Alertmanager
A Prometheus exporter converts application or system metrics into a format that Prometheus can scrape. It acts as an adapter between the monitored service and Prometheus.
Grafana Features
- Visualization: Grafana provides several visualization options that make metrics easier to understand.
- Alerting: Grafana can send alerts through email, Slack, Telegram, and other notification channels.
-
Download the Grafana package and place it under
/etc.bashsudo su wget https://dl.grafana.com/oss/release/grafana-11.2.2.linux-amd64.tar.gz tar -zxvf grafana-v11.2.2.linux-amd64.tar.gz cp grafana-v11.2.2.linux-amd64/etc/grafana -
Configure Prometheus to use Alertmanager in
/etc/prometheusconfig.yml.yamlalerting: alertmanagers: - static_configs: - targets: - IP_ALERT_MANAGER:PORT -
Define the rule file that Prometheus will use for alerting in
etc/prometheus/config.yml.yamlrule_files: - "FILE_RULES.yml" -
Configure Alertmanager's notification destination. This example sends alerts by email. For the full list of supported integrations, see the Prometheus Alertmanager receiver documentation.
yamlglobal: resolve_timeout: 15s route: receiver: email receivers: - name: email email_configs: - to: "email@test.id" from: "email@test.id" smarthost: smtp.gmail.com:587 auth_username: "email@test.id" auth_identity: "email@test.id" auth_password: "TOKEN_EMAIL" send_resolved: True -
Define the rules that trigger Alertmanager notifications. The following example covers a stopped Apache or Nginx web server.
yamlgroups: - name: NAME_RULES rules: - alert: NAME_ALERT expr: METRICS_UNTUK_ALERT for: 1m annotations: summary: "SUMMARY FOR ALERT" description: "DESCRIPTIONS FOR ALERT." -
Create a systemd service so Alertmanager runs in the background.
bashsudo nano /etc/systemd/system/alert_manager.servicebash[Unit] Description=Alert Manager [Service] User=root ExecStart=/etc/alertmanager/alertmanager \ --config.file=/etc/alertmanager/config.yml \ --web.external-url=http://IP_SERVER:9093/ \ --log.level=debug [Install] WantedBy=default.target -
Reload systemd, then start and enable the Alertmanager service.
bashsudo systemctl daemon-reload sudo systemctl start alert_manager.service sudo systemctl enable alert_manager.service sudo systemctl status alert_manager.service