You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Gauge Exporter is a Prometheus exporter written in Go that allows you to expose custom gauge metrics to Prometheus.It provides a simple HTTP API for inputting metrics and serves them in Prometheus format.
This exporter is specifically designed for use with stateless languages and environments where it is not feasible to maintain metric state in memory, such as in PHP.In these scenarios, Gauge Exporter provides a way to externally store and aggregate metrics that can't be kept in application memory between requests.If your application is written in a language that allows for easy in-memory state management, you might find other Prometheus client libraries more suitable for direct instrumentation.
Gauge Exporter is specifically designed for gauge metrics and does not support counter metrics.It is optimized for use cases where the metric value can increase, decrease, or be set to a specific point.If you need to work with cumulative counters that only increase over time, this exporter may not be suitable for your needs. Please, consider StatsD Exporter or Pushgateway.
Comparison
Gauge Exporter vs Prometheus Pushgateway
Gauge Exporter offers two key advantages over Prometheus Pushgateway.First, it automatically sets unprovided metric labels to zero, simplifying metric reporting with varying label sets.Second, it supports Time-to-Live (TTL) based metric expiration, allowing automatic cleanup of stale data.These features make Gauge Exporter particularly suitable for scenarios with time-sensitive metrics and dynamic labeling requirements, while Pushgateway remains ideal for batch jobs and situations requiring full control over metric persistence.
Usage
Running the Exporter
To run the Gauge Exporter, use the following command:
./gauge-exporter --listen=0.0.0.0:8181
You can customize the listening address and port using the--listen flag.
Endpoints
/metrics: Prometheus metrics endpoint
/gauge/{metric_name}: Input endpoint for gauge metrics
/version: Returns the version of the exporter
Inputting MetricBag
To input a metric, send a PUT request to/gauge/{metric_name} with the following JSON payload: