title: “2. Prometheus installieren”
date: 2016-10-07T13:00:36
slug: 2-prometheus-installieren
wget https://github.com/prometheus/prometheus/releases/download/v1.1.3/prometheus-1.1.3.linux-amd64.tar.gz
tar -xzf prometheus-1.1.3.linux-amd64.tar.gz
cd prometheus-1.1.3.linux-amd64
vi prometheus.yml
global:
scrape\_interval: 15s # By default, scrape targets every 15 seconds.
evaluation\_interval: 15s # Evaluate rules every 15 seconds.
# Attach these extra labels to all timeseries collected by this Prometheus instance.
external\_labels:
monitor: 'codelab-monitor'
rule\_files:
- 'prometheus.rules'
scrape\_configs:
- job\_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
scrape\_interval: 5s
static\_configs:
- targets: ['localhost:9090']
- job\_name: 'node'
# Override the global default and scrape targets from this job every 5 seconds.
scrape\_interval: 1s
static\_configs:
- targets: ['127.0.0.1:9100']
labels:
group: 'localhost'
Diese Konfiguration pollt jede Sekunde die Metrics vom localhost port 9100
Einen Job anlegen (rules Datei):
vi prometheus.rules
job\_service:bandwidth1 = rate(node\_network\_receive\_bytes{device="eth0"}[2s])
Einen Alert anlegen (rules Datei):
# Bandwidth Alert > 1s.
ALERT BandwidthHighAlert
IF rate(node\_network\_receive\_bytes{device="eth0"}[2s])/1024/1024 > 1
FOR 10s
ANNOTATIONS {
summary = "high Network Traffic on {{ $labels.instance }}",
description = "{{ $labels.instance }} has high Network Traffic (current value: {{ $value }}s)",
}
Start Prometheus with AlertManager at localhost Port 9093
./prometheus -config.file=prometheus.yml -alertmanager.url=http://localhost:9093