prometheus-exporter-harness

module
v0.0.0-...-97eeea7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2016 License: MIT

README

prometheus-exporter-harness

A prometheus exporter framework - Make it bit easy to build own prometheus exporter.

Usage

Please see example/ directory for more detail.

Coding

package main

import (
	"github.com/kawamuray/prometheus-exporter-harness/harness"
	"github.com/prometheus/client_golang/prometheus"
	"github.com/urfave/cli"
)

type collector struct{}

func (col *collector) Collect(reg *harness.MetricRegistry) {
	reg.Get("example_metric_A").(prometheus.Gauge).Set(128.0)
}

func exampleInit(c *cli.Context, reg *harness.MetricRegistry) (harness.Collector, error) {
	reg.Register("example_metric_A", prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "example_metric_A",
		Help: "is example_metric_A",
	}))
	return &collector{}, nil
}

func main() {
	opts := harness.NewExporterOpts("example_exporter", "0.0.1")
	opts.Init = exampleInit
	harness.Main(opts)
}

Building

./gow get ./example
./gow build -o example_exporter ./example

Running

./example_exporter --interval 10

See Also

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL