integrations/haproxy/documentation.yaml (128 lines of code) (raw):

exporter_type: included app_name_short: HAProxy app_name: {{app_name_short}} app_site_name: HAProxy app_site_url: https://www.haproxy.com/ exporter_name: the PROMEX service for HAProxy exporter_pkg_name: haproxy_promex exporter_repo_url: https://github.com/haproxy/haproxy/blob/master/addons/promex/README dashboard_available: true minimum_exporter_version: "2.4" multiple_dashboards: false dashboard_display_name: {{app_name_short}} Prometheus Overview additional_prereq_info: | {{app_name_short}} exposes Prometheus-format metrics only when it is [built with the service enabled](https://github.com/haproxy/haproxy/blob/master/addons/promex/README){:class="external"} and an appropriate `frontend` is included in the configuration. Most of the official Docker images for versions greater than or equal to 2.4 are built with this service enabled. The following example was built referencing [HAProxy Enterprise documentation](https://www.haproxy.com/documentation/hapee/latest/observability/metrics/prometheus/){:class="external"}. It works with the community edition and can be modified to suit specific needs: <pre> apiVersion: v1 kind: ConfigMap metadata: name: haproxy data: haproxy.cfg: | ... + frontend prometheus + mode http + bind *:8404 + http-request use-service prometheus-exporter if { path /metrics } ... --- apiVersion: apps/v1 kind: Deployment metadata: name: haproxy spec: selector: matchLabels: + app.kubernetes.io/name: haproxy template: metadata: labels: + app.kubernetes.io/name: haproxy spec: containers: - name: haproxy image: haproxy:2.8 ports: - containerPort: 8404 name: prometheus volumeMounts: - mountPath: /usr/local/etc/haproxy/haproxy.cfg subPath: haproxy.cfg name: haproxy volumes: - name: haproxy configMap: name: haproxy items: - key: haproxy.cfg path: haproxy.cfg </pre> To verify that {{exporter_name}} is emitting metrics on the expected endpoints, do the following: 1. Set up port forwarding by using the following command: <pre class="devsite-click-to-copy"> kubectl -n {{namespace_name}} port-forward {{pod_name}} 8404 </pre> 2. Access the endpoint `localhost:8404/metrics` by using the browser or the `curl` utility in another terminal session. podmonitoring_config: | apiVersion: monitoring.googleapis.com/v1 kind: PodMonitoring metadata: name: haproxy labels: app.kubernetes.io/name: haproxy app.kubernetes.io/part-of: google-cloud-managed-prometheus spec: endpoints: - port: prometheus scheme: http interval: 30s path: /metrics selector: matchLabels: app.kubernetes.io/name: haproxy additional_podmonitoring_info: | Ensure that the values of the `port` and `matchLabels` fields match those of the {{app_name_short}} pods you want to monitor. {{app_name_short}} exposes metrics from targets defined in the `bind` configuration option. This option requires a user to define the IP address and port to be listened on for scraping metrics. sample_promql_query: up{job="haproxy", cluster="{{cluster_name}}", namespace="{{namespace_name}}"} alerts_config: | apiVersion: monitoring.googleapis.com/v1 kind: Rules metadata: name: haproxy-rules labels: app.kubernetes.io/component: rules app.kubernetes.io/name: haproxy-rules app.kubernetes.io/part-of: google-cloud-managed-prometheus spec: groups: - name: haproxy interval: 30s rules: - alert: HAProxyDown annotations: description: |- HAProxy instance is down VALUE = {{ $value }} LABELS: {{ $labels }} summary: HAProxy down (instance {{ $labels.instance }}) expr: haproxy_server_up{job="haproxy"} == 0 for: 5m labels: severity: critical - alert: HAProxyTooManyConnections annotations: description: |- HAProxy instance has too many connections VALUE = {{ $value }} LABELS: {{ $labels }} summary: HAProxy too many connections (instance {{ $labels.instance }}) expr: haproxy_frontend_current_sessions{job="haproxy"} / haproxy_frontend_limit_sessions{job="haproxy"} * 100 > 90 for: 5m labels: severity: warning additional_alert_info: You can adjust the alert thresholds to suit your application.