Reputation: 15266
I am currently in the process of moving my metrics from statsd
to prometheus
.
I'm struggling with converting queries from statsD syntax to prometheus. I'm not clear on this and am looking for some documentation comparing the two. Specifically this range syntax [5m] and rate etc. It doesn't clearly translate to statsD language.
In this example I want to measure and graph average lag time of events being processed, between the timestamp the event was created (attribute on an event) to the current time the metric is reported by the code itself:
Pseudo:
def processEvent(event)
eventTime = event.timestamp
now = Now()
lag = now - eventTime
...
statsD.time(...metric_name(event.feed,event.action)..., lag)
the statsD query looks like this:
groupByNode(stats.timers.<node_ip>.lag.<feed>.<action>.mean, 4, 'avg')
(the average time of the mean reported for this metric across all instances)
in my new code creating the metric like this:
current_lag_gauge = Gauge('kafka_lag', 'tracks the lag of events',labelnames=['feed', 'action'])
lag = event.timestamp - Now()
...
current_lag_gauge.labels(feed="v1", action="v2").set(lag)
the library is adding some additional labels. the metric appears like this:
kafka_lag{action="v2",app="app1",base_chart_version="xxx",feed="123",instance="1.2.3.4:8000",job="kubernetes-xxx",kubernetes_namespace="xxxx",kubernetes_pod_name="xxxxx",pod_template_hash="123431314",release="xxxx"}
Is there a reference guide or cheat sheet comparing the 2? Would also be glad to get a couple example queries solving this translation.
Upvotes: 1
Views: 808
Reputation: 6765
There's a great post in Robust Perception covering translations between monitoring languages.
It doesn't cover the exact use case you've mentioned but can be a good reference for approaching this problem.
Regarding your specific query, I think that avg(kafka_lag) by (feed)
should give you roughly the same results as the statsd query you've mentions, but I'm not completely sure as I don't have 2 sets of data to play with and compare.
Upvotes: 0