common

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteMD5

func ByteMD5(b []byte) []byte

func FileMD5

func FileMD5(path string) []byte

func GetKeys

func GetKeys(arr map[string]string) []string

GetKeys returns the keys of a map as a slice

func IfDef

func IfDef(v, def interface{}) interface{}

func MergeMaps

func MergeMaps(maps ...map[string]string) map[string]string

func ReadFiles

func ReadFiles(pattern string) ([]string, error)

func RenderTemplate

func RenderTemplate(tpl *toolsRender.TextTemplate, def string, obj interface{}) (string, error)

func StringInArr

func StringInArr(a string, arr []string) bool

Types

type BaseAvailability

type BaseAvailability struct {
	Queries []*BaseAvailabilityQuery `yaml:"queries"`
	GroupBy []string                 `yaml:"group_by"`
	Labels  map[string]string        `yaml:"labels"`
}

type BaseAvailabilityQuery

type BaseAvailabilityQuery struct {
	Query   string            `yaml:"query"`
	Suffix  string            `yaml:"suffix"`
	Weight  interface{}       `yaml:"weight"`
	Labels  map[string]string `yaml:"labels"`
	UseCRD  string            `yaml:"crd"`
	Source  string            `yaml:"source"`
	Timeout string            `yaml:"timeout"`
}

type BaseConfig

type BaseConfig struct {
	Vars         map[string]string `yaml:"vars"`
	Labels       map[string]string `yaml:"labels"`
	Qualities    []*BaseQuality    `yaml:"quality"`
	Metrics      []*BaseMetric     `yaml:"metrics"`
	Availability *BaseAvailability `yaml:"availability"`
}

func (*BaseConfig) MetricExists

func (bc *BaseConfig) MetricExists(query string) bool

type BaseMetric

type BaseMetric struct {
	Query    string            `yaml:"query"`
	Name     string            `yaml:"name"`
	UniqueBy []string          `yaml:"unique_by"`
	Labels   map[string]string `yaml:"labels"`
}

type BaseQuality

type BaseQuality struct {
	Range  string `yaml:"range"`
	Every  string `yaml:"every"`
	Points int    `yaml:"points"`
	Query  string `yaml:"query"`
}

type Observability

type Observability struct {
	// contains filtered or unexported fields
}

func NewObservability

func NewObservability(logs *sre.Logs, metrics *sre.Metrics) *Observability

func (*Observability) Debug

func (o *Observability) Debug(obj interface{}, args ...interface{})

func (*Observability) Error

func (o *Observability) Error(obj interface{}, args ...interface{})

func (*Observability) Info

func (o *Observability) Info(obj interface{}, args ...interface{})

func (*Observability) Logs

func (o *Observability) Logs() *sre.Logs

func (*Observability) Metrics

func (o *Observability) Metrics() *sre.Metrics

func (*Observability) Warn

func (o *Observability) Warn(obj interface{}, args ...interface{})

type Service

type Service struct {
	Configs []*BaseConfig
	Labels  map[string]string
	Vars    map[string]string
}

type TelegrafConfig

type TelegrafConfig struct {
	Inputs TelegrafInputs `toml:"inputs"`
}

func (*TelegrafConfig) GenerateServiceBytes

func (tc *TelegrafConfig) GenerateServiceBytes(s *Service, opts TelegrafConfigOptions) ([]byte, error)

type TelegrafConfigOptions

type TelegrafConfigOptions struct {
	URL              string
	Version          string
	Params           string
	Interval         string
	Timeout          string
	Duration         string
	Prefix           string
	QualityName      string
	QualityRange     string
	QualityEvery     string
	QualityPoints    int
	QualityQuery     string
	AvailbailityName string
	MetricName       string
	DefaultTags      []string
}

type TelegrafInputPrometheusHttp

type TelegrafInputPrometheusHttp struct {
	URL           string                               `toml:"url"`
	Version       string                               `toml:"version"`
	Params        string                               `toml:"params"`
	Interval      string                               `toml:"interval"`
	Timeout       string                               `toml:"timeout"`
	Duration      string                               `toml:"duration"`
	Prefix        string                               `toml:"prefix"`
	Metric        []*TelegrafInputPrometheusHttpMetric `toml:"metric"`
	Tags          map[string]string                    `toml:"tags,omitempty"`
	Include       []string                             `toml:"taginclude,omitempty"`
	SkipEmptyTags bool                                 `toml:"skip_empty_tags"`
}

type TelegrafInputPrometheusHttpAvailability

type TelegrafInputPrometheusHttpAvailability struct {
	Name     string            `toml:"name"`
	Query    string            `toml:"query"`
	UniqueBy []string          `toml:"unique_by,omitempty"`
	Tags     map[string]string `toml:"tags,omitempty"`
}

type TelegrafInputPrometheusHttpMetric

type TelegrafInputPrometheusHttpMetric struct {
	Name     string            `toml:"name"`
	Query    string            `toml:"query"`
	UniqueBy []string          `toml:"unique_by,omitempty"`
	Tags     map[string]string `toml:"tags,omitempty"`
}

type TelegrafInputs

type TelegrafInputs struct {
	PrometheusHttp []*TelegrafInputPrometheusHttp `toml:"prometheus_http,omitempty"`
}

Jump to

Keyboard shortcuts

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