grafana-zabbix
grafana-zabbix copied to clipboard
Zabbix queries do not process variables when an expression is present on a panel
Describe the bug On a panel with a Zabbix query which has an item which includes a dashboard variable, adding an expression to the panel will cause the variable to be interpreted literally, rather than being replaced with the value.
Expected behavior When an expression is added to a panel containing a Zabbix query which includes a variable, the variable should continue to resolve to the currently selected value(s).
Screenshots
Software versions
Grafana | Zabbix | Grafana-Zabbix Plugin |
---|---|---|
9.1.3 | 6.2.2 | 4.2.10 |
Same issue here, built a panel with 6 Zabbix metrics queries, which work fine with a defined variable. As soon as an expression (e.g. simple math expression) is added to the panel, variable substitution stops working.
Query inspector shows just "$variable" instead of the variable value.
Removing the expression immediately causes variable substitution to start working again on the queries.
Grafana | Zabbix | Grafana-Zabbix Plugin |
---|---|---|
9.4.7 | 5.0.27 | 4.3.1 |
This is still a problem.
Short Version
# NO EXPRESSION
"group": {
"filter": "/REPLACED_FROM_VARIABLE_zgroup/" <=======
},
"host": {
"filter": "/REPLACED_FROM_VARIABLE_zhost/" <=======
},
VS
# WITH EXPRESSION
"group": {
"filter": "$zgroup" <======= Not replaced
},
"host": {
"filter": "$zhost" <======= Not replaced
},
NO EXPRESSION
{
"request": {
"url": "api/ds/query",
"method": "POST",
"data": {
"queries": [
{
"schema": 12,
"queryType": "0",
"group": {
"filter": "/REPLACED_FROM_VARIABLE_zgroup/" <=======
},
"host": {
"filter": "/REPLACED_FROM_VARIABLE_zhost/" <=======
},
"application": {
"filter": ""
},
"itemTag": {
"filter": ""
},
"item": {
"filter": "CPU system time"
},
"macro": {
"filter": ""
},
"functions": [],
"trigger": {
"filter": ""
},
"countTriggersBy": "",
"tags": {
"filter": ""
},
"proxy": {
"filter": ""
},
"textFilter": "",
"options": {
"showDisabledItems": false,
"skipEmptyValues": false,
"disableDataAlignment": false,
"useZabbixValueMapping": false,
"useTrends": "default",
"count": false
},
"table": {
"skipEmptyValues": false
},
"datasource": {
"type": "alexanderzobnin-zabbix-datasource",
"uid": "abbbc7e1-3d4a-4cab-b662-792ad91ed677"
},
"refId": "A",
"resultFormat": "time_series",
"datasourceId": 2,
"intervalMs": 120000,
"maxDataPoints": 686
},
{
"schema": 12,
"queryType": "0",
"group": {
"filter": "/REPLACED_FROM_VARIABLE_zgroup/"
},
"host": {
"filter": "/REPLACED_FROM_VARIABLE_zhost/"
},
"application": {
"filter": ""
},
"itemTag": {
"filter": ""
},
"item": {
"filter": "CPU user time"
},
"macro": {
"filter": ""
},
"functions": [],
"trigger": {
"filter": ""
},
"countTriggersBy": "",
"tags": {
"filter": ""
},
"proxy": {
"filter": ""
},
"textFilter": "",
"options": {
"showDisabledItems": false,
"skipEmptyValues": false,
"disableDataAlignment": false,
"useZabbixValueMapping": false,
"useTrends": "default",
"count": false
},
"table": {
"skipEmptyValues": false
},
"datasource": {
"uid": "abbbc7e1-3d4a-4cab-b662-792ad91ed677",
"type": "alexanderzobnin-zabbix-datasource"
},
"refId": "B",
"hide": false,
"resultFormat": "time_series",
"datasourceId": 2,
"intervalMs": 120000,
"maxDataPoints": 686
}
],
"range": {
"from": "2023-06-14T09:46:58.695Z",
"to": "2023-06-15T09:46:58.695Z",
"raw": {
"from": "now-24h",
"to": "now"
}
},
"from": "1686736018695",
"to": "1686822418695"
},
"hideFromInspector": false
},
"response": {
"results": {
"A": {
"status": 200,
"frames": [
{
"schema": {
"name": "REDACTED: CPU system time",
"refId": "A",
"fields": [
{
"name": "Time",
"type": "time",
"typeInfo": {
"frame": "time.Time"
}
},
{
"name": "Value",
"type": "number",
"typeInfo": {
"frame": "float64",
"nullable": true
},
"labels": {
"host": "REDACTED",
"item": "CPU system time",
"item_key": "system.stat[cpu,sy]"
},
"config": {
"displayNameFromDS": "REDACTED: CPU system time",
"custom": {
"scopedVars": {
"__zbx_host": {
"text": "",
"value": "REDACTED"
},
"__zbx_host_name": {
"text": "",
"value": "REDACTED"
},
"__zbx_item": {
"text": "",
"value": "CPU system time"
},
"__zbx_item_interval": {
"text": "",
"value": "1m"
},
"__zbx_item_key": {
"text": "",
"value": "system.stat[cpu,sy]"
},
"__zbx_item_name": {
"text": "",
"value": "CPU system time"
}
},
"units": "%"
},
"unit": "percent",
"min": 0,
"max": 100
}
}
]
},
"data": {
"values": [
[
1686735960000,
... more data ...
]
]
}
}
],
"refId": "A"
},
"B": {
"status": 200,
"frames": [
{
"schema": {
"name": "REDACTED: CPU user time",
"refId": "B",
"fields": [
{
"name": "Time",
"type": "time",
"typeInfo": {
"frame": "time.Time"
}
},
{
"name": "Value",
"type": "number",
"typeInfo": {
"frame": "float64",
"nullable": true
},
"labels": {
"host": "REDACTED",
"item": "CPU user time",
"item_key": "system.stat[cpu,us]"
},
"config": {
"displayNameFromDS": "REDACTED: CPU user time",
"custom": {
"scopedVars": {
"__zbx_host": {
"text": "",
"value": "REDACTED"
},
"__zbx_host_name": {
"text": "",
"value": "REDACTED"
},
"__zbx_item": {
"text": "",
"value": "CPU user time"
},
"__zbx_item_interval": {
"text": "",
"value": "1m"
},
"__zbx_item_key": {
"text": "",
"value": "system.stat[cpu,us]"
},
"__zbx_item_name": {
"text": "",
"value": "CPU user time"
}
},
"units": "%"
},
"unit": "percent",
"min": 0,
"max": 100
}
}
]
},
"data": {
"values": [
[
1686735960000,
... more data.
]
]
}
}
],
"refId": "B"
}
}
}
}
WITH EXPRESSION
{
"request": {
"url": "api/ds/query?expression=true",
"method": "POST",
"data": {
"queries": [
{
"schema": 12,
"queryType": "0",
"group": {
"filter": "$zgroup"
},
"host": {
"filter": "$zhost"
},
"application": {
"filter": ""
},
"itemTag": {
"filter": ""
},
"item": {
"filter": "CPU system time"
},
"macro": {
"filter": ""
},
"functions": [],
"trigger": {
"filter": ""
},
"countTriggersBy": "",
"tags": {
"filter": ""
},
"proxy": {
"filter": ""
},
"textFilter": "",
"options": {
"showDisabledItems": false,
"skipEmptyValues": false,
"disableDataAlignment": false,
"useZabbixValueMapping": false,
"useTrends": "default",
"count": false
},
"table": {
"skipEmptyValues": false
},
"datasource": {
"uid": "abbbc7e1-3d4a-4cab-b662-792ad91ed677",
"type": "alexanderzobnin-zabbix-datasource"
},
"refId": "A",
"resultFormat": "time_series",
"datasourceId": 2,
"intervalMs": 120000,
"maxDataPoints": 686
},
{
"schema": 12,
"queryType": "0",
"group": {
"filter": "$zgroup"
},
"host": {
"filter": "$zhost"
},
"application": {
"filter": ""
},
"itemTag": {
"filter": ""
},
"item": {
"filter": "CPU user time"
},
"macro": {
"filter": ""
},
"functions": [],
"trigger": {
"filter": ""
},
"countTriggersBy": "",
"tags": {
"filter": ""
},
"proxy": {
"filter": ""
},
"textFilter": "",
"options": {
"showDisabledItems": false,
"skipEmptyValues": false,
"disableDataAlignment": false,
"useZabbixValueMapping": false,
"useTrends": "default",
"count": false
},
"table": {
"skipEmptyValues": false
},
"datasource": {
"uid": "abbbc7e1-3d4a-4cab-b662-792ad91ed677",
"type": "alexanderzobnin-zabbix-datasource"
},
"refId": "B",
"hide": false,
"resultFormat": "time_series",
"datasourceId": 2,
"intervalMs": 120000,
"maxDataPoints": 686
},
{
"refId": "C",
"datasource": {
"type": "__expr__",
"uid": "__expr__",
"name": "Expression"
},
"type": "math",
"hide": false,
"expression": "$A + $B",
"window": ""
}
],
"range": {
"from": "2023-06-14T09:44:33.040Z",
"to": "2023-06-15T09:44:33.040Z",
"raw": {
"from": "now-24h",
"to": "now"
}
},
"from": "1686735873040",
"to": "1686822273040"
},
"hideFromInspector": false
},
"response": {
"results": {
"A": {
"status": 200,
"frames": [],
"refId": "A"
},
"B": {
"status": 200,
"frames": [],
"refId": "B"
},
"C": {
"status": 200,
"frames": [],
"refId": "C"
}
}
}
}
I have same issue j-papathanasis, has it been resolved??
FYI. We ran into this exact issue at a customer site last week. It is easily reproducible and happens only when using the Zabbix integration and having an expression in the same panel. A possible workaround is to move the calculation from the expression to a transformation, depending on the nature of your expression.