backend

package
v0.0.0-...-60b8127 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Graphite name of the graphite backend
	Graphite = "graphite"
	// InfluxDB name of the influx db backend
	InfluxDB = "influxdb"
	// ThinInfluxDB name of the thin influx db backend
	ThinInfluxDB = "thininfluxdb"
	// InfluxTag is the tag for influxdb
	InfluxTag = "influx"
	// Elastic name of the elastic backend
	Elastic = "elastic"
	// Prometheus name of the prometheus backend
	Prometheus = "prometheus"
	// Fluentd name of the fluentd backend
	Fluentd = "fluentd"
	// ThinPrometheus name of the thin prometheus backend
	ThinPrometheus = "thinprometheus"
	// Kafka name of the kafka backend
	Kafka = "kafka"
)

Variables

This section is empty.

Functions

func CreateIndexIfNotExists

func CreateIndexIfNotExists(e *elastic.Client, index string) error

CreateIndexIfNotExists not exists creates Elasticsearch Index if Not Exists

Types

type Backend

type Backend interface {
	Init(config Config) error
	Disconnect()
	SendMetrics(metrics []*Point)
}

Backend Interface

type Channels

type Channels struct {
	Request *chan Point
	Target  string
}

Channels are use for unscheduled backend

type Config

type Config struct {
	Hostname   string
	ValueField string
	Database   string
	Username   string
	Password   string
	Type       string
	Prefix     string
	Port       int
	NoArray    bool
	Encrypted  bool
	// contains filtered or unexported fields
}

Config : storage backend

func (*Config) Clean

func (backend *Config) Clean()

Clean : take actions on backend when cycle finished

func (*Config) Disconnect

func (backend *Config) Disconnect()

Disconnect : disconnect from backend

func (*Config) HasMetadata

func (backend *Config) HasMetadata() bool

HasMetadata indicates that the backend supports metadata

func (*Config) Init

func (backend *Config) Init() (*chan Channels, error)

Init : initialize a backend

func (*Config) InitPrometheus

func (backend *Config) InitPrometheus(vcenter string) error

InitPrometheus : Init Multiple channels for prometheus

func (*Config) Scheduled

func (backend *Config) Scheduled() bool

Scheduled indicates that the metric collection needs to be scheduled for the backend

func (*Config) SendMetrics

func (backend *Config) SendMetrics(metrics []*Point, cleanup bool)

SendMetrics : send metrics to backend

type InfluxPoint

type InfluxPoint struct {
	Key       string
	Fields    map[string]string
	Tags      map[string]string
	Timestamp int64
}

InfluxPoint is the representation of the parts of a point for influx

func (*InfluxPoint) ToInflux

func (ip *InfluxPoint) ToInflux(noarray bool, valuefield string) string

ToInflux converts the influx point to influx string format

type MapStr

type MapStr map[string]interface{}

MapStr represents a json node (string reference to an object)

type Point

type Point struct {
	VCenter      string   `influx:"tag,vcenter"`
	ObjectType   string   `influx:"tag,type"`
	ObjectName   string   `influx:"tag,name"`
	Group        string   `influx:"key,1"`
	Counter      string   `influx:"key,2"`
	Instance     string   `influx:"tag,instance"`
	Rollup       string   `influx:"key,3"`
	Value        int64    `influx:"value"`
	Datastore    []string `influx:"tag,datastore" json:",omitempty"`
	ESXi         string   `influx:"tag,host" json:",omitempty"`
	Cluster      string   `influx:"tag,cluster" json:",omitempty"`
	Network      []string `influx:"tag,network" json:",omitempty"`
	ResourcePool string   `influx:"tag,resourcepool" json:",omitempty"`
	Folder       string   `influx:"tag,folder" json:",omitempty"`
	ViTags       []string `influx:"tag,vitags" json:",omitempty"`
	Timestamp    int64    `influx:"time" elastic:"type:date,format:epoch_second"`
}

Point : Information collected for a point

func (*Point) GetInfluxPoint

func (point *Point) GetInfluxPoint(noarray bool, valuefield string) *InfluxPoint

GetInfluxPoint : convert a point to an influxpoint

func (*Point) GetTags

func (point *Point) GetTags(noarray bool, separator string) map[string]string

GetTags returns the tags of point as a map of strings

func (*Point) ToInflux

func (point *Point) ToInflux(noarray bool, valuefield string) string

ToInflux serializes the data to be consumed by influx line protocol see https://docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_tutorial/

type PrometheusBackend

type PrometheusBackend struct {
	Config *Config
	Target string
}

PrometheusBackend : Extend prometheus.Collector

func (*PrometheusBackend) Collect

func (backend *PrometheusBackend) Collect(ch chan<- prometheus.Metric)

Collect : Implementation of Prometheus Collector.Collect

func (*PrometheusBackend) Describe

func (backend *PrometheusBackend) Describe(ch chan<- *prometheus.Desc)

Describe : Implementation of Prometheus Collector.Describe

func (*PrometheusBackend) PrometheusSend

func (backend *PrometheusBackend) PrometheusSend(ch chan<- prometheus.Metric, point Point)

PrometheusSend sends a point to prometheus

type ThinPrometheusClient

type ThinPrometheusClient struct {
	Hostname string
	Port     int
	// contains filtered or unexported fields
}

ThinPrometheusClient tries to export metrics to prometheus as simply as possible

func NewThinPrometheusClient

func NewThinPrometheusClient(server string, port int) (ThinPrometheusClient, error)

NewThinPrometheusClient creates a new thin prometheus

func (*ThinPrometheusClient) ListenAndServe

func (client *ThinPrometheusClient) ListenAndServe() error

ListenAndServe will start the listen thread for metric requests

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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