Prometheus and Grafana dashboards - Arquisoft/radarin_en2b GitHub Wiki

Prometheus

Prometheus is an event-handler and monitoring software. It is based on time-series data, it is capable of creating events and alerting a console of centralized management. Software is installed in each of the nodes so it is reliable and independent. You can also make queries on these nodes. The usual thing is to present all the monitoring information on a solution called Grafana.

After saying this, we will talk about Prometheus and all its features.

First, you want to be able to extract metrics from your systems. You can do it in very different ways:

  • By ‘instrumenting‘ your application, meaning that your application will expose Prometheus compatible metrics on a given URL. Prometheus will define it as a target and scrap it on a given period.

  • By using of the prebuilt exporters : Prometheus has an entire collection of exporters for existing technologies. You can for example find prebuilt exporters for Linux machine monitoring (node exporter), for very established databases (SQL exporter or MongoDB exporter) and even for HTTP load balancers (such as the HAProxy exporter).

  • By using the Pushgateway : sometimes you have applications or jobs that do not expose metrics directly. Those applications are either not designed for it (such as batch jobs for example), or you may have made the choice not to expose those metrics directly via your app.

Difference with other time-series databases

Prometheus is different from other time series databases, it actively screens targets in order to retrieve metrics from them (other systems are based on push). This has one advantage, centralized control: if Prometheus initiates queries to its targets, your whole configuration is done on Prometheus server side and not on your individual targets. Prometheus is the one deciding who to scrap and how often you should scrap them.

Prometheus monitoring concepts

A. Prometheus data model

Prometheus works with key value pairs. The key describes what you are measuring while the value stores the actual measurement value, as a number. The key in this case is called a metric. It could be for example a CPU rate or a memory usage. Labels are designed to provide more details to your metrics by appending additional fields to it.

B. Metric types

When monitoring a metric, there are essentially four ways you can describe it with Prometheus:

  • Counter. It counts the elements over time. For example it can be used to count the number of HTTP requests.
  • Gauges. They are designed to handle values that may decrease over time. They act like a thermostat.
  • Histogram. It is a more complex metric type. With it you can compute averages or compute fractional measurements on your data.
  • Summaries. Summaries are an extension of histograms.

C. Jobs & Instances

Using Prometheus as a language, a single webserver unit is called an instance. A job is for example the action of counting the number of HTTP requests of all of your instances.

D. PromQL.

Prometheus also has its own embedded language that facilitates querying and retrieving data from your Prometheus servers :

E. Instrumentation.

Before retrieving data from your applications, you want to instrument them. Instrumentation in Prometheus terms means adding client libraries to your application in order for them to expose metrics to Prometheus. In our case, this will be done with Node.js via a third party client library.

F. Exporters

For ‘well-known’ applications, servers or databases, Prometheus built with vendors exporters that you can use in order to monitor your targets.

Examples of exporters include :

  • Database exporters : for MongoDB databases, SQL servers, and MySQL servers.
  • HTTP exporters : for HAProxy, Apache or NGINX servers.
  • Unix exporters : you can monitor system performance using built node exporters that exposes complete system metrics out of the box.

Grafana

Grafana is an analysis platform for metrics, which allows you to alert, visualize and understand data no matter where it is stored. It is very flexible and easy to use. It provides you with many different charts and alerts for the web when connected to supported data sources like Prometheus.

How to connect Prometheus and Grafana dashboards

There are different ways to connect Prometheus and Grafana, here are some of these links which are easy to understand: