prometheus_helper

package module
v0.0.0-...-2019e70 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2018 License: MIT Imports: 4 Imported by: 1

README

Build Status

Prometheus Helper

Prometheus.io

The purpose of this code is to make it easy to take a Struct structure and build prometheus metrics from it automatically.

Thanks to HyperBitShop.io for sponsoring this project.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectGaugeMap

func CollectGaugeMap(gaugeMap GaugeMap, ch chan<- prometheus.Metric)

func CollectGaugeMapMap

func CollectGaugeMapMap(gaugeMapMap GaugeMapMap, ch chan<- prometheus.Metric)

func CollectGaugeVecMapMap

func CollectGaugeVecMapMap(gaugeVecMapMap GaugeVecMapMap, ch chan<- prometheus.Metric)

func CollectGaugeVecs

func CollectGaugeVecs(name string, value interface{}, vecMapMap GaugeVecMapMap, namespace string, constLabels prometheus.Labels, labelNames []string, labelValues prometheus.Labels)

func ConvertToFloat

func ConvertToFloat(unk interface{}) (float64, error)

A smarter version of the function for conversion of interface to float than Type.ConvertibleTo()

func DescribeGaugeMap

func DescribeGaugeMap(gaugeMap GaugeMap, ch chan<- *prometheus.Desc)

func DescribeGaugeMapMap

func DescribeGaugeMapMap(gaugeMapMap GaugeMapMap, ch chan<- *prometheus.Desc)

func DescribeGaugeVecMapMap

func DescribeGaugeVecMapMap(gaugeVecMapMap GaugeVecMapMap, ch chan<- *prometheus.Desc)

func MakeStructMeta

func MakeStructMeta(strct interface{}, meta *StructMeta)

Recursively follow a nested tree of struct and add the names of the fields to the names map. If the field value is a map, use the keys from that as the names. If there is a name conflict then we use the last one found and throw a warning message.

Check the test for an example.

func NewGauge

func NewGauge(namespace string, metricName string, help string, constLabels prometheus.Labels) prometheus.Gauge

func NewGaugeVec

func NewGaugeVec(namespace string, metricName string, help string, constLabels prometheus.Labels, labels []string) prometheus.GaugeVec

func SetValuesOnGaugeVecs

func SetValuesOnGaugeVecs(meta StructMeta, namespace string, gaugeVecMap GaugeVecMap, labels prometheus.Labels)

func SetValuesOnGauges

func SetValuesOnGauges(meta StructMeta, namespace string, gaugeMap GaugeMap)

Types

type GaugeMap

type GaugeMap map[string]prometheus.Gauge

func NewGaugeMap

func NewGaugeMap(meta StructMeta, namespace string, constLabels prometheus.Labels) GaugeMap

Builds a map of Gauges, the names are built out of the struct property names. Looking first to see if there is a json tag name and if not, grab an actual name.

type GaugeMapMap

type GaugeMapMap map[string]GaugeMap

I must be insane.

func NewGaugeMapMap

func NewGaugeMapMap(faces map[string]interface{}, namespace string, constLabels prometheus.Labels) GaugeMapMap

Prometheus won't start up if there are no Gauges defined, so provide a helper to build the MapMap.

type GaugeVecMap

type GaugeVecMap map[string]prometheus.GaugeVec

func NewGaugeVecMap

func NewGaugeVecMap(meta StructMeta, namespace string, labels []string, constLabels prometheus.Labels) GaugeVecMap

Builds a map of Gauges, the names are built out of the struct property names. Looking first to see if there is a json tag name and if not, grab an actual name.

type GaugeVecMapMap

type GaugeVecMapMap map[string]GaugeVecMap

type StructFieldMap

type StructFieldMap map[string]interface{}

Key: FieldName Value: FieldValue

type PoolData struct {
	User    User    `json:"user"`
	Workers Workers `json:"workers"`
	Pool    Pool    `json:"pool"`
	Network Network `json:"network"`
	Market  Market  `json:"market"`
}

map["User"] = User map["Workers"] = Workers ...

func NewStructFieldMap

func NewStructFieldMap(strct interface{}) StructFieldMap

See documentation for StructFieldMap

type StructMeta

type StructMeta struct {
	Name string
	Data map[string]TagValue
}

type TagValue

type TagValue struct {
	Tag   string      // The parsed tag string `json:"Foo,string"` == Foo
	Value interface{} // The value of the field in the struct
}

Jump to

Keyboard shortcuts

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