Prometheus vs. InfluxDB: A Monitoring Comparison

Prometheus vs. InfluxDB for monitoring metrics

Monitoring has been around since the dawn of computing. Recently, however, there’s been a revolution in this field. Cloud native monitoring has introduced new challenges to an old task, rendering former solutions unsuitable for the job. When working with cloud native solutions such as Kubernetes, resources are volatile. Services come and go by design, and that’s fine—as long as the whole system operates in a regular way. Classical monitoring solutions aren’t always able to handle this transience gracefully. This post will pit Prometheus vs. InfluxDB to compare two modern monitoring solutions, examining their similarities and differences, and identify their best use cases.

Prometheus vs. InfluxDB: An Overview

Prometheus is a database optimized for time series data and an ideal way to store monitoring metrics. Prometheus graduated from the Cloud Native Computing Foundation (CNCF), which means it has great integration with other CNCF components. It features built-in service discovery, making it easy to use in highly dynamic environments. Unlike traditional monitoring tools, Prometheus uses a pull model which allows it to scale better. To access data, Prometheus offers a flexible query language called PromQL.

InfluxDB is a time series database designed for fast, high-availability storage and retrieval of time series data. It can work as a stand-alone solution, or it can be used to process data from Graphite. In addition to monitoring, InfluxDB can be used for the Internet of Things, sensor data, and home automation solutions. Just like Prometheus, it features its own query language inspired by SQL. Even though the database itself is an open-source project, it implements closed-source components to allow clustering. For a more detailed comparison of Prometheus and Graphite, check out this article.

A High-Level Comparison: Prometheus vs. InfluxDB

FeaturePrometheusInfluxDB
What it isFully integrated time series DBMS and monitoring systemTime series database
What it doesScraping, storing, querying, graphing, and alerting based on time series data; provides API endpoints for the data it holdsStores numeric time series data
Implemented inGoGo
Data types handledNumericNumeric
Year released20122013
Websiteprometheus.iohttps://github.com/influxdata/influxdb
Technical documentationprometheus.io/docshttps://v2.docs.influxdata.com/v2.0/
APIs and access methodsRESTful HTTP and JSONHTTP, TCP, and UDP API
XML support?Yes (can be imported)No
Server operating systemsLinux, WindowsLinux, macOS
Supported programming languages.NET, C++, Go, Haskell, Java, JavaScript (Node.js), Python, RubyC++, Erlang, Elixir, Go, Haskell, Java, JavaScript, LISP, MATLAB, .Net, Perl, PHP, Python, R, Ruby, Rust, Scala
Partitioning supported?Yes, shardingYes, sharding
Replication supported?Yes, by federationYes, several methods possible
Data collectionActive or pull (configurable)Push or pull

Features

Data Collection

InfluxDB is a push-based system. It requires an application to actively push data into InfluxDB.

Prometheus is a pull-based system. An application publishes the metrics at a given endpoint, and Prometheus fetches them periodically.

Storage

InfluxDB is much more suitable for event logging. Prometheus is focused on metrics recording.

Visualization and Dashboards

Both Prometheus and InfluxDB feature basic visualizations and dashboards. To truly shine, they should be deployed alongside dedicated visualization and dashboard solutions, such as Grafana or Chronograf.

Plug-in Architecture and Extensibility

The main advantage of Prometheus is its huge community support, which is based on its CNCF graduated project status. Many applications, especially cloud native ones, already offer Prometheus support out of the box.

While InfluxDB also features many integrations, it is not as ‘well-connected’ as Prometheus.

Community

Prometheus and InfluxDB are both open-source, and both are well maintained by active developer communities. As of January 2020, Prometheus’ primary GitHub repo has been forked over 4,600 times, compared to InfluxDB’s 2,600 forks.

Use Cases

Prometheus was built with monitoring in mind—especially distributed, cloud native monitoring. It excels in this category, featuring lots of useful integrations with other existing products.

