Closed ofavre closed 5 years ago
You ain't wrong, but we get parse the metrics during runtime from varnishstat JSON here https://github.com/jonnenauha/prometheus_varnish_exporter/blob/master/varnish.go#L128-L140
There is no info/property that I know of from varnish stats that would tell us/infer if it moves up and down or just up all the time. We could assume all are counters, but that's basically what I'm already doing and assuming all are gauges because it is the safer bet from the two of them.
Also the fact that if varnish gets restarted/reloaded some of the reported values goes to zero. I don't know how strict prometheus is about counters never going back to zero, I would think it is enforced and causes some kind of error. Then again all programs that provide metrics, can restart at any point and take all of their counters back to zero. I guess its just during one run they must only go up, in that case you are right. But in our case they can go back to zero during one run of the exporter.
Hope that explains the current choice. What would be the practical impact for you of making some or all values counters instead of gauges?
@jonnenauha I might be wrong, but I think that the "flag": "c"
means counter, "g"
would mean gauge, etc. I have to +1 @ofavre's request that we send the data as it is intended.
I'm going to make this change. I'll bump up the version to 1.5 for the next release. I doubt this will break anything in the wild. Prometheus/grafana does not seem to care which type it is. Already if varnish is rebooted/reloaded some counter values can go back to zero, prometheus and grafana should handle this fine.
I found this documentation https://varnish-cache.org/docs/trunk/reference/varnish-counters.html#varnish-counters-7 which says clearly "counter" and "gauge" and that looks to correspond to the "c" and "g" flag property in the JSON output.
Thanks for the suggestion, sorry it took this long. I'm now on summer vacation and have more time to look into these issues cumulated here :)
The new release now has this fix in. You can try it out from https://github.com/jonnenauha/prometheus_varnish_exporter/releases/tag/1.5
6.0.0
1.4.1
Every metric is exported as a gauge (as I saw using
curl ip:9145/metrics | grep TYPE
). While this is fine for Grafana that permits manipulating the data, it is impractical with other tools, such as StackDriver. For instancevarnish_main_client_req
is an ever increasing value that should havecounter
type instead, so that StackDriver users could graph the number of requests per second (hopefully mapping to their cumulative type).