Prometheus support for go-metrics

go-metrics-prometheus Build Status

This is a reporter for the go-metrics library which will post the metrics to the prometheus client registry . It just updates the registry, taking care of exporting the metrics is still your responsibility.

Usage:


	import "github.com/deathowl/go-metrics-prometheus"
	import "github.com/prometheus/client_golang/prometheus"

        metricsRegistry := metrics.NewRegistry()
	prometheusClient := prometheusmetrics.NewPrometheusProvider(
	   metrics.DefaultRegistry, "whatever","something",prometheus.DefaultRegisterer, 1*time.Second)
        go prometheusClient.UpdatePrometheusMetrics()
Comments
  • can't get metrics to show up in prometheus

    can't get metrics to show up in prometheus

    Definitely something stupid I'm doing but can't figure it out. Prometheus shows all the default ones, but not the metrics from the go-metrics examples:

    prometheusRegistry := prometheus.NewRegistry()
    prometheusClient := prometheusmetrics.NewPrometheusProvider(metrics.DefaultRegistry, "", "", prometheusRegistry, 1*time.Second)
    go prometheusClient.UpdatePrometheusMetrics()
    
    http.Handle("/metrics", promhttp.Handler())
    log.Println("Beginning to serve on port :8080")
    log.Fatal(http.ListenAndServe("127.1:8080", nil))
    

    If I create promauto metrics they appear. Any hint?

  • Fix broken go.mod file

    Fix broken go.mod file

    This change fixes the module name in the go.mod file following PR #11, which resulted in broken importing:

    $ go get ...
    ...
    go get: github.com/deathowl/[email protected] updating to
    	github.com/deathowl/[email protected]: parsing go.mod:
    	module declares its path as: github.com/tumani1/go-metrics-prometheus
    	        but was required as: github.com/deathowl/go-metrics-prometheus
    
  • Use flattened name in description

    Use flattened name in description

    Use the flattened name for the help argument when building the prometheus description since the name parameter uses flattened version as well.

    Without this, you can get an error like: has help "name_for-example" but should have "name_for_example" (notice the difference between the hyphen and the underscore between for and example)

  • Fix to go mod reference for Upstream

    Fix to go mod reference for Upstream

    Need a quick fix here so that we don't run into the issue for go get

    go get: github.com/deathowl/[email protected]: parsing go.mod:
            module declares its path as: github.com/tumani1/go-metrics-prometheus
                    but was required as: github.com/deathowl/go-metrics-prometheus
    
  • Race detection

    Race detection

    Replication: Start application with —race flag, Try to get metrics several times. Frequently we catch race condition.

    Trace log: Previous write at 0x00c00019c7f0 by goroutine 97: github.com/prometheus/client_golang/prometheus.NewDesc() /Users/i.tumanov/go/pkg/mod/github.com/prometheus/[email protected]/prometheus/desc.go:81 +0x8d github.com/deathowl/go-metrics-prometheus.(*PrometheusConfig).histogramFromNameAndMetric() /Users/i.tumanov/go/pkg/mod/github.com/deathowl/[email protected]/prometheusmetrics.go:118 +0xbda github.com/deathowl/go-metrics-prometheus.(*PrometheusConfig).UpdatePrometheusMetricsOnce.func1() /Users/i.tumanov/go/pkg/mod/github.com/deathowl/[email protected]/prometheusmetrics.go:163 +0x72a github.com/rcrowley/go-metrics.(*StandardRegistry).Each() /Users/i.tumanov/go/pkg/mod/github.com/rcrowley/[email protected]/registry.go:68 +0x1cc github.com/deathowl/go-metrics-prometheus.(*PrometheusConfig).UpdatePrometheusMetricsOnce() /Users/i.tumanov/go/pkg/mod/github.com/deathowl/[email protected]/prometheusmetrics.go:148 +0xfb github.com/deathowl/go-metrics-prometheus.(*PrometheusConfig).UpdatePrometheusMetrics() /Users/i.tumanov/go/pkg/mod/github.com/deathowl/[email protected]/prometheusmetrics.go:143 +0xe8

  • include histogram and timer buckets

    include histogram and timer buckets

    default bucket values on instantiation with option to globally set custom buckets integration test for histogram metrics

    At least partially resolves #9

  • Golang 1.5+ requirement

    Golang 1.5+ requirement

    prometheus officially requires golang 1.5. This patch is removing 1.4 from the travis build configuration (as it is failing currently) in favor of adding golang 1.7 and 1.8 build steps.

  • Provide Open Source License to go-metrics-prometheus project

    Provide Open Source License to go-metrics-prometheus project

    Since the project is not private, and it's been linked to from the original go-metrics project I'm guessing the project is intented to be Open Source.

    I'd like to make some additions and submit them for review, however clarifying that the project is open source would be a healthy formality. Addresses #2

    I've created a LICENSE file with copyright given to: Copyright 2016 Csergő Bálint github.com/deathowl

    Please consider if you'd like contributions. Cheers!

  • Clarify license

    Clarify license

    Hi hi,

    I'm evaluating various monitoring systems and libraries to use with a Go project. This repo came up and looks promising. One thing that would help me is a clarification of what open source license this code is available under.

    Thanks!

  • Add more metrics of Meters and Timers to Prometheus registry

    Add more metrics of Meters and Timers to Prometheus registry

    Hi.

    Meters and Timers have quite a lot of methods to acquire rates, counts and other stuff, but not all of them are published to Prometheus registry. I suppose they can be useful in certain situations, thus this PR adds missing metrics to registry as gauges.

    Some of the metrics are still missing (like percentiles) - my guess is to choose a number of the most useful of them (for example, 25%, 50%, 75%, 90%, 95%, 99%) and add them as gauges as well.

    Big thanks for the library, by the way :)

  • Support adding more than one pClient targeting the same promRegistry

    Support adding more than one pClient targeting the same promRegistry

    If the target Prometheus Registry has some metrics already registered (for instance, by an previous run of UpdatePrometheusMetrics()), trying to create a new (*PrometheusConfig) targetting the same Prometheus Registry will produce a panic, since MustRegister() will die if an error occurs.

    Simply replacing MustRegister() with Register() will enable this flow without killing the process, since MustRegister() will not panic, but instead return an error.

    Why is this an issue? In our use case, we instantiate a server which creates the goroutine with the pClient.UpdatePrometheusMetricsOnce(). When running in production-ish mode, this happens exactly once per process. But when running the tests, we often create and destroy this server several times in a row, in the same process, along with the goroutine that calls pClient.UpdatePrometheusMetricsOnce(). As it goes, the second time that happens, the call to MustRegister() within gaugeFromNameAndValue() abruptly ends the process with a nice panic, which kinda spoils the fun for us.

    We've changed MustRegister() with the more lax Register(), aiming towards the idempotence of the update process.

    Note that in no way are we trying to run two updaters concurrently.

    Thanks for your time.

    Co-authored-by: Jose Luis Lucas [email protected]

  • Question about metrics.Histogram Percentiles

    Question about metrics.Histogram Percentiles

    https://github.com/deathowl/go-metrics-prometheus/blob/master/prometheusmetrics.go#L103 snapshot.Percentiles(buckets) returns a slice of arbitrary percentiles of values in the sample

    It seems that it should correspond to the Summary in Promethus, right ? why use histogram ?

  • Is there any way to stop UpdatePrometheusMetrics?

    Is there any way to stop UpdatePrometheusMetrics?

    I'm trying to collect metrics of my service into prometheus using this rough implementation:

    pc := prometheusmetrics.NewPrometheusProvider(someRegistry, someNameSpace, someSubSystem, prometheus.DefaultRegisterer, time.Second)
    go pc.UpdatePrometheusMetrics()
    
    http.Handle("/metrics", promhttp.Handler())
    err := http.ListenAndServe(":8080", nil)
    if err != nil {
    	// stop UpdatePrometheusMetrics
    }
    

    Is there any way to stop UpdatePrometheusMetrics()? I don't want to leak an unnecessary goroutine if the endpoint is not even accessible.

