Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Make a simple graph

Collignon-Ducret Rémi edited this page Oct 12, 2018 · 3 revisions

You want to make a simple graph, you know which Time series you want on it, but the result is not as expected. Let's enhance this ones.

Every time you see READ_TOKEN, replace it by a valid Warp10 read token.

Basic Warp10 query

Let's take the minimal query:

[ 'READ_TOKEN' 'os.cpu' {} NOW 1 h ] FETCH

This query will display a metric named os.cpu ont the graph. The first issue you will notice appear when you try to change the time range on you dashboard settings (Grafana top right corner)

We might make this query dynamic, isn't it ?

[ 'READ_TOKEN' 'os.cpu' {} $end $interval ] FETCH

Wait ! what is $end $interval? This is 2 variables injected on top of your query, there are respectively the right limit of the graph (equivalent to now) and the time interval chosen (Ex: 1 h)

Query with this variables will adapt your time query to match Grafana ones.

There is some others variables injected, see Variables section

Ok, so let's see the next issue, your graph looks good when you look at it with a 1 h time range ? what about 1 month. There will be too much datapoints to display, in most of the time, your browser will crash. We have to down-sample the metric to take only significant count of datapoints. let's bucketize.

[ 'READ_TOKEN' 'os.cpu' {} $end $interval ] FETCH
[ SWAP bucketizer.max $end 0 100 ] BUCKETIZE

With that, the query will firstly fetch datapoints on the choosen time range and then down-sample your metric to get only 100 datapoints per series... no more than 100.

You can alternatively down-sample with a bucket time duration instead of the count of datapoints.

[ 'READ_TOKEN' 'os.cpu' {} $end $interval ] FETCH
[ SWAP bucketizer.max $end 5 m 0 ] BUCKETIZE

Last issue !

You move the cursor on the panel, but the datapoint shown is not the one you are hover. This is because Time series manipulation on Warp10 doesn't sort ticks by timestamp (Warp10 doesn't do a thing that is not necessary). Let's sort the ticks for Grafana.

[ 'READ_TOKEN' 'os.cpu' {} $end $interval ] FETCH
[ SWAP bucketizer.max $end 5 m 0 ] BUCKETIZE
SORT
Clone this wiki locally