Average Metric in Grafana Time Series Panel gives total different Graph result than when it is created in Kibana

  • What Grafana version and what operating system are you using?
    Grafana 11.1.2 on Ubuntu 22_04

  • What are you trying to achieve?
    Creating a time series graph with counter data from Elasticsearch that gives the same outcome as when it is created in Elasticsearch itself (Kibana)

  • How are you trying to achieve it?

  • What happened?
    The data shown in the Time Series panel with Metric average gives a totally other graph than the one in Kibana. (The one in Kibana is correct).
    It looks like the average calculation is completely different in Grafana and gives a completely misleading graph.
    This is how the graph shoud look like:


    This is how it looks with data from Elasticsearch:

  • What did you expect to happen?
    Getting the same graph as in Kibana.

  • Can you copy/paste the configuration(s) that you are having problems with?
    This is the query in Grafana:
    {
    “datasource”: {
    “type”: “elasticsearch”,
    “uid”: “uidofdatasource”
    },
    “alias”: “”,
    “bucketAggs”: [
    {
    “field”: “@timestamp”,
    “id”: “2”,
    “settings”: {
    “interval”: “1m”,
    “timeZone”: “Europe/Brussels”
    },
    “type”: “date_histogram”
    }
    ],
    “hide”: false,
    “metrics”: [
    {
    “field”: “CTR.per hour”,
    “id”: “1”,
    “type”: “avg”
    }
    ],
    “query”: “host.hostname:$Smartbox”,
    “refId”: “A”,
    “timeField”: “@timestamp”
    }
    ],
    “title”: “$Smartbox Counter-data from Elastic (average on interval per minute)”,
    “type”: “timeseries”

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No

  • Did you follow any online instructions? If so, what is the URL?
    Could not find anything in the current info on the internet

I found the problem. There were 2 problems, one obvious one I did not see immediately and the second one was syntax. In Grafana the Lucene query was: host.hostname.keyword : $Smartbox.our.domain.name. With $Smartbox as variable.
The obvious problem: The name in $Smartbox was in Upper case and had to be in Lower case.
The syntax problem: The Lucene query needs to be written as following:
host.hostname.keyword : ${Smartbox:text}.our.domain.name
Problem Solved!

1 Like