Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prometheus metrics #67

Open
udhos opened this issue Jan 15, 2024 · 0 comments
Open

Prometheus metrics #67

udhos opened this issue Jan 15, 2024 · 0 comments

Comments

@udhos
Copy link
Contributor

udhos commented Jan 15, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant