This service accepts Prometheus metrics, aggregates them, and exposes for /metrics
endpoint12 for scraping.
- no dependencies
- 300LOC
- 95% coverage
- defensive validation
- histograms3 with fixed buckets
- histograms with t-digest45
Bring it to your own http server
func main() {
var config pag.PromAggGatewayServerConfig
configBytes, _ := os.ReadFile(os.Getenv("PAG_CONFIG_PATH"))
if err := yaml.Unmarshal(configBytes, &config); err != nil {
log.Fatal(err)
}
s := pag.NewPromAggGatewayServer(config)
http.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) })
http.HandleFunc("POST /metrics", s.ConsumeMetrics)
http.HandleFunc("GET /metrics", s.GetMetrics)
log.Fatal(http.ListenAndServe(":8080", nil))
}
2024-12-16
not providingmax
,min
aggregations, instead encouraging using histograms2024-12-03
not provideavg
based on totalsum(x)
/count(x)
, to reduce complexity in configuration, keep code flexible and small, and this can be done downstream anyways2024-12-03
using_count
in label naming to match open telemetry histograms2024-12-03
using units in metric name, to keep closer to Prometheus and reduce complexity of API2024-12-02
not usingPrometheus Pushgateway
6, because it does not aggregate metrics2024-12-02
not zapier7 prom aggregation gateway, because: too many 3rd party dependencies (e.g. gin, cobra); no defensive validation;