Skip to content

[Haproxy] Add Prometheus metrics data stream#18439

Draft
giorgi-imerlishvili-elastic wants to merge 2 commits intoelastic:mainfrom
giorgi-imerlishvili-elastic:haproxy-new-metrics-datastream
Draft

[Haproxy] Add Prometheus metrics data stream#18439
giorgi-imerlishvili-elastic wants to merge 2 commits intoelastic:mainfrom
giorgi-imerlishvili-elastic:haproxy-new-metrics-datastream

Conversation

@giorgi-imerlishvili-elastic
Copy link
Copy Markdown
Contributor

Proposed commit message

Adds metrics exposed via prometheus metrics endpoint

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Screenshots

@giorgi-imerlishvili-elastic giorgi-imerlishvili-elastic added enhancement New feature or request Integration:haproxy HAProxy Team:Obs-InfraObs Observability Infrastructure Monitoring team [elastic/obs-infraobs-integrations] labels Apr 16, 2026
Comment on lines +7 to +9
- remove:
field: prometheus.labels
ignore_missing: true
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical ingest_pipeline/default.yml:7

The ingest pipeline unconditionally removes prometheus.labels at lines 7-9, but fields.yml defines prometheus.labels.instance, prometheus.labels.job, prometheus.labels.proxy, and prometheus.labels.state as dimension: true. Since this data stream uses index_mode: "time_series", removing these labels causes metrics from different HAProxy proxies, servers, and states to collapse into the same time series, resulting in silent data loss. Consider removing only unwanted labels while preserving the dimension-critical ones.

-  - remove:
-      field: prometheus.labels
-      ignore_missing: true
Also found in 1 other location(s)

packages/haproxy/data_stream/metrics/fields/fields.yml:5

The ingest pipeline in default.yml removes prometheus.labels entirely via a remove processor, but lines 5-24 of fields.yml define prometheus.labels.instance, prometheus.labels.job, prometheus.labels.proxy, and prometheus.labels.state as dimension: true fields. With index_mode: "time_series" configured in manifest.yml, these dimensions are critical for uniquely identifying time series. Because the pipeline deletes them before indexing, metrics from different HAProxy proxies, servers, and states will collapse into the same time series, causing data loss or incorrect metric values. For example, haproxy_backend_current_sessions for proxy "web" and proxy "api" would be indistinguishable.

🤖 Copy this AI Prompt to have your agent fix this:
In file packages/haproxy/data_stream/metrics/elasticsearch/ingest_pipeline/default.yml around lines 7-9:

The ingest pipeline unconditionally removes `prometheus.labels` at lines 7-9, but `fields.yml` defines `prometheus.labels.instance`, `prometheus.labels.job`, `prometheus.labels.proxy`, and `prometheus.labels.state` as `dimension: true`. Since this data stream uses `index_mode: "time_series"`, removing these labels causes metrics from different HAProxy proxies, servers, and states to collapse into the same time series, resulting in silent data loss. Consider removing only unwanted labels while preserving the dimension-critical ones.

Also found in 1 other location(s):
- packages/haproxy/data_stream/metrics/fields/fields.yml:5 -- The ingest pipeline in `default.yml` removes `prometheus.labels` entirely via a `remove` processor, but lines 5-24 of `fields.yml` define `prometheus.labels.instance`, `prometheus.labels.job`, `prometheus.labels.proxy`, and `prometheus.labels.state` as `dimension: true` fields. With `index_mode: "time_series"` configured in `manifest.yml`, these dimensions are critical for uniquely identifying time series. Because the pipeline deletes them before indexing, metrics from different HAProxy proxies, servers, and states will collapse into the same time series, causing data loss or incorrect metric values. For example, `haproxy_backend_current_sessions` for proxy "web" and proxy "api" would be indistinguishable.

- name: state
type: keyword
dimension: true
description: HAProxy state label exported with metrics.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High fields/fields.yml:24

Server-level metrics (haproxy_server_*) include a server label and listener metrics (haproxy_listener_*) include a listener label, but neither label is declared in prometheus.labels with dimension: true. In TSDB time_series mode, metrics from different servers or listeners sharing the same proxy and state labels will collapse into a single time series, causing data loss or aggregation errors.

+        - name: server
+          type: keyword
+          dimension: true
+          description: HAProxy server label exported with metrics.
+        - name: listener
+          type: keyword
+          dimension: true
+          description: HAProxy listener label exported with metrics.
🤖 Copy this AI Prompt to have your agent fix this:
In file packages/haproxy/data_stream/metrics/fields/fields.yml around line 24:

Server-level metrics (`haproxy_server_*`) include a `server` label and listener metrics (`haproxy_listener_*`) include a `listener` label, but neither label is declared in `prometheus.labels` with `dimension: true`. In TSDB `time_series` mode, metrics from different servers or listeners sharing the same `proxy` and `state` labels will collapse into a single time series, causing data loss or aggregation errors.

Comment on lines +615 to +624
type: long
metric_type: counter
description: >-
Number of bytes submitted to the HTTP compressor in this worker process over the last second
- name: haproxy_process_http_comp_bytes_out_total
type: long
metric_type: counter
description: >-
Number of bytes emitted by the HTTP compressor in this worker process over the last second
- name: haproxy_process_idle_time_percent
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium fields/fields.yml:615

haproxy_process_http_comp_bytes_in_total and haproxy_process_http_comp_bytes_out_total are declared as metric_type: counter but describe per-second byte rates (

-    - name: haproxy_process_http_comp_bytes_in_total
-      type: long
-      metric_type: counter
-      description: >-
-        Number of bytes submitted to the HTTP compressor in this worker process over the last second
-    - name: haproxy_process_http_comp_bytes_out_total
-      type: long
-      metric_type: counter
-      description: >-
-        Number of bytes emitted by the HTTP compressor in this worker process over the last second
+    - name: haproxy_process_http_comp_bytes_in
+      type: long
+      metric_type: gauge
+      description: >-
+        Number of bytes submitted to the HTTP compressor in this worker process over the last second
+    - name: haproxy_process_http_comp_bytes_out
+      type: long
+      metric_type: gauge
+      description: >-
+        Number of bytes emitted by the HTTP compressor in this worker process over the last second
🤖 Copy this AI Prompt to have your agent fix this:
In file packages/haproxy/data_stream/metrics/fields/fields.yml around lines 615-624:

`haproxy_process_http_comp_bytes_in_total` and `haproxy_process_http_comp_bytes_out_total` are declared as `metric_type: counter` but describe per-second byte rates (

@elastic-vault-github-plugin-prod
Copy link
Copy Markdown

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@elasticmachine
Copy link
Copy Markdown

💚 Build Succeeded

cc @giorgi-imerlishvili-elastic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Integration:haproxy HAProxy Team:Obs-InfraObs Observability Infrastructure Monitoring team [elastic/obs-infraobs-integrations]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants