common

package
v0.13.8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendHostSink added in v0.6.0

func AppendHostSink(m SinkMap, name string, hs HostSink)

func AppendHostSinkLabels added in v0.13.8

func AppendHostSinkLabels(m SinkMap, name string, hs HostSink, lbs Labels)

func FileMD5

func FileMD5(path string) []byte

func FileMd5ToString added in v0.9.0

func FileMd5ToString(path string) string

func FileWriteWithCheckSum added in v0.8.1

func FileWriteWithCheckSum(path string, data []byte, checksum bool) (bool, error)

func FilterStringMap added in v0.6.0

func FilterStringMap(m map[string]string, keys []string) map[string]string

func GetBaseConfigKeys added in v0.0.5

func GetBaseConfigKeys(arr map[string]*BaseConfig) []string

func GetFileKeys added in v0.3.15

func GetFileKeys(arr map[string]*File) []string

func GetLabelsKeys added in v0.5.10

func GetLabelsKeys(arr map[string]Labels) []string

func GetStringKeys added in v0.0.5

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

func IfDef

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

func Md5 added in v0.9.0

func Md5(b []byte) []byte

func Md5ToString added in v0.9.0

func Md5ToString(b []byte) string

func MergeInterfacegMaps added in v0.3.6

func MergeInterfacegMaps(maps ...map[string]interface{}) map[string]interface{}

func MergeStringMaps added in v0.3.6

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

func ParsePeriodFromNow added in v0.5.3

func ParsePeriodFromNow(period string, t time.Time) string

func ReadFile added in v0.11.0

func ReadFile(path, typ string) (interface{}, error)

func ReadFiles

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

func ReadJson added in v0.11.0

func ReadJson(bytes []byte) (interface{}, error)

func ReadToml added in v0.11.0

func ReadToml(bytes []byte) (interface{}, error)

func ReadYaml added in v0.11.0

func ReadYaml(bytes []byte) (interface{}, error)

func RemoveEmptyStrings added in v0.6.0

func RemoveEmptyStrings(items []string) []string

func Render added in v0.5.3

func Render(def string, obj interface{}, observability *Observability) string

func RenderTemplate

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

func SortStringMapByKeys added in v0.0.5

func SortStringMapByKeys(m map[string]string, keys []string) map[string]string

func StringContainsAny added in v0.3.13

func StringContainsAny(s string, arr []string) bool

func StringInArr

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

func StringSliceToMap added in v0.6.8

func StringSliceToMap(lines []string) map[string]string

Types

type BaseAvailability

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

type BaseAvailabilityQuery

type BaseAvailabilityQuery struct {
	Query     string      `yaml:"query"`
	Round     *int        `yaml:"round"`
	Suffix    string      `yaml:"suffix"`
	Weight    interface{} `yaml:"weight"`
	Labels    Labels      `yaml:"labels"`
	UseCRD    string      `yaml:"crd"`
	Composite string      `yaml:"composite"`
	Source    string      `yaml:"source"`
	Timeout   string      `yaml:"timeout"`
}

type BaseCondition added in v0.3.5

type BaseCondition struct {
	Metric string `yaml:"metric"`
	Labels Labels `yaml:"labels"`
}

type BaseConfig

type BaseConfig struct {
	Disabled     bool              `yaml:"disabled"`
	Prefix       string            `yaml:"prefix"`
	Vars         map[string]string `yaml:"vars"`
	Labels       Labels            `yaml:"labels"`
	Conditions   []*BaseCondition  `yaml:"if"`
	Filters      []*BaseCondition  `yaml:"not"`
	Qualities    []*BaseQuality    `yaml:"quality"`
	Metrics      []*BaseMetric     `yaml:"metrics"`
	Availability *BaseAvailability `yaml:"availability"`
}

func (*BaseConfig) Contains added in v0.3.18

func (bc *BaseConfig) Contains(pattern string) bool

func (*BaseConfig) LabelsExist added in v0.3.5

func (bc *BaseConfig) LabelsExist(c *BaseCondition, labels Labels) bool

func (*BaseConfig) MetricExists

func (bc *BaseConfig) MetricExists(query string, labels Labels) bool

type BaseMetric

