icingaweb2-module-grafana
icingaweb2-module-grafana copied to clipboard
Special chars on custom variables not working
Hey! I have an icinga service that has a custom variable with special chars ("=", ")", "}" etc...) The problem is - when sending this variable to grafana only the chars before the "=" are being sent to the dashboard. For example - the variable is: max(kube_deployment_spec_replicas{deployment="blabla"}) without (instance, pod)
and what is passed on to grafana is: max(kube_deployment_spec_replicas{deployment
Expected Behavior
Pass the entire content of the variable to grafana
Current Behavior
Only the chars after the "=" are being sent.
Your Environment
- Icinga Web 2 Grafana version (System - About): 1.3.6
- Icinga Web 2 version and modules (System - About): 2.5.1
- Version used (
icinga2 --version): 2.10.5-1 - Operating System and version: centos 7.5
Hello,
sorry for late reply. Can you please supply the link that is generated from the module (see debug mode).
Regards, Carsten
Hi, i am facing a similar problem, so here are some more details (same versions as above). The Content of the custom variable is cut at the '='
Service config:
apply Service "prometheus_up" { import "generic-service"
check_command = "check_prometheus"
vars.QUERY = "up{job="{{host}}"}" vars.NAME = "Prometheus UP" vars.TYPE = "vector" vars.METHOD = "lt" vars.WARNING = "1" vars.CRITICAL = "1"
assign where host.name == "{{host}}" && host.vars.prometheus == true }
graphs.ini
[check_prometheus] dashboard = "icinga2-integration" panelId = "4" customVars = "&var-query=$query$" repeatable = "no"
generated url:
https://grafana.void.ms/d-solo/nDHPzrjZk/icinga2-integration?var-hostname=webserver1&var-service=prometheus_up&var-command=check_prometheus&var-query=up%7Bjob&panelId=4&orgId=1&theme=light&from=now-3h&to=now
Hello,
you problem is how you assign the variable. The Variable ends at the second double quote. It should be (i think you want to put in the hostname
vars.QUERY = "up{job=" + host.name + "}"
or if it should be with quotes
vars.QUERY = "up{job=\"{{host}}\"}"
Regards, Carsten
@Mikesch-mp: im facing the same issue as the ones above.
Details: Plugin Version 1.4.2
Graph Config:

Query Variable:
| Query | (sum(container_memory_working_set_bytes{namespace="xxxxxx"}) BY (pod) / sum(container_spec_memory_limit_bytes{namespace="xxxxxx"} > 0) BY (pod) * 100) |
|---|
Debug Output from Grafana Graphs:
| Custom Variables | &var-query=%28sum%28container_memory_working_set_bytes%7Bnamespace |
|---|
it cuts directly at "=" and i already tried to escape the "=" with no success. Every escape character led to prometheus errors and didnt helped
hope you can help how to properly escape the "=" or passing "=" to a custom var
https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/239 is facing the same problem and i cant find any working solution in here
I think the problem is here: https://github.com/Mikesch-mp/icingaweb2-module-grafana/blob/2cae443a51f964f01f83b59c5d206bba08bd944d/library/Grafana/ProvidedHook/Grapher.php#L342-L353
the custom vars are split based on "=" and only the first and second array element are used to build the variable.
The issue can be fixed by replacing rawurlencode($arr[1]) with rawurlencode(implode('=',array_slice($arr, 1))) I will create a PR for that
greetings fl0w
@Mikesch-mp, can you give any update here or provide help :)?