# prometheus/client_golang

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/prometheus-client-golang).**

5,999 stars · 1,287 forks · Go · Apache-2.0

## Links

- GitHub: https://github.com/prometheus/client_golang
- Homepage: https://pkg.go.dev/github.com/prometheus/client_golang
- awesome-repositories: https://awesome-repositories.com/repository/prometheus-client-golang.md

## Description

Prometheus client_golang is the official Go client library for instrumenting applications with Prometheus metrics. It provides a metric registry that manages and exposes custom application metrics like counters, gauges, histograms, and summaries in Prometheus format for HTTP scraping by a Prometheus server. The library also includes a remote read client that sends PromQL queries to a Prometheus server over HTTP and retrieves time series data programmatically.

The library supports creating separate registries to isolate metric namespaces and control which metrics are exposed per scrape endpoint. It uses atomic operations and mutexes to allow concurrent metric updates from multiple goroutines without data races, and exposes a standard net/http handler that serializes registered metrics into Prometheus text format on each scrape request. Dynamic label sets per metric family enable multi-dimensional time series through label-value pairs, while metrics are registered by implementing a Collector interface that returns descriptor and channel pairs for scrape-time collection.

Additional capabilities include sending PromQL queries to a remote Prometheus server using the HTTP API and parsing the JSON response into Go data structures, computing streaming quantiles over a sliding time window using a configurable reservoir sampling algorithm, and pre-allocating histogram buckets at registration time with atomic counter increments for efficient latency recording.

## Tags

### System Administration & Monitoring

- [Instrumentation Libraries](https://awesome-repositories.com/f/system-administration-monitoring/instrumentation-libraries.md) — Official Go instrumentation library that registers and exposes application metrics in Prometheus format for HTTP scraping.
- [Application Metric Tracking](https://awesome-repositories.com/f/system-administration-monitoring/application-metric-tracking.md) — Registers counters, gauges, histograms, and summaries for Prometheus server scraping. ([source](https://cdn.jsdelivr.net/gh/prometheus/client_golang@main/README.md))
- [Go Instrumentation](https://awesome-repositories.com/f/system-administration-monitoring/application-performance-monitoring/application-performance-monitoring/go-instrumentation.md) — Instruments Go applications with Prometheus metrics for tracking performance, errors, and resource usage.
- [Custom Metric Collectors](https://awesome-repositories.com/f/system-administration-monitoring/global-metric-registries/custom-metric-collectors.md) — Registers metrics by implementing a Collector interface that returns descriptor and channel pairs for scrape-time collection.
- [Prometheus-Formatted HTTP Endpoints](https://awesome-repositories.com/f/system-administration-monitoring/metrics-exporters/prometheus-formatted-http-endpoints.md) — Exposes a standard HTTP handler that serializes registered metrics into Prometheus text format.
- [Prometheus-Based Metric Exporters](https://awesome-repositories.com/f/system-administration-monitoring/prometheus-exporters/prometheus-based-metric-exporters.md) — Exposes custom application metrics like counters, gauges, and histograms for Prometheus server scraping.
- [Metric Registries](https://awesome-repositories.com/f/system-administration-monitoring/prometheus-exporters/prometheus-based-metric-exporters/metric-registries.md) — Manages and exposes custom application metrics for collection by a Prometheus server.
- [Prometheus Remote Read Endpoints](https://awesome-repositories.com/f/system-administration-monitoring/prometheus-remote-read-endpoints.md) — Sends PromQL queries to a Prometheus server over HTTP and retrieves time series data programmatically.
- [Time Series Quantile Tracking](https://awesome-repositories.com/f/system-administration-monitoring/time-series-quantile-tracking.md) — Computes streaming quantiles over a sliding time window using a configurable reservoir sampling algorithm.

### Data & Databases

- [Label-Based Multi-Dimensionality](https://awesome-repositories.com/f/data-databases/multi-dimensional-analysis/label-based-multi-dimensionality.md) — Enables multi-dimensional time series through dynamic label-value pairs on metric families.
- [HTTP API Clients](https://awesome-repositories.com/f/data-databases/query-engines/promql-compatible-engines/http-api-clients.md) — Provides a remote read client that sends PromQL queries over HTTP and parses JSON responses.
- [HTTP Query Clients](https://awesome-repositories.com/f/data-databases/query-engines/promql-compatible-engines/http-query-clients.md) — Sends PromQL queries to a Prometheus server from Go code to retrieve time series data programmatically.
- [PromQL Queries](https://awesome-repositories.com/f/data-databases/time-series-data-modeling/time-series-statistical-profiling/time-series-aggregations/time-series-query-analytics/promql-queries.md) — Sends PromQL queries to a Prometheus server over HTTP and returns time series for programmatic use. ([source](https://cdn.jsdelivr.net/gh/prometheus/client_golang@main/README.md))

### Programming Languages & Runtimes

- [Safe Metric Accumulation](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/concurrency-models/concurrency/synchronization-primitives/channel-based-concurrency/goroutine-based-concurrency/safe-metric-accumulation.md) — Ships atomic and mutex-based mechanisms for concurrent metric updates in Go applications.

### Software Engineering & Architecture

- [Custom Metric Registries](https://awesome-repositories.com/f/software-engineering-architecture/custom-metric-registries.md) — Provides isolated metric registries to control which metrics are exposed per scrape endpoint.
- [Pre-Allocated Bucketing](https://awesome-repositories.com/f/software-engineering-architecture/performance-reliability/performance-engineering/latency-optimization/latency-histograms/pre-allocated-bucketing.md) — Pre-allocates histogram buckets at registration time with atomic counter increments for efficient latency recording.
