Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppConfig ¶
type AppConfig struct { Name string `yaml:"name"` SourceFiles []string `yaml:"source_files"` Relables []*RelabelConfig `yaml:"relabels"` }
AppConfig config an APP observer APP observer has a name, which will be labeled in metrics as app={name} APP observer can read from multple files APP observer can overide namespace's default relabel configs
type AppObserver ¶
type AppObserver struct { Name string // contains filtered or unexported fields }
AppObserver reads incoming nginx logs and gather values
func NewAppObserver ¶
func NewAppObserver(ns *Namespace, appCfg AppConfig) *AppObserver
NewAppObserver create a new AppObserver
type ExcactReplaceConfig ¶
type ExcactReplaceConfig struct { Match string `yaml:"match"` Replacement string `yaml:"replacement"` }
ExcactReplaceConfig tells how to extract label value from source value
type Follower ¶
Follower describes an object that continuously emits a stream of lines
func NewFileFollower ¶
NewFileFollower creates a new Follower instance for a given file (given by name)
type Namespace ¶
type Namespace struct { Name string Parser *gonx.Parser Metrics Metrics Labels []string Relabels map[string]*Relabeling Observers []*AppObserver LabelIndexer map[string]int }
Namespace collect a group of metrics of different APP
func NewNamespace ¶
func NewNamespace(nsCfg NamespaceConfig) *Namespace
NewNamespace create a Namespace object from nsCfg
func NewNamespaceWithMetrics ¶
func NewNamespaceWithMetrics(nsCfg NamespaceConfig, metrics Metrics) *Namespace
NewNamespaceWithMetrics create a Namespace object from config and metrics
It uses labels in metrics and ignore labels in nsCfg
func (*Namespace) StartObserve ¶
StartObserve start goroutines to observe metrics of different APP Observers
type NamespaceConfig ¶
type NamespaceConfig struct { Name string `yaml:"name"` Labels []string `yaml:"labels"` Format string `yaml:"format"` DefaultRelabels []*RelabelConfig `yaml:"default_relabels"` HistogramBuckets []float64 `yaml:"histogram_buckets"` Apps []AppConfig }
NamespaceConfig config a group of metric scraper metrics in a namespace share:
- group of metric names
- labels
- nginx log format
- historgram buckets
a namespace has default relabel configs, they can be changed by child APP observers
type RegexReplace ¶
RegexReplace match and convert value
func NewRegexReplace ¶
func NewRegexReplace(cfg *RegexReplaceConfig) *RegexReplace
NewRegexReplace create RegexReplace object
type RegexReplaceConfig ¶
type RegexReplaceConfig struct { RegexpString string `yaml:"regexp"` // pattern to match source value Replacement string `yaml:"replacement"` // replace pattern, like "abc_$1" }
RegexReplaceConfig tells how to extract label value from source value
type RelabelConfig ¶
type RelabelConfig struct { Name string `yaml:"name"` // label name Source string `yaml:"source"` // keyword in nginx log format Split int `yaml:"split"` // sometimes we need onyl part of source value, we can split source value and take specific part Preprocesses []*RegexReplaceConfig `yaml:"preprocesses"` RegexMatches []*RegexReplaceConfig `yaml:"regex_matches"` ExcactMatches []*ExcactReplaceConfig `yaml:"exact_matches"` }
RelabelConfig tells the application how to extract a metric label value
type Relabeling ¶
type Relabeling struct { Name string Source string Split int Preprocesses []*RegexReplace RegexMatches []*RegexReplace ExactMatches map[string]string }
Relabeling extract label value from source value
func NewRelabeling ¶
func NewRelabeling(cfg *RelabelConfig) *Relabeling
NewRelabeling create Relabeling object from config