jsonexporter

package
v0.0.0-...-f0d80a1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "0.0.2"

Variables

View Source
var DefaultScrapeType = "value"
View Source
var ScrapeTypes = map[string]*ScrapeType{
	"object": {
		Configure: func(config *Config, reg *harness.MetricRegistry) {
			for subName := range config.Values {
				name := harness.MakeMetricName(config.Name, subName)
				reg.Register(
					name,
					prometheus.NewGaugeVec(prometheus.GaugeOpts{
						Name: name,
						Help: config.Help + " - " + subName,
					}, config.labelNames()),
				)
			}
		},
		NewScraper: NewObjectScraper,
	},
	"value": {
		Configure: func(config *Config, reg *harness.MetricRegistry) {
			reg.Register(
				config.Name,
				prometheus.NewGaugeVec(prometheus.GaugeOpts{
					Name: config.Name,
					Help: config.Help,
				}, config.labelNames()),
			)
		},
		NewScraper: NewValueScraper,
	},
}

Functions

Types

type Collector

type Collector struct {
	Endpoint string
	// contains filtered or unexported fields
}

func NewCollector

func NewCollector(endpoint string, scrapers []JsonScraper) *Collector

func (*Collector) Collect

func (col *Collector) Collect(reg *harness.MetricRegistry)

type Config

type Config struct {
	Name   string            `yaml:name`
	Path   string            `yaml:path`
	Labels map[string]string `yaml:labels`
	Type   string            `yaml:type`
	Help   string            `yaml:help`
	Values map[string]string `yaml:values`
}

type JsonScraper

type JsonScraper interface {
	Scrape(data []byte, reg *harness.MetricRegistry) error
}

func NewObjectScraper

func NewObjectScraper(config *Config) (JsonScraper, error)

func NewValueScraper

func NewValueScraper(config *Config) (JsonScraper, error)

type ObjectScraper

type ObjectScraper struct {
	*ValueScraper
	// contains filtered or unexported fields
}

func (*ObjectScraper) Scrape

func (obsc *ObjectScraper) Scrape(data []byte, reg *harness.MetricRegistry) error

type ScrapeType

type ScrapeType struct {
	Configure  func(*Config, *harness.MetricRegistry)
	NewScraper func(*Config) (JsonScraper, error)
}

type ValueScraper

type ValueScraper struct {
	*Config
	// contains filtered or unexported fields
}

func (*ValueScraper) Scrape

func (vs *ValueScraper) Scrape(data []byte, reg *harness.MetricRegistry) error

Jump to

Keyboard shortcuts

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