Grafana 8 Gauge does not display query aliases as labels

  • What Grafana version and what operating system are you using?

  • Grafana v8.0.5 (cbb2aa5001)

  • Linux Mint 20.1 Cinnamon

  • InfluxDB v1.9

  • What are you trying to achieve?
    Display 4 x standard circular gauges in a panel which uses 4 queries (there are 4 batteries), each gauge labelled underneath with the Alias of its respective query (e.g. “Battery 1”).

  • How are you trying to achieve it?
    By adding the text to the ALIAS field of the query template. (That method works OK for the BarGraph component).

  • What happened?
    The Query Aliases were not used as labels for the Gauge instances (see image below):

  • What did you expect to happen?
    Consistent with other panel controls (e.g. the BarGraph), I expected that the query alias would be used as a label for each gauge instance in the panel.

  • Can you copy/paste the configuration(s) that you are having problems with?
    See JSON segment at the foot of this post.

Here is an example of one of the queries.

Using the Query Inspector I see the following, but I note that no aliases are visible in the inspector’s query text:

SELECT last(“value”) FROM “batt_current” WHERE (“site” = ‘Bananaville’
AND “batt_num” = ‘1’) AND time >= now() - 24h and time <= now()
GROUP BY time(1m) fill(null);

SELECT last(“value”) FROM “batt_current” WHERE (“site” = ‘Bananaville’
AND “batt_num” = ‘2’) AND time >= now() - 24h and time <= now()
GROUP BY time(1m) fill(null);

SELECT last(“value”) FROM “batt_current” WHERE (“site” = ‘Bananaville’
AND “batt_num” = ‘3’) AND time >= now() - 24h and time <= now()
GROUP BY time(1m) fill(null);

SELECT last(“value”) FROM “batt_current” WHERE (“site” = ‘Bananaville’
AND “batt_num” = ‘4’) AND time >= now() - 24h and time <= now()
GROUP BY time(1m) fill(null)

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No - the gauge works OK except that none of the gauge instances has a label to uniquely identify them (each query relating to a particular gauge instance does have a unique Alias defined, which we intended to be used as a label).

  • Did you follow any online instructions? If so, what is the URL?
    No.

Here is the panel JSON text. I note that the Alias definition does appear in the JSON text.

