Deepthi
Deepthi

Reputation: 545

Prometheus : How to collect metrics for memory consumption of temporary processes?

I have an application that spawns different processes asynchronously. When the process finishes, the response contains details of the process like memory consumed etc. I want to create metrics for the memory consumed by each process, based on the output. (Note: This means I can only update the metric only after the process finishes)

From the Prometheus official document I found that Gauge is the correct metric for such a measurement, when values go up and down arbitrarily. But the problem using Gauge is that the metric value stays there for ever. I want to track the value used by the process only for that instant of time.

When i plot the graph of Grafana, I see a steady line, when i only want a surge for an instant. Any suggestions to best solve this problem. Thanks !

Upvotes: 0

Views: 1567

Answers (2)

yamenk
yamenk

Reputation: 51778

For short-lived jobs that cannot be scraped normally using Prometheus, Prometheus provides the push gateway which allows you to push metrics.

In your case, your short lived processes would push the reported metrics into the push gateway and Prometheus will handle the rest.

Upvotes: 1

Deepthi
Deepthi

Reputation: 545

As of now, this is my workaround:

I have created a metric of type Counter and I keep increasing the metric value by an absolute number(the actual memory consumed).

In Grafana I display the increase() every 1 minute.

If anyone has a more correct solution, please do tell.

Upvotes: 0

Related Questions