Prometheus instrumentation library for Go applications https://pkg.go.dev/github.com/prometheus/client_golang
  • Go 99.3%
  • Makefile 0.3%
  • C 0.3%
  • Shell 0.1%
Find a file
Bartlomiej Plotka a4329cfb37
Merge pull request #2160 from mrueg/graphite-sanitize-tags
graphite: sanitize tag names and values
History 2026-10-08 16:20:31 +02:00
.github fix: updates for tsdb blocks handling (#1928) 2026-10-04 19:54:16 +02:00
api build(deps): bump google.golang.org/grpc 2026-10-04 17:56:26 +00:00
examples Improve linting (#2115) 2026-09-14 10:56:53 +02:00
exp exp/api/remote: reset buffer before generic marshal (#2139) 2026-10-03 12:50:51 +02:00
internal/github.com/golang/gddo Improve linting (#2115) 2026-09-14 10:56:53 +02:00
prometheus Merge pull request #2160 from mrueg/graphite-sanitize-tags 2026-10-08 16:20:31 +02:00
tutorials/whatsup fix: updates for tsdb blocks handling (#1928) 2026-10-04 19:54:16 +02:00
.dockerignore Update common Prometheus files 2026-04-10 18:01:09 +00:00
.gitignore Cut v1.15.0 (#1249) 2023-04-13 12:51:09 +02:00
.golangci.yml Improve linting (#2115) 2026-09-14 10:56:53 +02:00
AGENTS.md docs: add AGENTS.md contributor and maintainer guide (#2056) 2026-08-20 13:39:06 +01:00
CHANGELOG.md fix: updates for tsdb blocks handling (#1928) 2026-10-04 19:54:16 +02:00
CODE_OF_CONDUCT.md Update common Prometheus files (#1045) 2022-05-05 07:46:54 +02:00
CONTRIBUTING.md chore: Remove half-implemented changelog automation (#1564) 2024-07-19 17:12:40 +01:00
generate-go-collector.bash Auto-update Go Collector Metrics for new Go versions (#1476) 2024-03-26 12:42:34 +00:00
go.mod build(deps): bump github.com/klauspost/compress from 1.19.2 to 1.20.1 2026-10-01 09:47:19 +00:00
go.sum build(deps): bump github.com/klauspost/compress from 1.19.2 to 1.20.1 2026-10-01 09:47:19 +00:00
LICENSE License cleanup 2015-01-22 16:13:15 +01:00
MAINTAINERS.md Remove Arthur from the list of maintainers (#1964) 2026-03-17 08:42:19 +01:00
Makefile fix: updates for tsdb blocks handling (#1928) 2026-10-04 19:54:16 +02:00
Makefile.common Improve linting (#2115) 2026-09-14 10:56:53 +02:00
NOTICE Remove inlined upstream code (#1539) 2024-06-20 13:05:41 +02:00
README.md README: document the OpenTelemetry OTLP push bridge (#1987) 2026-08-20 13:04:55 +01:00
RELEASE.md Update supported Go versions (#1812) 2025-05-16 09:09:54 +02:00
SECURITY.md Update common Prometheus files 2026-04-10 18:01:09 +00:00
supported_go_versions.json Update Go Collector metrics for new Go version (#2095) 2026-09-07 11:06:14 +01:00
update-go-version.bash chore(ci): Use stable names for CI steps (#1914) 2025-11-24 09:14:39 +00:00
VERSION release: cut v1.24.1 (#2076) 2026-07-24 07:32:04 +01:00

Prometheus Go client library

Go Reference OpenSSF Scorecard Slack

This is the Go client library for Prometheus. It has two separate parts, one for instrumenting application code, and one for creating clients that talk to the Prometheus HTTP API.

Version Compatibility

This library supports the two most recent major releases of Go. While it may function with older versions, we only provide fixes and support for the currently supported Go releases.

Note

See our Release Process for details on compatibility and support policies.

Important note about releases and stability

This repository generally follows Semantic Versioning. However, the API client in prometheus/client_golang/api/… is still considered experimental. Breaking changes of the API client will not trigger a new major release. The same is true for selected other new features explicitly marked as EXPERIMENTAL in CHANGELOG.md.

Features that require breaking changes in the stable parts of the repository are being batched up and tracked in the v2 milestone, but plans for further development of v2 at the moment.

NOTE: The initial v2 attempt is in a separate branch. We also started experimenting on a new prometheus.V2.* APIs in the 1.x's V2 struct. Help wanted!

Instrumenting applications

Go Reference

The prometheus directory contains the instrumentation library. See the guide on the Prometheus website to learn more about instrumenting applications.

The examples directory contains simple examples of instrumented code.

Pushing metrics via OpenTelemetry OTLP

Applications instrumented with client_golang can also export their metrics via the OpenTelemetry OTLP push protocol without re-instrumenting against a different metric API. The go.opentelemetry.io/contrib/bridges/prometheus module wraps a prometheus.Registry as an OpenTelemetry metric producer, which an OTLP exporter (HTTP or gRPC) can then push to an OTel collector or OTLP-accepting backend. This is useful for batch jobs or environments where pull-based /metrics scraping is not an option.

Pull-based collection via promhttp remains the recommended default for reliability, central discovery, and failover. The bridge is intended as an additional option, not a replacement.

See the bridge's Go reference and source for setup details.

Client for the Prometheus HTTP API

Go Reference

The api/prometheus directory contains the client for the Prometheus HTTP API. It allows you to write Go applications that query time series data from a Prometheus server. It is still in alpha stage.

Where is model, extraction, and text?

The model packages has been moved to prometheus/common/model.

The extraction and text packages are now contained in prometheus/common/expfmt.

Contributing and community

See the contributing guidelines and the Community section of the homepage.

client_golang community is also present on the CNCF Slack #prometheus-client_golang.