Prometheus support for go-metrics

Overview

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()
Issues
  • 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?

    opened by andig 12
  • 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
    
    opened by falzm 3
  • 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)

    opened by sachinagada 1
  • 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
    
    opened by Zyian 1
  • 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

    opened by tumani1 1
  • 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

    opened by stuartmclean 1
  • 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.

    opened by 140am 1
  • 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!

    opened by Ropes 1
  • 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!

    opened by johanoskarsson 1
  • 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]

    opened by panchoh 0
  • 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 ?

    opened by 75115200 0
  • 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 :)

    opened by VoIdemar 0
  • 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.

    opened by nickylogan 3
Owner
Csergő Bálint
Csergő Bálint
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.

Cabify 93 Jun 9, 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. Supports MongoDB and SQL

S Santhosh Nagaraj 19 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

Michael Stapelberg 29 Jul 9, 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

Richard Crowley 3.3k Aug 7, 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 :

null 7 Feb 7, 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

Brigade 4 Mar 17, 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

Mailsac 51 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

Kambi 7 Apr 28, 2022
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

Mackerel 407 Jul 28, 2022
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

Pascal S. de Kloe 22 Jun 10, 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

Prometheus 4k Aug 2, 2022
an unofficial prometheus exporter for the Hochwassernachrichtendienst Bayern.

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

Maximilian Güntner 3 Mar 21, 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

Reinier Schoof 1 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.

Hamid Hosseinzadeh 1 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

Ivan 0 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

Lily Ballard 29 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.

SPDX 173 Aug 3, 2022
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

Anton Ohorodnyk 28 Jul 25, 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

Mixin Network 16 Jul 29, 2022