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 (8)

View Page History
h1. Alerting

Alerts Raising alerts and sending notifications can be configured in multiple ways, here we'll briefly cover these two:

* *Prometheus* can push alerts to [*Alertmanager*|https://prometheus.io/docs/alerting/alertmanager/] which can notify through various channels
* *Grafana* can raise alerts and notify through various channels (including alertmanager)

We will provide examples to send email notifications.

h2. Using Prometheus

h3. Configuring rules

Prometheus can parse additional rule files, for this you must specify them in the [prometheus configuration|https://prometheus.io/docs/prometheus/latest/configuration/configuration/] file:
{code}
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
{code}

And then configure [alerts rules|https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/] in this file, for instance :
{code}
groups:
? !prometheus_alert_triggered.png|width=1112!

h3. Collecting in Alertmanager

{quote}
The Alertmanager handles alerts sent by client applications such as the Prometheus server. It takes care of deduplicating, grouping, and routing them to the correct receiver integration such as email, PagerDuty, or OpsGenie. It also takes care of silencing and inhibition of alerts.

\[...\]


Alertmanager supports configuration to create a cluster for high availability. 
{quote}

To allow Prometheus to push alerts to Alertmanager, you must first provide an alertmanager url in Prometheus configuration. For instance, add these lines to prometheus configuration file :

{code}
alerting:
alertmanagers:
- scheme: http
static_configs:
- targets:
- "localhost:9093"
{code}

Then, [download Alertmanager|https://prometheus.io/download/], unzip it, and create an _alertmanager.yml_ configuration file :
{code}
global:
resolve_timeout: 5m

route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: emails
receivers:
- name: emails
email_configs:
- to: administratorpetals@petals.com
from: alertmanager@example.com
smarthost: localhost:25
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']
{code}

Then, launch Alertmanager providing its configuration file :
{code}
./alertmanager --config.file=alertmanager.yml
{code}

Alertmanager is now set up and awaiting alerts from prometheus to notify by email. You can check alerts on its web UI (exposed at [_'http://127.0.0.1:9093/#/alerts'_|http://127.0.0.1:9093/#/alerts] by default):
? !alertmanager_raisedAlert.png!

h2. using Grafana