1
1
Fork 0

Add observability chapter

This commit is contained in:
Gleb Goncharov 2023-02-26 17:13:50 +04:00
parent ec1523d970
commit a34067cbda
6 changed files with 2149 additions and 2788 deletions

View File

@ -135,4 +135,4 @@ docker-compose --profile app stop consumer-1
Как можно заметить, теперь партиции распределились между двумя консумерами: по три на каждого участника группы.
✅ Готово. Теперь переходите к [изучению метрик Kafka]().
✅ Готово. Теперь переходите к [изучению метрик Kafka](./006-observability.md).

View File

@ -1 +1,32 @@
# Наблюдаемость Kafka
# Наблюдаемость Kafka
Пока мы экспериментировали с консумерами и продюсерами, Prometheus-сервер собирал метрики с Kafka-брокеров. Давайте уделим время последней, но не по важности, теме наблюдаемости Kafka.
Откройте [Grafana-дашборд "Kafka: Producers & Consumers"](http://localhost:3000/d/kafka-consumers-and-producers).
- **Имя пользователя**: `admin`
- **Пароль**: `admin`
Kafka представляет широкие возможности для снятия телеметрии с JMX. В экосистеме Prometheus для снятия метрик мы используем JMX Exporter с описанием правил сбора метрик MBeans. В других системах мониторинга вы можете использовать другие инструменты.
![Grafana: Producers & Consumers](./assets/006-grafana-kafka-producers-and-consumers.png)
Откройте [Grafana-дашборд "Kafka: Performance"](http://localhost:3000/d/kafka-performance) и оцените изменение ключевых метрик.
> Для развёртки продуктивного кластера советуем ознакомиться с [рекомендациями Confluent по сбору метрик](https://docs.confluent.io/platform/current/kafka/monitoring.html). В примере используем только часть метрик, чтобы не переусложнять понимание основных процессов.
---
✅ Готово. Поздравляю, вы завершили базовый курс знакомства с Kafka.
Для остановки стенда используйте команду:
```bash
docker-compose --profile app down
```
🎉 Спасибо, что приняли участие в интенсиве «Kafka за 90 минут»!
---
[Вернуться на главную](../../README.md)

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,557 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"description": "",
"editable": true,
"fiscalYearStartMonth": 0,
"gnetId": 7589,
"graphTooltip": 1,
"links": [
{
"asDropdown": false,
"icon": "external link",
"includeVars": false,
"keepTime": false,
"tags": [
"Apache Kafka"
],
"targetBlank": false,
"title": "Dashboards",
"tooltip": "",
"type": "dashboards",
"url": ""
}
],
"liveNow": false,
"panels": [
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"id": 21,
"panels": [],
"title": "Overview",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 12,
"x": 0,
"y": 1
},
"id": 19,
"interval": "1m",
"links": [],
"options": {
"legend": {
"calcs": [
"lastNotNull",
"max"
],
"displayMode": "table",
"placement": "right",
"showLegend": true,
"width": 480
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "9.0.3",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum(delta(kafka_topic_partition_current_offset{instance=~'$instance',topic=~\"$topic\"}[$__rate_interval])) by (topic, partition) >= 0",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{topic}}#{{partition}}",
"range": true,
"refId": "A"
}
],
"title": "Produced messages rate",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 12,
"x": 12,
"y": 1
},
"id": 18,
"interval": "1m",
"links": [],
"options": {
"legend": {
"calcs": [
"lastNotNull",
"max"
],
"displayMode": "table",
"placement": "right",
"showLegend": true,
"width": 480
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "9.0.3",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum(delta(kafka_consumergroup_current_offset{instance=~'$instance',topic=~\"$topic\",consumergroup=~\"$consumergroup\"}[$__rate_interval])) by (consumergroup, topic, partition) >= 0",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{topic}}#{{partition}} ({{consumergroup}})",
"range": true,
"refId": "A"
}
],
"title": "Consumed messages rate",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 11,
"w": 24,
"x": 0,
"y": 11
},
"id": 12,
"links": [],
"options": {
"legend": {
"calcs": [
"lastNotNull",
"max"
],
"displayMode": "table",
"placement": "right",
"showLegend": true,
"width": 480
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"pluginVersion": "9.0.3",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum(kafka_consumergroup_lag{instance=\"$instance\",topic=~\"$topic\",consumergroup=~\"$consumergroup\"}) by (consumergroup, topic, partition) ",
"format": "time_series",
"instant": false,
"interval": "",
"intervalFactor": 1,
"legendFormat": "{{ topic }}#{{ partition}} ({{consumergroup}})",
"refId": "A"
}
],
"title": "Consumer group lag",
"type": "timeseries"
}
],
"refresh": false,
"schemaVersion": 37,
"style": "dark",
"tags": [
"Apache Kafka"
],
"templating": {
"list": [
{
"current": {
"selected": false,
"text": "Prometheus",
"value": "Prometheus"
},
"hide": 0,
"includeAll": false,
"label": "Datasource",
"multi": false,
"name": "datasource",
"options": [],
"query": "prometheus",
"queryValue": "",
"refresh": 1,
"regex": "/Prometheus/",
"skipUrlSync": false,
"type": "datasource"
},
{
"current": {
"selected": false,
"text": "kafka-exporter",
"value": "kafka-exporter"
},
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"definition": "label_values(kafka_consumergroup_current_offset, job)",
"hide": 2,
"includeAll": false,
"label": "Job",
"multi": false,
"name": "job",
"options": [],
"query": {
"query": "label_values(kafka_consumergroup_current_offset, job)",
"refId": "StandardVariableQuery"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
"current": {
"selected": false,
"text": "kafka-exporter:9308",
"value": "kafka-exporter:9308"
},
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"definition": "label_values(kafka_consumergroup_current_offset{job=~\"$job\"}, instance)",
"hide": 2,
"includeAll": false,
"label": "Instance",
"multi": false,
"name": "instance",
"options": [],
"query": {
"query": "label_values(kafka_consumergroup_current_offset{job=~\"$job\"}, instance)",
"refId": "StandardVariableQuery"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"definition": "label_values(kafka_topic_partition_current_offset{instance='$instance',topic!='__consumer_offsets',topic!='--kafka'}, topic)",
"hide": 0,
"includeAll": true,
"label": "Topic",
"multi": true,
"name": "topic",
"options": [],
"query": {
"query": "label_values(kafka_topic_partition_current_offset{instance='$instance',topic!='__consumer_offsets',topic!='--kafka'}, topic)",
"refId": "StandardVariableQuery"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 1,
"tagValuesQuery": "",
"type": "query",
"useTags": false
},
{
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"definition": "label_values(kafka_consumergroup_lag{instance='$instance',topic!='__consumer_offsets',topic!='--kafka',topic=~\"$topic\"}, consumergroup)",
"hide": 0,
"includeAll": true,
"label": "Consumer group",
"multi": true,
"name": "consumergroup",
"options": [],
"query": {
"query": "label_values(kafka_consumergroup_lag{instance='$instance',topic!='__consumer_offsets',topic!='--kafka',topic=~\"$topic\"}, consumergroup)",
"refId": "StandardVariableQuery"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 1,
"tagValuesQuery": "",
"type": "query",
"useTags": false
}
]
},
"time": {
"from": "now-30m",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "Europe/Moscow",
"title": "Kafka: Producers & Consumers",
"uid": "kafka-consumers-and-producers",
"version": 1,
"weekStart": ""
}