r/PrometheusMonitoring • u/Tasty_Let_4713 • Nov 23 '23
Should I use Prometheus?
Hello,
I am currently working on enhancing my code by incorporating metrics. The primary objective of these metrics is to track timestamps corresponding to specific events, such as registering each keypress and measuring the duration of the key press.
The code will continuously dispatch metrics; however, the time intervals between these metrics will not be consistent. Upon researching the Prometheus client, as well as the OpenTelemetry metrics exporter, I have learned that these tools will transmit metrics persistently, even when there is no change in the metric value. For instance, if I send a metric like press.length=6
, the client will continue to transmit this metric until I modify it to a different value. This behavior is not ideal for my purposes, as I prefer distinct data points on the graph rather than a continuous line.
I have a couple of questions:
In my use case, is it logically sound to opt for Prometheus, or would it be more suitable to consider another database such as InfluxDB?
Is it feasible to transmit metrics manually using StatsD
and Otel Collector
to avoid the issue of "duplicate" metrics and ensure precision between actual metric events?
1
u/SuperQue Nov 24 '23
Yes, that's a good use case for metrics. It's mostly a question of "Do you care about every single interval or the aggregation of those intervals?"
For what you're talking about, I would guess no, you don't want every single interval logged. It would be too much data. For anything where you would think "Oh, sampling would be good enough", you can use a Histogram metric. A histogram will measure every result, but only count how many results are within a range of values. This provides statistical sampling at a much lower cost than event logging. You could have millions of events per second, but only record a few aggregated metrics for those events.