187.md 1.9 KB
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# Monitoring HAProxy

> 原文:[https://docs.gitlab.com/ee/user/project/integrations/prometheus_library/haproxy.html](https://docs.gitlab.com/ee/user/project/integrations/prometheus_library/haproxy.html)

*   [Requirements](#requirements)
*   [Metrics supported](#metrics-supported)
*   [Configuring Prometheus to monitor for HAProxy metrics](#configuring-prometheus-to-monitor-for-haproxy-metrics)
*   [Specifying the Environment label](#specifying-the-environment-label)

# Monitoring HAProxy[](#monitoring-haproxy "Permalink")

在 GitLab 9.4 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/12621)

GitLab 支持自动检测和监视 HAProxy. 这是通过利用[HAProxy Exporter](https://github.com/prometheus/haproxy_exporter)来提供的,后者将 HAProxy 统计信息转换为 Prometheus 可读形式.

## Requirements[](#requirements "Permalink")

必须启用[Prometheus 服务](../prometheus.html) .

## Metrics supported[](#metrics-supported "Permalink")

| Name | Query |
| --- | --- |
| 吞吐量(要求/秒) | `sum(rate(haproxy_frontend_http_requests_total{%{environment_filter}}[2m])) by (code)` |
| HTTP 错误率(%) | `sum(rate(haproxy_frontend_http_requests_total{code="5xx",%{environment_filter}}[2m])) / sum(rate(haproxy_frontend_http_requests_total{%{environment_filter}}[2m]))` |

## Configuring Prometheus to monitor for HAProxy metrics[](#configuring-prometheus-to-monitor-for-haproxy-metrics "Permalink")

要开始使用 NGINX 监视,您应该安装并配置[HAProxy 导出程序](https://github.com/prometheus/haproxy_exporter) ,该程序可以解析这些统计信息并将其转换为 Prometheus 监视端点.

## Specifying the Environment label[](#specifying-the-environment-label "Permalink")

为了隔离并仅显示给定环境的相关指标,GitLab 需要一种方法来检测关联了哪些标签. 为此,GitLab 将[查找`environment`标签](index.html#identifying-environments) .