Type-safe Prometheus metrics builder library for golang

gotoprom A Prometheus metrics builder gotoprom offers an easy to use declarative API with type-safe labels for building and using Prometheus metrics.

Dec 5, 2022
A tool to run queries in defined frequency and expose the count as prometheus metrics.
A tool to run queries in defined frequency and expose the count as prometheus metrics.

A tool to run queries in defined frequency and expose the count as prometheus metrics. Supports MongoDB and SQL

Jul 1, 2022
rsync wrapper (or output parser) that pushes metrics to prometheus

rsync-prom An rsync wrapper (or output parser) that pushes metrics to prometheus. This allows you to then build dashboards and alerting for your rsync

Dec 11, 2022
Go port of Coda Hale's Metrics library

go-metrics Go port of Coda Hale's Metrics library: https://github.com/dropwizard/metrics. Documentation: http://godoc.org/github.com/rcrowley/go-metri

Dec 30, 2022
a tool for getting metrics in containers

read metrics in container if environment is container, the cpu ,memory is relative to container, else the metrics is relative to host. juejing link :

Oct 13, 2022
Collect and visualize metrics from Brigade 2

Brigade Metrics: Monitoring for Brigade 2 Brigade Metrics adds monitoring capabilities to a Brigade 2 installation. It utilizes Brigade APIs to export

