Monitoring Petals ESB with Prometheus

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (5)

View Page History
h2. Prometheus API

Prometheus server is reachable through its [HTTP API|https://prometheus.io/docs/prometheus/latest/querying/api]. It allows to directly query metrics and can be useful in specific cases.

For instance, by requesting */api/v1/targets* you can get an overview of configured targets and their health in json format.
response: [^prometheus_get-api-targets.json].

However there is a web UI already build in Prometheus server and there are open sources solution natively compatible with this API (like [Grafana|https://grafana.com]).
However there are simpler solutions, as a web UI already build in Prometheus server or open sources softwares natively compatible with this API (like [Grafana|https://grafana.com]).

h2. Prometheus web UI

This UI is accessible connecting to prometheus server */graph*, in our example:
{code}http://localhost:9090/graph{code}

This web UI allows you to enter any expression and see its result either in a table or graphed over time. This is primarily useful for ad-hoc queries and debugging.
But you can also view various prometheus server configuration (targets, rules, alerts, services discovery, etc...).

h2. Grafana

h3. Installing

[Grafana|http://grafana.com/] installation is documented on [Grafana website|http://docs.grafana.org/installation/] and setup for prometheus is documented on [Prometheus website|https://prometheus.io/docs/visualization/grafana/]. It is advised to rely on these sources for an up to date installation.

* In short, install and run as standalone:
{code}
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.4.linux-amd64.tar.gz
tar -zxvf grafana-5.2.4.linux-amd64.tar.gz
cd grafana-5.2.4
./bin/grafana-server web
{code}

* Or as package:
Add the following line to your */etc/apt/sources.list* file (even if you are on Ubuntu or another Debian version).
{code}
deb https://packagecloud.io/grafana/stable/debian/ stretch main
{code}
Then run:
{code}
curl https://packagecloud.io/gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install grafana
sudo service grafana-server start
{code}

By default, Grafana web UI is available at *localhost:3000*, the default user is *admin/admin*.

h3. Connecting to Prometheus

For an exhaustive documentation go to [Grafana website|http://docs.grafana.org/features/datasources/prometheus/]

In short, once logged as admin:
# Open the side menu by clicking the Grafana icon in the top header.
# In the side menu under the Dashboards link you should find a link named Data Sources.
# Click the + Add data source button in the top header.
# Select _Prometheus_ from the Type dropdown.
# Give a name to the data source
# Set the URL of prometheus server, in our example the default : localhost:9090
# Clic _Save & Test_

*Note:* Grafana data sources can also be [configured by files|http://docs.grafana.org/administration/provisioning/#datasources]