test

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package test will scrape a target and you can inspect the variables. Basic usage:

result := Scrape("http://localhost:9153/metrics")
v := MetricValue("coredns_cache_capacity", result)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MetricValue

func MetricValue(name string, mfs []*MetricFamily) (string, map[string]string)

MetricValue returns the value associated with name as a string as well as the labels. It only returns the first metrics of the slice.

func MetricValueLabel

func MetricValueLabel(name, label string, mfs []*MetricFamily) (string, map[string]string)

MetricValueLabel returns the value for name *and* label *value*.

func ScrapeMetricAsInt

func ScrapeMetricAsInt(t *testing.T, addr string, name string, label string, nometricvalue int) int

ScrapeMetricAsInt provide a sum of all metrics collected for the name and label provided. if the metric is not a numeric value, it will be counted a 0.

Types

type MetricFamily

type MetricFamily struct {
	Name    string        `json:"name"`
	Help    string        `json:"help"`
	Type    string        `json:"type"`
	Metrics []interface{} `json:"metrics,omitempty"` // Either metric or summary.
}

MetricFamily holds a prometheus metric.

func Scrape

func Scrape(t *testing.T, url string) []*MetricFamily

Scrape returns the all the vars a []*metricFamily.

Jump to

Keyboard shortcuts

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