<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
<p>New Hawkular blog post from noreply@hawkular.org (Joel Takvorian): http://ift.tt/2uPct0T<br><br></p>
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>There have been improvements lately in the Hawkular Grafana datasource that are worth mentioning.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The way to query metrics by tags has changed since plugin <a href="http://ift.tt/2ttB7Aj">v1.0.8</a>. It now takes advantage of the Hawkular Metrics' tags query language, that was introduced server-side in <a href="http://ift.tt/2kQeiVC">Metrics 0.24.0</a> and enhanced in <a href="http://ift.tt/2mMgdfM">0.25.0</a>. To sum it up, Metrics integrates a parser that allows queries such as: <code>tag1 = 'awesome!' AND tag2 NOT IN ['foo', 'bar']</code>.</p>
</li>
<li>
<p>The datasource in now able to fetch bucketized metrics stats, instead of raw metrics. It consists in aggregating datapoints in slices of time (buckets) and providing, for each slice, some statistics like <em>min</em>, <em>max</em>, <em>average</em> and more. The exact content of a bucket is described in <a href="http://ift.tt/2uQmzhP">Metrics REST API</a>. Hawkular has always been able to provide metric stats server-side, but being able to use them in the Grafana plugin is new, introduced in <a href="http://ift.tt/2ttUkBW">v1.0.9</a>.</p>
</li>
</ul>
</div>
<div class="imageblock text-center">
<div class="content"><img src="http://ift.tt/2uQ9JjA" alt="New query interface"></div>
</div>
<div class="paragraph text-center">
<p><em>The new query interface</em></p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_tags_query_language">Tags query language</h3>
<div class="paragraph">
<p>The first change is that you don’t have to choose between <em>query by tag</em> and <em>query by metric id</em> anymore, you can do both at the same time. Querying by tag will refine the available list of metric names (much like a filter) and can result in multiple metrics from a single query. By selecting a <em>metric name</em>, you restrict the query to only display that one. This filtering is really nice when there’s tons of metrics available, like in the case of hundreds of OpenShift pods being monitored with the same tenant.</p>
</div>
<div class="paragraph">
<p>The simple <em>key/value</em> pairs interface is now replaced with a more elaborated query builder, following the pattern: <em>'tag-key'</em> <em>'operator'</em> <em>'tag-value(s)'</em> [<em>'AND/OR'</em> etc.]</p>
</div>
<div class="paragraph">
<p>The following images show a walk-through:</p>
</div>
<div class="imageblock text-center">
<div class="content"><img src="http://ift.tt/2ttB87l" alt="Selecting tag key"></div>
</div>
<div class="paragraph text-center">
<p><em>Selecting the tag key</em></p>
</div>
<div class="imageblock text-center">
<div class="content"><img src="http://ift.tt/2uPNn1C" alt="Selecting tag operator"></div>
</div>
<div class="paragraph text-center">
<p><em>Selecting the tag operator</em></p>
</div>
<div class="imageblock text-center">
<div class="content"><img src="http://ift.tt/2ttB9bp" alt="Selecting tag value"></div>
</div>
<div class="paragraph text-center">
<p><em>Selecting the tag value</em></p>
</div>
<div class="paragraph">
<p>The text fields include dynamic suggestions, you can use Grafana template variables within tag values, or enter free text. Once you’ve set up a tag query expression, the relevant metrics immediately show up on the chart and the list of available metrics in the dropdown list in updated.</p>
</div>
<div class="imageblock text-center">
<div class="content"><img src="http://ift.tt/2uQ9KUG" alt="Filtered metrics"></div>
</div>
<div class="paragraph text-center">
<p><em>Filtered metrics</em></p>
</div>
<div class="paragraph">
<p>This query builder lets you build almost any tag query that the Hawkular server understands. There are however some corner cases. For now this builder doesn’t allow you to prioritize expressions with parentheses. For instance, you cannot build <code>c1 = 'foo' OR (b1 != 'B' AND a1 = 'abcd')</code>. As a workaround you can turn off the query builder and directly type in your query expression.</p>
</div>
<div class="imageblock text-center">
<div class="content"><img src="http://ift.tt/2ttB9Ir" alt="Toggle editor mode"></div>
</div>
<div class="paragraph text-center">
<p><em>Toggle editor mode</em></p>
</div>
<div class="paragraph">
<p>It will be sent as is to the Hawkular Metrics server. This will also be useful to fill the gap if the language evolves server-side and this plugin isn’t updated immediately.</p>
</div>
</div>
<div class="sect2">
<h3 id="_stats_query">Stats query</h3>
<div class="paragraph">
<p>The other important feature is the ability to run <a href="http://ift.tt/2uQ9N2O">stats</a> queries against Hawkular Metrics, instead of <a href="http://ift.tt/2ttB5bF">raw</a> queries. There are several reasons to do this:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>it reduces the network load, and client-side processing load, especially when raw data would contain tons of datapoints</p>
</li>
<li>
<p>it enables some aggregation methods</p>
</li>
<li>
<p>it also allows higher-level analysis with stats such as percentiles</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>To enable it, just clear the <em>raw</em> checkbox.</p>
</div>
<div class="imageblock text-center">
<div class="content"><img src="http://ift.tt/2uQ4twv" alt="Toggle stats mode"></div>
</div>
<div class="paragraph text-center">
<p><em>Toggle stats mode</em></p>
</div>
<div class="paragraph">
<p>When you clear the <em>raw</em> checkbox, you can configure <em>Multiple series aggregation</em> to <em>None</em>, <em>Sum</em> or <em>Average</em> and can configure <em>Stat type</em> as <em>avg</em>, <em>min</em>, <em>max</em>, <em>median</em>, <em>sum</em> and different percentiles. You can display several different <em>Stat types</em> within the same query.</p>
</div>
<div class="imageblock text-center">
<div class="content"><img src="http://ift.tt/2ttBaft" alt="Stats without aggregation"></div>
</div>
<div class="paragraph text-center">
<p><em>Stats without aggregation: each two metrics show avg, min and max</em></p>
</div>
<div class="imageblock text-center">
<div class="content"><img src="http://ift.tt/2uPRBpQ" alt="Stats avg"></div>
</div>
<div class="paragraph text-center">
<p><em>Same query with series aggregation: the two metrics are averaged into one, which shows avg, min and max</em></p>
</div>
<div class="paragraph">
<p>If the query returns multiple series, use <em>Multiple series aggregation</em> to define if and how to aggregate them. <em>None</em> will show them individually on the chart. But consider for instance the case of an OpenShift pod with many replicas, and you’re tracking their memory usage. It may be more relevant here to aggregate all of them, both <em>sum</em> and <em>average</em> are meaningful here.</p>
</div>
<div class="paragraph">
<p>The <em>Stat type</em> option refers to an aggregation at a different level: not between multiple metrics, but within a single metric, all raw datapoints are aggregated within time buckets.</p>
</div>
</div>
<div class="sect2">
<h3 id="_conclusion">Conclusion</h3>
<div class="paragraph">
<p>These two improvements aim a common goal, that is facilitating querying over large amounts of data. This is becoming crucial especially in the context of microservices and applications running on container platforms, as the number of metrics explodes. Proper metrics tagging is the corner stone to make sense of this data.</p>
</div>
</div>
<br><br>
from Hawkular Blog
</body></html>