elastic / elastic/beats

Refactor metricbeat prometheus module to use prometheus/common

Open
#48,217 3 comments 0 reactions 0 assignees View on GitHub
BeatReceiver:MakeItRight Metricbeat prometheus Team:Elastic-Agent-Data-Plane
Dominant language
Go
Stars
12.7k
Forks
5k
Avg merge
2d 15m
Merged PRs (30d)
385

Description

The metricbeat prometheus module imports some prometheus internals from `github.com/prometheus/prometheus`. These should be replaced with equivalents from `prometheus/common`, which is a lot more stable, and more importantly, does not cause conflicts with otel contrib and its [prometheus receiver](https://github.com/elastic/opentelemetry-collector-contrib/blob/main/receiver/prometheusreceiver). Some of our otel upgrades have been severely delayed due to this, see https://github.com/elastic/beats/pull/45667.

The metricbeat module only really needs to parse the exposition format, and https://github.com/prometheus/common/tree/main/expfmt should be good enough for that.

The one case where this isn't clear cut is for the prometheus remote write protocol protobuf definitions, which metricbeat [imports](https://github.com/elastic/beats/blob/main/metricbeat/module/prometheus/remote_write/remote_write.go) from `prometheus/prometheus/prompb`. This can be left alone for now, as it shouldn't lead to any conflicts, but we can also pull the definitions from https://buf.build/prometheus/prometheus and generate the Go code ourselves.

Contributor guide

Open the contributing guide

Research direction

Start by locating the metricbeat Prometheus module imports and inspect metricbeat/module/prometheus/remote_write/remote_write.go separately, since the remote-write protobuf dependency may remain unchanged. Compare the exposition-format needs with prometheus/common/expfmt, then run the module's existing tests. Done means the exposition parser no longer relies on Prometheus internals and the module tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, prometheus
Domain
observability
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.