Пример настройки модуля | Example of the module configuration |
yaml apiVersion: deckhouse.io/v1alpha1 kind: ModuleConfig metadata: name: prometheus-pushgateway spec: version: 1 enabled: true settings: instances:
| yaml apiVersion: deckhouse.io/v1alpha1 kind: ModuleConfig metadata: name: prometheus-pushgateway spec: version: 1 enabled: true settings: instances:
|
Адрес PushGateway (из контейнера пода): | PushGateway address (from a container pod): |
Отправка метрики | Pushing a metric |
Пример отправки метрики через curl: | An example of pushing a metric using curl: |
shell echo “test_metric{env=”dev”} 3.14” | curl –data-binary @- http://first.kube-prometheus-pushgateway:9091/metrics/job/myapp | shell echo “test_metric{env=”dev”} 3.14” | curl –data-binary @- http://first.kube-prometheus-pushgateway:9091/metrics/job/myapp |
Через 30 секунд (после скрейпа данных) метрики будут доступны в Prometheus. Пример: | The metrics will be available in Prometheus in 30 seconds (after the data are scraped). An example: |
text test_metric{container=”prometheus-pushgateway”, env=”dev”, exported_job=”myapp”, instance=”10.244.1.155:9091”, job=”prometheus-pushgateway”, pushgateway=”prometheus-pushgateway”, tier=”cluster”} 3.14 | text test_metric{container=”prometheus-pushgateway”, env=”dev”, exported_job=”myapp”, instance=”10.244.1.155:9091”, job=”prometheus-pushgateway”, pushgateway=”prometheus-pushgateway”, tier=”cluster”} 3.14 |
Название job (в примере — | The job name ( |
Возможно, вам потребуется получить список всех имеющихся job для выбора уникального названия (чтобы не испортить существующие графики и алерты). Получить список всех имеющихся job можно следующим запросом: | You may need to get a list of all available job names to choose a unique name (in order not to spoil existing graphs and alerts). Use the following query to get a list of all existing jobs: |
Удаление метрик | Deleting metrics |
Пример удаления всех метрик группы | An example of deleting all metrics of a group |
shell curl -X DELETE http://first.kube-prometheus-pushgateway:9091/metrics/job/myapp/instance/10.244.1.155:9091 | shell curl -X DELETE http://first.kube-prometheus-pushgateway:9091/metrics/job/myapp/instance/10.244.1.155:9091 |
Так как PushGateway хранит полученные метрики в памяти, при рестарте пода все метрики будут утеряны. | Since PushGateway stores the scraped metrics in memory, all metrics will be lost when the Pod is restarted. |