Marek M.
Marek M.

Reputation: 3951

Picking the right prometheus function to show graph of time measurements data

I have a gauge metric which I'm updating with the value of time that elapsed since starting of some processing, like that:

var watch = System.Diagnostics.Stopwatch.StartNew();

DoSomeProcessing();

watch.Stop();
_performanceGauge.Set(watch.ElapsedMilliseconds);

I would like that to be reflected in grafana dashboard but I'm having problems picking up correct function for this task. I thought about using the idelta function, but it results in a flat graph:

idelta(bg_process_performance[2h])

So which one should I use?

Upvotes: 1

Views: 875

Answers (1)

brian-brazil
brian-brazil

Reputation: 34152

If it's a Gauge then you should display the raw value with no functions.

If you care about more than the most recent event, then you should use a Summary/Histogram instead and then calculate irate(my_metric_sum[1m])/irate(my_metric_count[1m]) to get the average latency.

Upvotes: 1

Related Questions