Technology

Four Types of Prometheus Metrics

The world of tech runs on metrics. We use them to see how successful our marketing is, how productive we or our systems are, our performance over time, and more. When it comes specifically to the monitor or software, engineers have used metrics for much longer than the average person. As software and hardware improve over the years, the systems become more complex. One of the most popular open-source monitoring software is Prometheus – a CNCF project.

Four types of Prometheus metrics are collected (although the topic deserves a deep dive): 

Summaries 

Summaries are useful for measuring the response size and request durations. Summaries offer an accurate account of quantiles (more accurate than histograms), but there are a couple of drawbacks to be aware of:

  •  Aggregating summaries across multiple series is impossible- rendering them useless for most use cases in a dynamic modern system. 
  • The quantiles you desire need to be predefined by the client – meaning that nothing can be calculated unless a metric is already provided. The new addition of quantiles will require code modification. 
  • Computation of quantiles is costly for the client and often better avoided. 

Histograms 

A histogram will divide the whole range of measurements into buckets, giving you the total measurement for each of those intervals. Histograms can be used to present the averages across a series and percentiles at query time. The most significant benefit of using histograms is aggregation. 

The cons of histograms are:

  • Percentiles are calculated server-side, which can be costly (with rising costs) the more data is processed. 
  • Approximation in percentiles rather than accurate ones (you’ll need buckets that offer reasonable accuracy). 
  • The buckets will need some design and pre-definition to compute the percentiles. 

Gauges 

Metrics with arbitrary increases or decreases are called gauge metrics, as the actual value is useful even without additional processing. Gauges include, for instance, measurements of temperature, CPU, memory, or queue size.

Counters 

Any measurement that can increase and only increase a counter metric will be used. Since they are always cumulative, the value can only go up. If there was an exception to the rule (and there usually is), it could be when the counter is restarted and back at zero. 

Quite often, when it comes to metrics, the single value of the counter isn’t helpful on its own, so it will be used in combination with other metrics. One of the most common uses for a counter is API call measurement (a number that will always increase). 

Other places where a counter metric would be ideal are, in the case of a website, counting the number of sales or, for example, website visitors. Both of these figures can only increase. 

The metric you choose will depend on the type of data you need and the desired accuracy. For example, if percentiles are not needed, then Summaries may have the most use; for single figures that increase, Counters are the obvious choice. 

Although there are plenty of other ways to create systems to measure metrics and deliver those numbers, coding and code language are becoming more of a part of every day: Programming Languages: Is Coding the New Literacy? – Muncie Voice.

Show More

Todd Smekens

Journalist, consultant, publisher, and servant-leader with a passion for truth-seeking. Enjoy motorcycling, meditation, and spending quality time with my daughter and rescue hound. Spiritually-centered first and foremost. Lived in multiple states within the USA and frequent traveler to the mountains.

Related Articles

Back to top button