groupcache icon indicating copy to clipboard operation
groupcache copied to clipboard

Prometheus metrics

Open udhos opened this issue 2 years ago • 0 comments

Hi!

Is there any publicly available code for easily exposing groupcache metrics for Prometheus?

I am sketching up the package below, but maybe I am reinventing the wheel here?!

Please advise!

// Usage example
{
    metricsRoute := "/metrics"
    metricsPort := ":3000"

    log.Printf("starting metrics server at: %s %s", metricsPort, metricsRoute)

    mailgun := mailgun.New(cache)
    labels := map[string]string{
        "app": appName,
    }
    namespace := ""
    collector := groupcache_exporter.NewExporter(namespace, labels, mailgun)

    prometheus.MustRegister(collector)

    go func() {
        http.Handle(metricsRoute, promhttp.Handler())
        log.Fatal(http.ListenAndServe(metricsPort, nil))
    }()
}

Full details: https://github.com/udhos/groupcache_exporter

udhos avatar Jan 15 '24 20:01 udhos