Metrics Exporter is a Go library that provides functionality to interact with Prometheus endpoints and exposes metrics in the text-based exposition format. It simplifies the process of collecting and selectively exposing metrics for monitoring purposes. For example, if there is an usecase of exposing subset of metrics, prometheus metrics exporter enables us to filter the metrics using prometheus query endpoint, and exposes the metrics in text based exposition format.
- Seamless integration with Prometheus endpoints
- Automatic exposition of metrics in the text-based format
To install metrics_exporter, use the following command:
go get -u github.com/milind12/metrics_exporter
To get started with this project, follow these steps:
1 . Import the package into your Go code:
import "github.com/milind12/metrics_exporter"
- Following code example demonstrates selectively exposing metrics which have label
job
with valuedemo-app-metrics
promExporterInstance, err := NewPrometheusExporterInstance("http", "<PrometheusHost>", "<PrometheusPort>", []map[string]string{map[string]string{"job": "demo-app-metrics"}})
if err != nil {
t.Errorf("failed")
}
exportedMetrics:= promInstance.ExportMetrics()
fmt.Println(exportedMetrics)