<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Grafana on Jorge Luis Betancourt</title><link>https://jorgelbg.me/tags/grafana/</link><description>Recent content in Grafana on Jorge Luis Betancourt</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 18 Mar 2020 00:00:00 +0100</lastBuildDate><atom:link href="https://jorgelbg.me/tags/grafana/index.xml" rel="self" type="application/rss+xml"/><item><title>Displaying geohash tags from a Loki datasource in a Grafana Worldmap Panel</title><link>https://jorgelbg.me/2020/03/displaying-geohash-tags-from-a-loki-datasource-in-a-grafana-worldmap-panel/</link><pubDate>Wed, 18 Mar 2020 00:00:00 +0100</pubDate><guid>https://jorgelbg.me/2020/03/displaying-geohash-tags-from-a-loki-datasource-in-a-grafana-worldmap-panel/</guid><description>&lt;blockquote&gt;&#10;&lt;h3 id="-loki-v2x"&gt;🚧 Loki v2.x&lt;/h3&gt;&#10;&lt;p&gt;Loki v2.0 included a new set of features to the query language that allows extraction of labels at&#10;query time, unlocking new possibilities. This means that previously we would need to have the&#10;&lt;code&gt;geohash&lt;/code&gt; information as a label (which is not a great idea). Loki works best when you have a small&#10;set of labels (with &lt;a href="https://grafana.com/blog/2020/04/21/how-labels-in-loki-can-make-log-queries-faster-and-easier/"&gt;no high&#10;cardinality&lt;/a&gt;).&#10;A &lt;code&gt;geohash&lt;/code&gt; field is a very bad candidate for a label 🙃, in our defense before Loki v2.0 this was&#10;the only way of using the &lt;code&gt;geohash&lt;/code&gt; in the worldmap plugin.&lt;/p&gt;&#10;&lt;p&gt;With the new &lt;a href="https://grafana.com/docs/loki/latest/logql/#parser-expression"&gt;Parser expressions&lt;/a&gt; we&#10;can extract labels (at query time) and used them as normal labels in our queries. For instance,&#10;instead of using the old:&lt;/p&gt;&#10;&#10;&lt;div class="code-frame"&gt;&#10; &lt;div class="code-bar" aria-hidden="true"&gt;&#10; &lt;span class="code-dots"&gt;&lt;i&gt;&lt;/i&gt;&lt;i&gt;&lt;/i&gt;&lt;i&gt;&lt;/i&gt;&lt;/span&gt;&#10; &lt;span class="code-lang"&gt;js&lt;/span&gt;&#10; &lt;/div&gt;&#10; &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count_over_time&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="nx"&gt;geohash&lt;/span&gt;&lt;span class="o"&gt;=~&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;.+&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;}[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;h&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; &lt;span class="nx"&gt;by&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;geohash&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;p&gt;which expects the geo information in a &lt;code&gt;geohash&lt;/code&gt; label. We can instead use the &lt;code&gt;| logfmt&lt;/code&gt; parser&#10;expression to extract the &lt;code&gt;geohash&lt;/code&gt; information from the payload into a label at query time.&lt;/p&gt;&#10;&#10;&lt;div class="code-frame"&gt;&#10; &lt;div class="code-bar" aria-hidden="true"&gt;&#10; &lt;span class="code-dots"&gt;&lt;i&gt;&lt;/i&gt;&lt;i&gt;&lt;/i&gt;&lt;i&gt;&lt;/i&gt;&lt;/span&gt;&#10; &lt;span class="code-lang"&gt;js&lt;/span&gt;&#10; &lt;/div&gt;&#10; &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count_over_time&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="nx"&gt;domain&lt;/span&gt;&lt;span class="o"&gt;=~&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;jorgelbg.me&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;logfmt&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; &lt;span class="nx"&gt;by&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;geohash&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;p&gt;This has the advantage of not polluting our set of identifiable labels and helping to keep Loki&#10;queries as fast as possible.&lt;/p&gt;&#10;&lt;p&gt;Note: Beside the &lt;code&gt;| logfmt&lt;/code&gt; parser it is also possible to use the &lt;code&gt;| json&lt;/code&gt; one if the payload sent&#10;to Loki is in the JSON format.&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>Display the application's version in your Grafana dashboards</title><link>https://jorgelbg.me/2019/02/display-the-applications-version-in-your-grafana-dashboards/</link><pubDate>Sun, 17 Feb 2019 14:00:28 +0100</pubDate><guid>https://jorgelbg.me/2019/02/display-the-applications-version-in-your-grafana-dashboards/</guid><description>&lt;p&gt;At work, we needed a way to monitor the lag of some Kafka consumers reading&#10;business-critical topics.&lt;/p&gt;&#10;&lt;p&gt;We ended up using &lt;a href="https://github.com/danielqsj/kafka_exporter/"&gt;this exporter&lt;/a&gt;&#10;that provided exactly the metrics that we needed. After adding &lt;a href="https://github.com/danielqsj/kafka_exporter/pull/75"&gt;metadata caching&lt;/a&gt;&#10;to reduce the load on our Kafka cluster we deployed the exporter to our Nomad&#10;cluster and started to build dashboards.&lt;/p&gt;&#10;&lt;p&gt;While I was making changes to the application. I needed not only to check the&#10;logs but also to graph the data that the exporter was getting from Kafka, to&#10;make sure that my changes were not breaking the normal behavior. Yes,&#10;I love metrics and &lt;a href="http://jorgelbg.github.io/posts/logs-metrics-for-small-data/"&gt;I create graphs even while writing code 😂&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Optimize Grafana dashboards with Elasticsearch index aliases</title><link>https://jorgelbg.me/2018/12/optimize-grafana-dashboards-with-elasticsearch-index-aliases/</link><pubDate>Thu, 20 Dec 2018 00:00:00 +0100</pubDate><guid>https://jorgelbg.me/2018/12/optimize-grafana-dashboards-with-elasticsearch-index-aliases/</guid><description>&lt;p&gt;Grafana is a very popular opensource dashboarding solution. Provides support&#10;for a long list of storage solutions, including Elasticsearch.&#10;Unfortunately, the ES support is not at the same level as the one you get for&#10;InfluxDB, for instance. Still, Grafana allows combining in the same&#10;dashboard different data sources. It is possible to have a panel fetching data&#10;from ES and a different panel fetching data from InfluxDB.&lt;/p&gt;&#10;&lt;h2 id="grafana--elasticsearch"&gt;Grafana ❤️ Elasticsearch&lt;/h2&gt;&#10;&lt;p&gt;Grafana provides stellar support for &lt;a href="https://www.influxdata.com/"&gt;InfluxDB&lt;/a&gt;&#10;&amp;amp; &lt;a href="http://docs.grafana.org/features/datasources/prometheus/"&gt;Prometheus&lt;/a&gt;,&#10;among others. This means that you get, query autocompletion for fields, values,&#10;etc. When you select ES as a data source for a panel, the features are a bit less&#10;polished. You are greet by a &amp;ldquo;Lucene query&amp;rdquo; input and some more options.&#10;Depending on the metric (aggregation), Grafana also provides some help&#10;for field name selection when using ES as a data source.&lt;/p&gt;</description></item><item><title>Logs and metrics for Small Data</title><link>https://jorgelbg.me/2018/08/logs-and-metrics-for-small-data/</link><pubDate>Thu, 23 Aug 2018 05:42:44 +0200</pubDate><guid>https://jorgelbg.me/2018/08/logs-and-metrics-for-small-data/</guid><description>&lt;p&gt;This post is a personal comment. I&amp;rsquo;m going to talk about how using some tools&#10;thought for &amp;ldquo;Big Data&amp;rdquo;™ makes sense for common development tasks. If you hear&#10;someone talking about ELK, Grafana or Prometheus, you wouldn&amp;rsquo;t think about a&#10;system to run your laptop during development, right?&lt;/p&gt;&#10;&lt;h2 id="logs"&gt;Logs&lt;/h2&gt;&#10;&lt;p&gt;Concatenating files, parsing logs, are some of those tasks that are part of our&#10;daily routine as developers. We type lots of commands (usually connected via&#10;pipes &lt;code&gt;|&lt;/code&gt;) to accomplish a given goal.&lt;/p&gt;</description></item></channel></rss>