Обновлена документация под новые аддоны (gitlab, redis, mongodb, kafka, kafka-ui, rabbitmq) и новую модель явного выбора зависимостей. Добавлены и унифицированы описания переключателей *_database_mode и *_redis_mode, обновлена таблица зависимостей аддонов, примеры конфигурации и список vault-секретов.
Prometheus Pushgateway
Промежуточное хранилище метрик для batch-задач, CI/CD, cron-скриптов — всего что не может быть scraped напрямую Prometheus. Устанавливается в namespace monitoring (рядом с Prometheus).
Быстрый старт
# group_vars/all/addons.yml
addon_pushgateway: true
addon_prometheus_stack: true # Prometheus scrapes Pushgateway автоматически
make addon-pushgateway
Параметры
| Переменная | Умолч. | Описание |
|---|---|---|
pushgateway_ingress_enabled |
false |
Ingress (обычно не нужен) |
pushgateway_persistence_enabled |
false |
Сохранять метрики при рестарте |
pushgateway_persistence_size |
2Gi |
PVC если persistence enabled |
Endpoint
http://prometheus-pushgateway.monitoring.svc.cluster.local:9091
Отправить метрику (curl)
# Одна метрика
cat <<EOF | curl --data-binary @- \
http://prometheus-pushgateway.monitoring.svc.cluster.local:9091/metrics/job/my-batch-job
# HELP my_job_duration_seconds Duration of my batch job
# TYPE my_job_duration_seconds gauge
my_job_duration_seconds 42.5
EOF
# С labels
cat <<EOF | curl --data-binary @- \
http://prometheus-pushgateway.monitoring.svc.cluster.local:9091/metrics/job/backup/instance/prod
backup_success 1
backup_size_bytes 1073741824
EOF
Из Python
from prometheus_client import CollectorRegistry, Gauge, push_to_gateway
registry = CollectorRegistry()
g = Gauge('job_last_success_unixtime', 'Last time job succeeded',
registry=registry)
g.set_to_current_time()
push_to_gateway(
'prometheus-pushgateway.monitoring.svc.cluster.local:9091',
job='my_job',
registry=registry
)
Из скрипта (bash в Pod)
#!/bin/bash
START=$(date +%s)
# ... основная работа ...
END=$(date +%s)
DURATION=$((END - START))
cat <<EOF | curl --data-binary @- \
"${PUSHGATEWAY_URL}/metrics/job/${JOB_NAME}/instance/${HOSTNAME}"
job_duration_seconds ${DURATION}
job_last_success_timestamp $(date +%s)
EOF
Alerting на пропавшие метрики
# PrometheusRule
- alert: BatchJobMissing
expr: time() - push_time_seconds{job="my-cron-job"} > 3600
for: 0m
annotations:
summary: "Batch job hasn't run in 1 hour"
Удалить метрику
curl -X DELETE \
http://prometheus-pushgateway.monitoring.svc.cluster.local:9091/metrics/job/my-batch-job
Официальные ресурсы
- Официальный сайт: https://github.com/prometheus/pushgateway
- Официальная документация: https://github.com/prometheus/pushgateway
- Версии Helm chart / ПО: https://artifacthub.io/packages/helm/prometheus-community/prometheus-pushgateway