type BaseMetric struct {
	Disabled bool     `yaml:"disabled"`
	Query    string   `yaml:"query"`
	Name     string   `yaml:"name"`
	Round    *int     `yaml:"round"`
	UniqueBy []string `yaml:"unique_by"`
	Labels   Labels   `yaml:"labels"`
}

type BaseQuality

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

type Discovery added in v0.5.3

type Discovery interface {
	Discover()
	Name() string
	Source() string
}

type File added in v0.3.2

type File struct {
	Path string
	Type string
	Obj  interface{}
}

type Files added in v0.6.0

type Files map[string]*File

type HostSink added in v0.6.0

type HostSink struct {
	IP      string
	Host    string
	Vendor  string
	OS      string
	Cluster string
	Server  string
}

type Labels added in v0.5.3

type Labels map[string]string

func MergeLabels added in v0.6.8

func MergeLabels(labels ...Labels) Labels

func ReplaceLabelValues added in v0.10.1

func ReplaceLabelValues(labels Labels, replacements map[string]string) Labels

type LabelsMap added in v0.6.0

type LabelsMap map[string]Labels

func ConvertSinkMapToLabelsMap added in v0.10.0

func ConvertSinkMapToLabelsMap(m SinkMap) LabelsMap

type Object added in v0.9.0

type Object struct {
	Metrics []string
	Configs map[string]*BaseConfig
	//	Labels  Labels
	Vars  map[string]string
	Files Files
}

type Objects added in v0.9.0

type Objects map[string]*Object

func ConvertSinkMapToObjects added in v0.10.0

func ConvertSinkMapToObjects(m SinkMap) Objects

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) Panic added in v0.13.7

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

func (*Observability) Warn

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

type Processor added in v0.11.0

type Processor interface {
	Process(d Discovery, so SinkObject)
	Name() string
	Providers() []string
}

type Processors added in v0.11.0

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

func NewProcessors added in v0.11.0

func NewProcessors(observability *Observability, sinks *Sinks) *Processors

func (*Processors) Add added in v0.11.0

func (ps *Processors) Add(p Processor)

func (*Processors) Process added in v0.11.0

func (ps *Processors) Process(d Discovery, so SinkObject)

type PromDiscoveryObject added in v0.5.16

type PromDiscoveryObject struct {
	Name     string
	URL      string
	User     string
	Password string
}

func GetPrometheusDiscoveriesByInstances added in v0.5.3

func GetPrometheusDiscoveriesByInstances(names string, logger sreCommon.Logger) []PromDiscoveryObject

prometheus=prometheus.service.svc:9090, victoria=https://user:pass@victoria.some.where, source2=http://prometheus.location

type PrometheusOptions added in v0.5.3

type PrometheusOptions struct {
	Names    string
	URL      string
	User     string
	Password string
	Timeout  int
	Insecure bool
}

type PrometheusResponse added in v0.5.3

type PrometheusResponse struct {
	Status string                  `json:"status"`
	Data   *PrometheusResponseData `json:"data"`
}

type PrometheusResponseData added in v0.5.3

type PrometheusResponseData struct {
	ResultType string                          `json:"resultType"`
	Result     []*PrometheusResponseDataVector `json:"result"`
}

type PrometheusResponseDataVector added in v0.5.3

type PrometheusResponseDataVector struct {
	Labels map[string]string `json:"metric"`
}

type Sink added in v0.6.0

type Sink interface {
	Process(d Discovery, so SinkObject)
	Name() string
	Providers() []string
}

type SinkMap added in v0.6.0

type SinkMap map[string]interface{}

func ConvertLabelsMapToSinkMap added in v0.6.0

func ConvertLabelsMapToSinkMap(m LabelsMap) SinkMap

func ConvertObjectsToSinkMap added in v0.9.0

func ConvertObjectsToSinkMap(m Objects) SinkMap

type SinkObject added in v0.6.0

type SinkObject interface {
	Map() SinkMap
	Options() interface{}
}

type Sinks added in v0.6.0

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

func NewSinks added in v0.6.0

func NewSinks(observability *Observability) *Sinks

func (*Sinks) Add added in v0.6.0

func (ss *Sinks) Add(s Sink)

func (*Sinks) Process added in v0.6.0

func (ss *Sinks) Process(d Discovery, so SinkObject)

Jump to

Keyboard shortcuts

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