11. Что же выбрать?
➔ С кодом удобнее работать. Особенно, если ты не один
➔ Push очень мощный!
➔ Pull модель, внезапно, очень хороша для микросервисов
➔ Active как-то не прижился, все боятся restart loop.
◆ А restart в кластере может плохо кончится
13. Capture. Снятие метрик
➔ Statsd
➔ Collectd
➔ Prometheus Exporters
➔ Influxdb Telegraf
➔ Elastic Beats
★ Nodejs / no Windows
★ C / SSC Serv for Windows
★ Go
★ Go
★ Go
14. Store. База данных
➔ Elasticsearch
➔ Graphite
➔ Prometheus
➔ InfluxDB
➔ OpenTSDB
22. Внезапно
➔ Метрики -- одна из важнейших частей feedback loop
◆ Аналитика -- часть мониторинга
➔ Гипотеза, реализация, проверка, гипотеза
➔ Инфраструктура и код неразделимы
23. Проблемы
➔ Мониторинг -- blackbox для разработчиков
◆ Read Only модель
➔ Сенсоры пишут Ops
◆ Ops не знают код, dev не знают инфраструктуру
33. Prometheus Alertmanager Rules
alert.rules: |-
ALERT HighCPU
IF ((sum(node_cpu{mode=~"user|nice|system|irq|softirq|steal|idle|iowait"}) by (instance, job))
- ( sum(node_cpu{mode=~"idle|iowait"}) by (instance,job) ) )
/ (sum(node_cpu{mode=~"user|nice|system|irq|softirq|steal|idle|iowait"}) by (instance, job)) * 100 > 95
FOR 10m
LABELS { service = "backend" }
ANNOTATIONS {
summary = "High CPU Usage",
description = "This machine has really high CPU usage for over 10m",
}
35. Bosun Alert Rule
alert cpu.linux {
template = generic
$notes = "High CPU load on server for last 30 minutes."
$series = 100 - graphite("groupByNode(servers.*.cpu.*.percent.idle, 1, 'avg')", "30m", "", "host")
$q = avg($series)
warn = $q >= 90
crit = $q >= 95
macro = common
warnNotification = $warnNotification
critNotification = $critNotification
}
36. Bosun Alert Global
macro common {
$warnNotification = slack
$critNotification = slack
$kibanaDomainName = kibana.mycompany.com
$grafanaDomainName = grafana.mycompany.com
}
notification slack {
post = https://hooks.slack.com/services/xxxxxxx
body = payload={"username": "bosun", "text": {{.|json}}, "attachments":[{"fallback": "Prod","color":
"#69B","title": "Prod env"}] }
next = slack
timeout = 4h
}
37. Storage as a Service
➔ Storage на dev, stage, prod
◆ https://github.com/vegasbrianc/prometheus
◆ https://github.com/hopsoft/docker-graphite-statsd
◆ https://github.com/sstarcher/docker-sensu
38. Заключение
➔ Мониторинг -- это непрерывный процесс
➔ Read/Write модель для разработчиков
➔ DevOps предоставляет сервис, а не сенсоры