Can we use prometheus to monitor a state(member variable) in a system

71 views
Skip to first unread message

Jeivardan

unread,
Sep 3, 2020, 11:09:29 PM9/3/20
to Prometheus Users
Consider an example my system has an object called chamber and one of its properties is pressure and I wish to monitor this pressure. Is it possible using prometheus?

Regards,
Jeivardan V

Tom Black

unread,
Sep 3, 2020, 11:12:59 PM9/3/20
to promethe...@googlegroups.com
you need to customize a plugin IMO. prometheus itself is
Language-independent.

regards.

Jeivardan

unread,
Sep 3, 2020, 11:25:17 PM9/3/20
to Prometheus Users
What do you mean by plugin IMO can explain in detail?

Tom Black

unread,
Sep 3, 2020, 11:38:06 PM9/3/20
to promethe...@googlegroups.com
Hi

Jeivardan wrote:
> What do you mean by plugin IMO can explain in detail?

Please check the documentation:
https://prometheus.io/docs/instrumenting/writing_exporters/

regards.

Jeivardan

unread,
Sep 4, 2020, 12:09:06 AM9/4/20
to Prometheus Users
Hi tom,
So what I understood from your reply is that we can monitor any state variables in a class or in a system using prometheus and for that we should write exporters? Is that right?

Regards,
Jeivardan V

Brian Candler

unread,
Sep 4, 2020, 3:10:51 AM9/4/20
to Prometheus Users
Yes, and there are multiple ways to do that.

Ideally you would integrate exporter capability into your existing application, using one of the client libraries.

You can run a standalone exporter like statsd_exporter, and send messages to it to update the state that it exposes.

At worst you can just write metrics into a file in the exposition format, then serve them using node_exporter's textfile collector, or even just a plain web server.

Jeivardan

unread,
Sep 4, 2020, 6:53:12 AM9/4/20
to Prometheus Users
And also I have another question.
Consider my application has 5 states(enums) and that change over time Can I monitor those kind of things.Any idea that which metrics(like gauge) can I use in that case. And another example might be consider my application has a state called voltage and also has min and Max threshold and I wish to monitor such state and create alerts whether gauge is the correct one to measure such kind(voltage, pressure etc ..).

Regards,
Jeivardan V

--
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 prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/0fb8c26d-043a-4ce0-911a-16742adbd9ebn%40googlegroups.com.

Brian Candler

unread,
Sep 4, 2020, 7:06:38 AM9/4/20
to Prometheus Users
You can monitor anything that can be represented as a float64 numeric value.  The meaning and units of those metrics is up to you - whether it be Volts or N/m^2 or whatever.

For enums it's conventional to have a separate timeseries for each choice:

mymetric{state="foo"} 0
mymetric{state="bar"} 1
mymetric{state="baz"} 0
mymetric{state="qux"} 0

You could instead have a single timeseries with different numeric values for each enum choice - and some tools like Grafana support mapping of those values to text labels - but it's generally less convenient.

Prometheus can generate alerts from alerting rules, which are basically PromQL expressions which are evaluated at repeated intervals and raise an alert if a non-empty set of timeseries is returned.  These are delivered to a separate AlertManager component which groups and delivers alerts.

Jeivardan

unread,
Sep 4, 2020, 7:48:13 AM9/4/20
to Prometheus Users
Thank you for your responses.

Regards,
Jeivardan V

Jeivardan

unread,
Sep 16, 2020, 11:46:21 PM9/16/20
to Prometheus Users
Hi all,

I have another doubt. In my system I to record every state change of a variable can prometheus support this or promethus only save sample data?

Regards,
Jeivardan

Jeivardan

unread,
Sep 16, 2020, 11:46:49 PM9/16/20
to Prometheus Users
*I wish to

Brian Candler

unread,
Sep 17, 2020, 2:57:55 AM9/17/20
to Prometheus Users
On Thursday, 17 September 2020 04:46:21 UTC+1, Jeivardan wrote:
In my system I to record every state change of a variable can prometheus support this or promethus only save sample data?


Prometheus samples data periodically - this is called "scraping".  You can configure the scrape interval, but you can only provide one data point per timeseries per scrape.

This is fundamental to prometheus' design.  Prometheus contains a timeseries database (TSDB), but you don't have direct write access to that TSDB.

There are other TSDB's that do let you write ("push") arbitrary data.  Examples include TimescaleDB, InfluxDB, VictoriaMetrics.
Reply all
Reply to author
Forward
0 new messages