How to set a metric value and then reset it ?

159 views
Skip to first unread message

rahul bawa

unread,
Apr 29, 2020, 2:15:10 PM4/29/20
to Prometheus Users
I use the python client for storing metrics for a user's online presence. For example when a user comes online I start counting seconds and then as soon as he goes offline ,I post the metric to grafana. Now after posting the online timespan I immediately need to update that user has gone offline so I set the metric value to 0.

The last update remains and the one value before it does not appear on grafana as prometheus metric show the last metric reading only (checked via /metrics)

# Steps to reproduce

# Example using a Gauge class in the client

- User 1 comes online for 20 seconds
- /metrics updated with 20seconds
- Now set /metrics to 0 since user has gone offline.
- Earlier metric disappeared.

Reply all
Reply to author
Forward
0 new messages