While InfluxDB can also handle monitoring, it’s not as popular as Prometheus for accomplishing this task. As a result, you may be required to write your own integrations. However, if you are interested in more than just monitoring, InfluxDB is also a great option for storing time series data, such as data coming from sensor networks or data used in real-time analytics (e.g., financial data or Twitter stats).

Visualization with Grafana

When it comes to monitoring and querying, Prometheus is a powerful tool. When it comes to UI, it has its drawbacks. Because of this, most people use Grafana with Prometheus most of the time. Since Grafana has a pluggable data source model, it can be used with both Prometheus and InfluxDB. Let’s look at how to configure both.

Configuring Grafana with Prometheus

For a detailed, step-by-step article on how to set up and configure Prometheus and Grafana, please refer to our tutorial, Prometheus Monitoring with Grafana. For a quick and easy example that illustrates the power of these two tools in combination, we’ll use a preconfigured component. Assuming you have access to a Kubernetes cluster, you’ll want to access the Prometheus operator Helm chart.

To use the Helm chart, you first need to install it. Depending on the operating system, you can use brew install helm (for macOS and Linux) or choco install kubernetes-helm (for Windows). After that, you can run a few Helm commands to install the Prometheus Operator:

helm repo add stable https://kubernetes-charts.storage.googleapis.com/
helm install stable/prometheus-operator --name po

After a while, your Prometheus Operator should be running. You can verify that by calling kubectl get pods and checking to see that they are all in the running state. Then, access Grafana by calling:

kubectl port-forward $(kubectl get pods -l "app=grafana,release=po" -o jsonpath="{.items[0].metadata.name}") 3000:3000

Now, you should be able to access Grafana at http://localhost:3000. The login to access the panel is admin, and the default password is prom-operator.

In the Grafana panel, you can either explore the preconfigured dashboards or create your own. The screenshot below provides an example of a preconfigured dashboard showing cluster health:

Grafana dashboard for Prometheus

Grafana dashboard for Prometheus

Configuring Grafana with InfluxDB

Here is a short InfluxDB-Grafana tutorial. There isn’t a ready-made, all-in-one Helm chart for InfluxDB with Grafana, so, for this process, you will need to do more work. We’ll use Helm to simplify the installation—as we did with Prometheus—installing charts for Grafana and InfluxDB separately:

helm repo add stable https://kubernetes-charts.storage.googleapis.com/
helm install stable/influxdb --name influxdb
helm install stable/grafana --name grafana

To access Grafana, use admin-user and the password admin-password. Forward the application’s port with:

kubectl port-forward $(kubectl get pods -l "app=grafana,release=grafana" -o jsonpath="{.items[0].metadata.name}") 3000:3000

Since we want our data pumped into InfluxDB, we will also modify Heapster to feed our InfluxDB instance. To do this, we need to open an editor with Heapster deployment using:

kubectl edit deployment heapster -n kube-system

Inside the editor, search for the spec.containers.command section and add as the last line of the command:

--sink=influxdb:http://influxdb-influxdb.default:8086

Then, go to the Grafana dashboard and add the InfluxDB data source, pointing to http://influxdb-influxdb.default:8086 and selecting “k8s” as a database. This article will give you some dashboard configuration inspiration. 

The screenshot below illustrates an example of a CPU metrics dashboard:

CPU metrics Grafana dashboard for InfluxDB

CPU metrics Grafana dashboard for InfluxDB

Summary

Both of these products are excellent time series databases. They differ in their default mode (push for InfluxDB, pull for Prometheus). Some people argue that PromQL, Prometheus’ language, is simpler than the language used by InfluxDB, but, all in all, the decision to use one tool or the other will probably depend on your use case. If monitoring is what you’re most interested in, Prometheus is your safest bet because of its many integrations and scalable model. If you’re more likely to be using a time series database for IoT, sensors, or analytics, then you’ll probably want to choose InfluxDB.

Artboard Created with Sketch.

External