prometheus / nagios_plugins

Nagios plugins for alerting on Prometheus query results
Apache License 2.0
104 stars 45 forks source link

Getting parse error #6

Closed nickvth closed 8 years ago

nickvth commented 8 years ago

[root@apps1 nagios_plugins]# ./check_prometheus_metric.sh -H 'http://localhost' -q 'count(consul_health_service_status{service="test"}) - sum(consul_health_service_status{service="test"})' -c 2 -w 1 -n test UNKNOWN - unable to parse prometheus response test is {};0;1452182545.297

when sh -x ++ get_prometheus_result ++ local _PROMETHEUS_CMD ++ local _RESULT ++ printf -v _PROMETHEUS_CMD '%s -server=%s -timeout=%s query' '/bin/docker run --rm -ti prom/prometheus-cli' http://localhost 30s +++ /bin/docker run --rm -ti prom/prometheus-cli -server=http://localhost -timeout=30s query 'count(consul_health_service_status{service="test"}) - sum(consul_health_service_status{service="test"})' '+ _RESULT='{};0;1452182314.599 =~ ^-?[0-9]+.?[0-9]*$ ]] ++ case "$_RESULT" in '+ printf %s '{};0;1452182314.599 ' PROMETHEUS_RESULT='{};0;1452182314.599 =~ ^-?[0-9]+$ ]]314.599

beorn7 commented 8 years ago

You have to wrap your expression into scalar(...).