Sep 8, 2022
Count Dracula is a fast metrics server that counts entries while automatically expiring old ones

In-Memory Expirable Key Counter This is a fast metrics server, ideal for tracking throttling. Put values to the server, and then count them. Values ex

Jun 17, 2022
Service for firewalling graphite metrics

hadrianus Block incoming graphite metrics if they come in too fast for downstream carbon-relay/carbon-cache to handle. Building Hadrianus is written i

Apr 28, 2022
mackerel-agent is an agent program to post your hosts' metrics to mackerel.io.
mackerel-agent is an agent program to post your hosts' metrics to mackerel.io.

mackerel-agent mackerel-agent is a client software for Mackerel. Mackerel is an online visualization and monitoring service for servers. Once mackerel

Jan 7, 2023
atomic measures + Prometheus exposition library

About Atomic measures with Prometheus exposition for the Go programming language. This is free and unencumbered software released into the public doma

Sep 27, 2022
Prometheus instrumentation library for Go applications

Prometheus Go client library This is the Go client library for Prometheus. It has two separate parts, one for instrumenting application code, and one

Jan 3, 2023
an unofficial prometheus exporter for the Hochwassernachrichtendienst Bayern.

Hochwassernachrichtendienst Exporter an unofficial prometheus exporter for the Hochwassernachrichtendienst Bayern. Usage Usage of ./hochwassernachrich

Nov 2, 2022
Prometheus exporter for Hue Sensors

Prometheus exporter for Hue Sensors This program allows you to gather generic metrics on all your Philips Hue sensors with Prometheus. Installation In

Nov 17, 2021
In one particular project, i had to import some key/value data to Prometheus. So i have decided to create my custom-built Node Exporter in Golang.
In one particular project, i had to import some key/value data to Prometheus. So i have decided to create my custom-built Node Exporter in Golang.

In one particular project, i had to import some key/value data to Prometheus. So i have decided to create my custom-built Node Exporter in Golang.

May 19, 2022
Prometheus statistics exporter for Open vSwitch

Prometheus statistics exporter for Open vSwitch Open vSwitch is popular virutal switch that enables high performance software defined networking. Sinc

Feb 18, 2022
CoreFoundation Property List support for Go

PACKAGE package plist import "github.com/kballard/go-osx-plist" Package plist implements serializing and deserializing of property list

Mar 18, 2022
Support CI generation of SBOMs via golang tooling.

Software Package Data Exchange (SPDX) is an open standard for communicating software bill of materials (SBOM) information that supports accurate identification of software components, explicit mapping of relationships between components, and the association of security and licensing information with each component.

Jan 3, 2023
Library to work with MimeHeaders and another mime types. Library support wildcards and parameters.

Mime header Motivation This library created to help people to parse media type data, like headers, and store and match it. The main features of the li

Nov 9, 2022
🏆 A decentralized layer to support NFT on Mixin Messenger and Kernel.

NFO A decentralized layer to support NFT on Mixin Kernel. This MTG sends back an NFT to the receiver whenever it receives a transaction with valid min

Aug 14, 2022