It sounds like you're attacking this from the wrong direction. What I believe you want is a counter of drift events. Each time a drift event occurs, you increment the counter. 0 to 1, 1 to 2, 2 to 3 etc. Never reset it to 0. This is the standard and most useful way to handle such data in Prometheus. Using a proper counter also handles edge cases that you might not have considered, such as two of these "drift events" occurring between scrapes.
You can the write queries (e.g. for alerts) which will tell you whether the counter has increased in the last 10 minutes, or the last hour, or whatever. Such things *will* naturally reset to zero. For example, here's an alerting rule I use: expr: increase(megaraid_pd_shield_counter[72h]) > 0 This gives an alarm whenever the counter has increased; when it *hasn't* increased for 72 hours then the alert is cleared. P.S. Note that you don't "push" a value to prometheus; prometheus "pulls" a value by scraping the exporter. On Wednesday, 16 February 2022 at 15:29:50 UTC [email protected] wrote: > Hi Brian, > > Good day, > > I have a code that monitors a drift in data > > If drift happens I need to push value 1 to prometheus > Default 0 , issue is when I set gauge as 1, It is 1 till I set it back to > 0 > > Is there any metric where I can push the value 1 and it resets to 0 > automatically ? > > Regards, > Yegna > > > > On Fri, Jan 21, 2022 at 04:35 Brian Candler <[email protected]> wrote: > >> > I have considered the grafana data source option but I found a plugin >> for mongoDb which is available only in enterprise grafana >> > >> > So do you suggest me to create a data source for mongoDB in grafana ? >> >> That's a grafana question, not a prometheus question; it would be better >> asked in the grafana community <https://community.grafana.com/>. >> >> > And regarding 2 and 3 - since we use python - Is prometheus-python >> client API useful to directly write to prometheus ? (remote write protocol) >> >> If you mean https://github.com/prometheus/client_python, then as far as >> I know it's only an exporter, not a remote write client. Remote write was >> option 3. You could send data to vector.dev using one of its many source >> adapters, and let it do the remote write >> <https://vector.dev/docs/reference/configuration/sinks/prometheus_remote_write/> >> >> for you. >> >> In option 2, what I was thinking was that you could expose the data as a >> regular exporter, at the same time as you write it to MongoDB. Prometheus >> can then scrape this as normal, i.e. it will scrape the *most recent" >> updated value only. >> >> -- >> > You received this message because you are subscribed to the Google Groups >> "Prometheus Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/prometheus-users/a84587cb-9db9-496c-a7f8-e1442c16a8e2n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/prometheus-users/a84587cb-9db9-496c-a7f8-e1442c16a8e2n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Prometheus Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/1e9affbe-96b4-4cdd-86e7-2b93543ab117n%40googlegroups.com.

