What are Prometheus Functions?

What are Prometheus Functions?

Table of Contents

Banner opt.2.webp



Prometheus is a platform for real-time systems and event monitoring and alerting. The Prometheus project is free, open-source, and available on GitHub. Originally developed at SoundCloud, Prometheus became a project of the Cloud Native Computing Foundation in 2016, alongside other popular frameworks such as Kubernetes. The core of the project is the Prometheus server, which acts as the system’s “brain” by collecting various metrics and storing them in a time-series database.


But once the data is inside the Prometheus database, how can you query this data efficiently to get answers to important business questions? That's where Prometheus functions come in. Below, we'll discuss what Prometheus functions are and the various use cases of Prometheus functions.


If you're interested in monitoring for yourself, sign up for our Hosted Graphite free trial. You can also sign up for a demo and we can talk about the best alternative monitoring solutions for you.



What are Prometheus Functions?

Before we discuss Prometheus functions too deeply, we first need to discuss some basic concepts and terminology.


PromQL is a custom query language for the Prometheus project that is used to filter and search through Prometheus' time series data. When querying in PromQL, every metric has four components:


  • The metric name
  • Labels, i.e. key-value pairs to distinguish metrics with the same name
  • The metric value, a 64-bit floating point number
  • timestamp with millisecond-level precision


The Prometheus expression language has three different data types:


  • A scalar represents a floating point value.
  • An instant vector is a set of time series data with a single scalar for each time series.
  • range vector is a set of time series data with a range of data points over time for each time series.


In addition, there are four different metric types in the Prometheus client libraries:


  • Counter: Useful for increasing values; the counter resets to zero on restart.
  • Gauge: Useful for counts that go up and down, or for rising and falling values.
  • Histogram: Useful for sampling observations (such as response sizes), counting them in buckets for configuration, and providing a sum of the observed values.
  • Summary: Similar to a histogram, this metric type records a total count of observations and a sum of observed values. It processes the information while computing configurable quantities for a sliding window of time.


A Prometheus query using the PromQL query language can return either an instant vector or a range vector, depending on the metric type and the result you are asking for. Now that we've got all that out of the way, let's return to the original question: what are Prometheus functions?


Simply put, Prometheus functions are functions in the PromQL language that can be used to query a Prometheus database. In the next section, we'll go over a few of the most common use cases of Prometheus functions.


If you're interested in using Prometheus, but the setup and management of it would be too resource-consuming, book a demo and talk to us about how Hosted Graphite can fit into your monitoring environment. You can also get right onto a free trial, and check it out now.



What are the Use Cases of Prometheus Functions?

There are as many Prometheus function use cases as there are functions—and even more. Below, we'll demonstrate just a few uses of Prometheus functions.


Aggregation operators

Aggregation operators calculate mathematical values over a time range. You can use Prometheus functions such as the ones below to aggregate over a given range vector:


  • avg_over_time() for the average (mean) value
  • max_over_time() for the maximum value
  • count_over_time() for the total count of all values


Counting HTTP requests

As another example, you can use the increase() Prometheus function to count the number of HTTP requests over the past 5 minutes, e.g.:




Linear regression

Given a range vector and a scalar t, the predict_linear() Prometheus function uses simple linear regression to predict the value of the time series t seconds in the future.


Regular expressions

The label_replace() Prometheus function searches through time series to find one that matches the given regex (regular expression), and then 


Calculating percentiles

Given a histogram, the histogram_quantile() Prometheus function. The highest bucket in the histogram must have an upper bound of +Inf (positive infinity).


Calculating differences

Given a range vector, the delta() Prometheus function calculates the difference between two quantities. For example, to calculate the difference in CPU temperature between now and 2 hours ago:




To enhance your use of Prometheus functions, you can also integrate Prometheus with Grafana, a web application for data analytics and visualization. MetricFire's hosted Grafana service makes it easy for any Prometheus user to enjoy high-quality, informative data visualizations. When you choose MetricFire, you also get access to our Hosted Graphite data source and platform, and 24/7 support for all your Graphite and Grafana needs. Sign up today!



How MetricFire Can Help

MetricFire is a cloud infrastructure and application monitoring platform that makes it simple to understand your data at a glance. We offer a hosted Graphite service that handles issues such as scaling, data storage, and support and maintenance—so that you can spend more time on the metrics and less time on the technical details.


To learn more, check out the Prometheus posts on our blog, or book a demo for a chat about your business needs and objectives. Want to get started with your monitoring right away? The MetricFire free trial is an excellent way to explore what you can do with hosted Graphite.

You might also like other posts...
metricfire Jul 12, 2024 · 8 min read

Monitor Your Active SystemD Services Using Telegraf

Monitoring the state of your services and running processes is crucial for ensuring system... Continue Reading

metricfire Jul 03, 2024 · 9 min read

Monitor Your Socket Connections Using Telegraf and MetricFire

Monitoring socket connections in your servers is critical because it ensures network communication is... Continue Reading

metricfire Jun 26, 2024 · 9 min read

Guide to Monitoring Webhook Performance Using Telegraf

Monitoring your webhook endpoints is essential to maintain operational efficiency and customer satisfaction, as... Continue Reading

header image

We strive for
99.999% uptime

Because our system is your system.

14-day trial 14-day trial
No Credit Card Required No Credit Card Required