Eine Reise ins Monitoring mit Prometheus Markus Bente Michael Mühlbeyer @trivadis news.trivadis.com/blog
Markus Bente Data Analytics Plattform Architekturen Streaming Architekturen Open Source Infrastructure Data Analytics & Streaming Security @trivadis news.trivadis.com/blog
Michael Mühlbeyer bei Trivadis seit 2012 Oracle und PostgreSQL Datenbank Architekturen Oracle DB High Availability Oracle Engineered Systems Big Data und Streaming Architekturen @muehlbeyer news.trivadis.com/blog
Agenda Prometheus Architektur Prometheus & Docker Prometheus & Grafana Prometheus in der Praxis Apache Kafka Oracle DB
Architektur
Architektur - Geschichte Open-Source Monitoring und Alerting Tool Seit 2012 von Soundcloud entwickelt Produktives Monitoring ab 2013 Seit 2016 als Projekt in der Cloud Native Computing Foundation Version 1.0 Version 2.0 in 2017 Aktuelles Stable Release v2.13.0
Architektur Features Pull Architektur Metriken werden von Services gepullt Push-Gateway wenn Pull nicht möglich Multi-dimensionales Datenmodell TimeSeries Metrik-Namen und Key/Value Paare PromQL Flexible Query Sprache
Architektur Components Prometheus Server Sammler um Metrik Daten zu sammeln (scraping) Time Series DB (TSDB) um die Daten zu speichern API für die Abfrage Alertmanager Alerting Engine Exporter Für verschiedene Services wie HAProxy, Graphite, MongoDB,... Pushgateway Push von Metriken zum Prometheus Server
Architektur Components Quelle:https://prometheus.io/docs/introduction/overview/
Architektur Prometheus pull via http pull via http pull via http Metriken in TSDB
Architektur Alertmanager Alertmanager verwaltet die Alarme der Clients Prometheus Server Gruppierung der Alarme De-Duplizierung der Alarme Routing der Alarme Mail Teams Slack... Datacenter1 Alerts Slack Alertmanger Benachrichtigungen E-Mail SMS
Architektur Exporter Viele Libraries und Server für das exportieren verschiedener Metriken nach Prometheus verfügbar Einige Exporter werden beim offiziellen Prometheus GIT Repo verwaltet Andere werden extern gepflegt https://prometheus.io/docs/instrumenting/exporters/ Blackbox Exporter verfügbar Endpoint Monitoring HTTP, HTTPS, DNS,... MongoDB Exporter Metrik pull Verbindet an
Architektur Metriken MongoDB Exporter Python App Batch job Cpu_usage:123 Memory_usage:47 Clients_connected:500 Metrik pull Metrik pull Pushgateway Metrik Cache Metrik push
Architektur Installation Binaries beim Projekt https://prometheus.io/download/ Build von Source https://github.com/prometheus/ Docker https://quay.io/repository/prometheus/prometheus https://hub.docker.com/r/prom/prometheus/
Prometheus & Docker
Prometheus & Docker Schnelle und einfache Monitoring Lösung mit Docker Out of the box Monitoring aller HTTP Services in kurzer Zeit https://github.com/mmuehlbeyer/prometheus Auch mit Cloud Container Services möglich (z.b. AWS ECS) Cloud Spezialitäten beachten Integration in Jenkins hilfreich Deploy mit einem Klick
Prometheus & Docker Beispiel #docker-compose.yml version: '3.1' networks: monitor-net: driver: bridge services: prometheus: build: context:. dockerfile: prometheus restart: unless-stopped expose: - 9090 networks: - monitor-net ports: - "9090:9090" alertmanager: build: context:. dockerfile: alert_manager restart: unless-stopped expose: - 9093 ports: - "9093:9093" networks: - monitor-net blackboxexporter: build: context:. dockerfile: blackbox_exporter expose: - 9115 networks: - monitor-net
Prometheus & Docker Beispiel #prometheus.yml global: scrape_interval: 10s evaluation_interval: 10s rule_files: - alert.rules.yml alerting: alertmanagers: - static_configs: - targets: - alertmanager:9093 scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'blackbox' metrics_path: /probe params: module: [http_2xx] static_configs: - targets: - https://google.de relabel_configs: - source_labels: [ address ] target_label: param_target - source_labels: [ param_target] target_label: instance - target_label: address replacement: blackbox:9115 # The blackbox exporter's real hostname:port.
Prometheus & Docker Beispiel #alertmanager.yml global: smtp_smarthost: 'yoursmtp.yourdomain:25' smtp_from: 'info@yourdomain' smtp_require_tls: true smtp_auth_username: 'xxx' smtp_auth_password: 'zzz' receivers: - name: 'mymon' email_configs: - to: 'monitor@byom.de' html: null text: '{{ template "email.mail.text". }}' templates: - '/etc/alertmanager/mail.tmpl' route: group_by: [job, instance] group_wait: 10s group_interval: 10s receiver: 'mymon'
Prometheus & Docker Beispiel #blackbox config modules: http_2xx: prober: http timeout: 5s http: valid_status_codes: [] method: GET preferred_ip_protocol: "ipv4" tls_config: insecure_skip_verify: true no_follow_redirects: true
Prometheus & Grafana
Prometheus & Grafana Visualisung von Metriken Verschiedene Graphen zur Darstellung Alerting Möglichkeit Threshold Visualisierung Dynamische Dashboards
Prometheus & Grafana "targets": [ { "expr": "jvm_memory_bytes_max{instance='$instance:9095'}", "format": "time_series", "intervalfactor": 1, "legendformat": "max {{area}}", "refid": "A" }, { "expr": "jvm_memory_bytes_used{instance='$instance:9095'}", "format": "time_series", "intervalfactor": 1, "legendformat": "used {{area}}", "refid": "B" } ],
Prometheus & Grafana "templating": { "list": [ { "allvalue": null, "current": { "text": "Bk_Zk_1", "value": [ "10.0.2.15" ] }, "hide": 0, "includeall": false, "label": null, "multi": false, "name": "instance", "options": [ { "selected": false, "text": "Bk_Zk_1", "value": "10.0.2.15" } ], "query": "10.0.2.15", "skipurlsync": false, "type": "custom"
Prometheus & Grafana
Prometheus & Grafana
Prometheus & Grafana
Prometheus in der Praxis
Prometheus in der Praxis Apache Kafka Prometheus Kafka JMX Exporter Kafka Broker Blackbox Exporter Zookeeper JMX Exporter Kafka Zookeeper Grafana Kafka Mirror Maker Mirror Maker JMX Exporter Replication Monitoring
Prometheus in der Praxis Apache Kafka JMX Exporter für Java Prozesse Javaagend implementation Aufbereitung der Mbeans in Prometheus lesbare Metriken Möglichkeit zur einschränkung der Mbeans publizierten Environment=KAFKA_OPTS=-javaagent:/apps/jmx_prometheus_javaagent- 0.11.0.jar=9098:/apps/jmx_config_zookeeper.yml
Prometheus in der Praxis Apache Kafka lowercaseoutputname: true rules: - pattern: java.lang<type=(garbagecollector), name=(.+)><lastgcinfo>duration name: java_zookeeper_$1_duration labels: GCType: "$2" - pattern: "org.apache.zookeeperservice<name0=replicatedserver_id(\\d+), name1= replica.(\\d+), name2=(\\w+)><>(\\w+)" name: "zookeeper_$4" labels: replicaid: "$2" membertype: "$3"
Prometheus in der Praxis Apache Kafka Replication Monitoring Custom Docker Container Basierent auf dem Node Exporter Textfile Reader Exponiert Consumer Gruppen Lag Benötigte Komponenten für den Custom Docker Container Node Exporter Kafka Binaries Java
DEMO
Prometheus in der Praxis Oracle Oracle Exporter Custom Metric Support Dockerisiert [[metric]] context = "version" labels = [ "oracle" ] metricsdesc = { value= "Guage metric with Oracle Release number" } request = "SELECT 'Oracle' as oracle, substr(version_full, 1,2) '.' substr(version_full, 4,1) as value FROM v$instance"
Prometheus in der Praxis Oracle
Prometheus in der Praxis Oracle
DEMO
Visit us at our booth on level 3 Trivadis barista (good coffee from morning to night) Birthday cake (daily from 15:00) Speed-Sessions at the booth with raffle: Di 14:45: Martin Berger "Oracle Cloud Free Tier eben mal kurz ausprobiert " Mi 10:45: Guido Schmutz "Warum ich Apache Kafka als IT-Spezialist kennen sollte!" Mi 14:45: Stefan Oehrli "PDB Sicherheit und Isolation, Herausforderungen von Oracle Container DB s" Do 10:45: Chris Antognini "Welche Query-Optimizer Funktionalitäten sind nur in Autonomous Database verfügbar? Participation in our DOAG raffle Networking and discussions with our speakers Party with drinks and snacks after the sessions on Tuesday 17:30