{
“id”: 36,
“gridPos”: {
“h”: 6,
“w”: 14,
“x”: 10,
“y”: 0
},
“type”: “gauge”,
“title”: “Battery Currents (-ve = Charging)”,
“datasource”: “Power Metrics - AWS”,
“pluginVersion”: “8.0.5”,
“fieldConfig”: {
“defaults”: {
“thresholds”: {
“mode”: “absolute”,
“steps”: [
{
“color”: “transparent”,
“value”: null
},
{
“color”: “green”,
“value”: -250
},
{
“color”: “yellow”,
“value”: 0
},
{
“color”: “super-light-orange”,
“value”: 250
}
]
},
“mappings”: ,
“color”: {
“mode”: “thresholds”
},
“decimals”: 1,
“max”: 50,
“min”: -50,
“noValue”: “N/A”,
“unit”: “amp”
},
“overrides”:
},
“options”: {
“reduceOptions”: {
“values”: false,
“calcs”: [
“lastNotNull”
],
“fields”: “”
},
“showThresholdLabels”: true,
“showThresholdMarkers”: true,
“text”: {
“titleSize”: 1
}
},
“targets”: [
{
“alias”: “Battery 1”,
“groupBy”: [
{
“params”: [
“$__interval”
],
“type”: “time”
},
{
“params”: [
“null”
],
“type”: “fill”
}
],
“measurement”: “batt_current”,
“orderByTime”: “ASC”,
“policy”: “default”,
“refId”: “A”,
“resultFormat”: “time_series”,
“select”: [
[
{
“params”: [
“value”
],
“type”: “field”
},
{
“params”: ,
“type”: “last”
}
]
],
“tags”: [
{
“key”: “site”,
“operator”: “=”,
“value”: “Bananaville”
},
{
“condition”: “AND”,
“key”: “batt_num”,
“operator”: “=”,
“value”: “1”
}
]
},
{
“alias”: “Battery 2”,
“groupBy”: [
{
“params”: [
“$__interval”
],
“type”: “time”
},
{
“params”: [
“null”
],
“type”: “fill”
}
],
“hide”: false,
“measurement”: “batt_current”,
“orderByTime”: “ASC”,
“policy”: “default”,
“refId”: “B”,
“resultFormat”: “time_series”,
“select”: [
[
{
“params”: [
“value”
],
“type”: “field”
},
{
“params”: ,
“type”: “last”
}
]
],
“tags”: [
{
“key”: “site”,
“operator”: “=”,
“value”: “Bananaville”
},
{
“condition”: “AND”,
“key”: “batt_num”,
“operator”: “=”,
“value”: “2”
}
]
},
{
“alias”: “Battery 3”,
“groupBy”: [
{
“params”: [
“$__interval”
],
“type”: “time”
},
{
“params”: [
“null”
],
“type”: “fill”
}
],
“hide”: false,
“measurement”: “batt_current”,
“orderByTime”: “ASC”,
“policy”: “default”,
“refId”: “C”,
“resultFormat”: “time_series”,
“select”: [
[
{
“params”: [
“value”
],
“type”: “field”
},
{
“params”: ,
“type”: “last”
}
]
],
“tags”: [
{
“key”: “site”,
“operator”: “=”,
“value”: “Bananaville”
},
{
“condition”: “AND”,
“key”: “batt_num”,
“operator”: “=”,
“value”: “3”
}
]
},
{
“alias”: “Battery 4”,
“groupBy”: [
{
“params”: [
“$__interval”
],
“type”: “time”
},
{
“params”: [
“null”
],
“type”: “fill”
}
],
“hide”: false,
“measurement”: “batt_current”,
“orderByTime”: “ASC”,
“policy”: “default”,
“refId”: “D”,
“resultFormat”: “time_series”,
“select”: [
[
{
“params”: [
“value”
],
“type”: “field”
},
{
“params”: ,
“type”: “last”
}
]
],
“tags”: [
{
“key”: “site”,
“operator”: “=”,
“value”: “Bananaville”
},
{
“condition”: “AND”,
“key”: “batt_num”,
“operator”: “=”,
“value”: “4”
}
]
}
]
}

What have I missed or done wrong in the panel configuration?

Eric

what can you see if you click + button on the side of ‘select’

for me, Mysql, if I click +, I can see ‘Alias’
image

Boyke,

Thanks for your message.

I followed your suggestion and selected the Aliasing > alias, and changed the word “alias” to the required text for each query. The alias now appears in the query SQL:

SELECT last("value") AS "Battery 1" FROM "batt_current" WHERE ("site" = 'Bananaville' AND "batt_num" = '1') AND time >= now() - 24h and time <= now() GROUP BY time(1m) fill(null);

but unfortunately the alias text is still not displayed underneath the gauge controls as their labels.

It seems as though the behaviour of the control is inconsistent with other panel controls.

Eric

will this help?

so instead of having 1 column like your query

SELECT last("value") AS "Battery 1
...
GROUP BY time(1m) fill(null);

I have 3 columns:

SELECT 
  SUM(p.b) AS "PIR 10.5%",
  SUM(p.a) AS "PIR 17.5%",
  SUM(p.c) AS "PIR 28%"

Not sure that we can do this.

Influx is not a relational database like Postgres and in our specific case the number of batteries will be variable by site, so their data needs to be in a separate table to the site.

you can do it by Transfrom;
choose the Add field from calculation
like my image
what i want to do? i need to display Value #A (mean) to latency
how to do ? Add field you want, be care of , the mode of add field sure be Reduce row

This topic was automatically closed after 365 days. New replies are no longer allowed.