Documentation
¶
Index ¶
- Constants
- Variables
- func AddFlags(flagSet *kingpin.Application)
- func RegisterCollector(reg prometheus.Registerer)
- type Action
- type Builder
- type CollectConfig
- func (c *CollectConfig) GetMetric(logger log.Logger, data []byte, rcs RelabelConfigs, ...)
- func (c *CollectConfig) GetMetricByDs(ctx context.Context, logger log.Logger, ds *Datasource, ...)
- func (c *CollectConfig) SetLogger(logger log.Logger)
- func (c *CollectConfig) StartStreamCollect(ctx context.Context) error
- func (c *CollectConfig) StopStreamCollect()
- func (c *CollectConfig) UnmarshalYAML(value *yaml.Node) error
- type CollectContext
- type Collects
- type ConnReader
- type ContextKey
- type DataFormat
- type Datapoint
- type Datasource
- func (d *Datasource) Close()
- func (d *Datasource) GetLineStream(ctx context.Context, logger log.Logger) (buffer.ReadLineCloser, error)
- func (d *Datasource) GetStream(ctx context.Context) (io.ReadCloser, error)
- func (d *Datasource) MarshalYAML() (interface{}, error)
- func (d *Datasource) ReadAll(ctx context.Context) ([]byte, error)
- func (d *Datasource) UnmarshalYAML(value *yaml.Node) error
- type DatasourceReadMode
- type DatasourceType
- type GArray
- type GMap
- type HTTPConfig
- type Label
- type Labels
- func (ls *Labels) Append(name, val string)
- func (ls Labels) Bytes(buf []byte) []byte
- func (ls Labels) Copy() Labels
- func (ls Labels) Get(name string) string
- func (ls Labels) Has(name string) bool
- func (ls Labels) HasDuplicateLabelNames() (string, bool)
- func (ls Labels) Hash() uint64
- func (ls Labels) HashForLabels(b []byte, names ...string) (uint64, []byte)
- func (ls Labels) HashWithoutLabels(b []byte, names ...string) (uint64, []byte)
- func (ls Labels) Keys() []string
- func (ls Labels) Len() int
- func (ls Labels) Less(i, j int) bool
- func (ls Labels) Map() map[string]string
- func (ls Labels) MarshalJSON() ([]byte, error)
- func (ls Labels) MarshalYAML() (interface{}, error)
- func (ls Labels) MatchLabels(on bool, names ...string) Labels
- func (ls Labels) String() string
- func (ls Labels) Swap(i, j int)
- func (ls *Labels) UnmarshalJSON(b []byte) error
- func (ls *Labels) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (ls Labels) WithLabels(names ...string) Labels
- func (ls Labels) WithoutEmpty() Labels
- func (ls Labels) WithoutLabels(names ...string) Labels
- type MetricConfig
- func (mc *MetricConfig) BuildRegexp(pointPrefix string) (err error)
- func (mc *MetricConfig) BuildTemplate(pointPrefix string) (err error)
- func (mc *MetricConfig) GetDatapointsByJson(logger log.Logger, data []byte) []Datapoint
- func (mc *MetricConfig) GetDatapointsByRegex(logger log.Logger, data []byte) []Datapoint
- func (mc *MetricConfig) GetDatapointsByXml(logger log.Logger, data []byte) []Datapoint
- func (mc *MetricConfig) GetDatapointsByYaml(logger log.Logger, data []byte) []Datapoint
- func (mc *MetricConfig) Relabels(logger log.Logger, rcs RelabelConfigs, lvs Labels) (newLvs Labels, err error)
- func (mc *MetricConfig) SetLogger(logger log.Logger)
- func (mc *MetricConfig) UnmarshalJSON(raw []byte) error
- func (mc *MetricConfig) UnmarshalYAML(value *yaml.Node) error
- type MetricConfigs
- type MetricGenerator
- type MetricGenerators
- type MetricGroup
- type MetricMatch
- type MetricType
- type NetConfig
- type Regexp
- type RelabelConfig
- type RelabelConfigs
- type SendConfig
- type SendConfigs
- type Streamer
- type Template
- func (t *Template) Execute(data interface{}) ([]byte, error)
- func (t *Template) ExecuteTemplate(name string, data interface{}) ([]byte, error)
- func (t *Template) Funcs(funcMap template.FuncMap) *Template
- func (t Template) MarshalYAML() (interface{}, error)
- func (t *Template) UnmarshalJSON(raw []byte) error
- func (t *Template) UnmarshalYAML(value *yaml.Node) error
Constants ¶
const ( LabelMetricName = "__name__" LabelMetricNamespace = "__namespace__" LabelMetricSubsystem = "__subsystem__" LabelMetricHelp = "__help__" LabelMetricTime = "__time__" LabelMetricTimeFormat = "__time_format__" LabelMetricValue = "__value__" LabelMetricBuckets = "__buckets__" LabelMetricValues = "__values__" LabelMetricValuesSeparator = "__values_separator__" LabelMetricValuesIndex = "__values_index__" LabelMetricValuesIndexSeparator = "__values_index_separator__" LabelMetricValuesIndexLabelName = "__values_index_label_name__" )
const DefaultMaxContent = 102400000
const ExporterName string = "data_exporter"
Variables ¶
var ( DefaultHttpConfig = HTTPConfig{Method: "GET"} DatasourceDefaultTimeout = time.Second * 30 DatasourceDefaultConnectTimeout = time.Second * 3 )
var ( DefaultRelabelConfig = RelabelConfig{ Action: Replace, Separator: ";", Regex: MustNewRegexp("(.*)"), Replacement: "$1", } )
var ErrValueIsNull = fmt.Errorf("metric value is null")
var ErrorDataTooSort = errors.New("data is too short")
Functions ¶
func RegisterCollector ¶
func RegisterCollector(reg prometheus.Registerer)
Types ¶
type Action ¶
type Action string
const ( // Replace performs a regex replacement. Replace Action = "replace" // TemplateExecute performs a template execute replacement. TemplateExecute Action = "templexec" // Keep drops targets for which the input does not match the regex. Keep Action = "keep" // Drop drops targets for which the input does match the regex. Drop Action = "drop" // HashMod sets a label to the modulus of a hash of labels. HashMod Action = "hashmod" // LabelMap copies labels to other labelnames based on a regex. LabelMap Action = "labelmap" // LabelDrop drops any label matching the regex. LabelDrop Action = "labeldrop" // LabelKeep drops any label not matching the regex. LabelKeep Action = "labelkeep" )
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder allows modifying Labels.
func (*Builder) Labels ¶
Labels returns the labels from the builder. If no modifications were made, the original labels are returned.
type CollectConfig ¶
type CollectConfig struct { Name string `yaml:"name,omitempty"` RelabelConfigs RelabelConfigs `yaml:"relabel_configs,omitempty"` DataFormat DataFormat `yaml:"data_format"` Datasource []*Datasource `yaml:"datasource"` Metrics MetricConfigs `yaml:"metrics"` // contains filtered or unexported fields }
func (*CollectConfig) GetMetric ¶
func (c *CollectConfig) GetMetric(logger log.Logger, data []byte, rcs RelabelConfigs, metrics chan<- MetricGenerator)
func (*CollectConfig) GetMetricByDs ¶
func (c *CollectConfig) GetMetricByDs(ctx context.Context, logger log.Logger, ds *Datasource, metrics chan<- MetricGenerator)
func (*CollectConfig) SetLogger ¶
func (c *CollectConfig) SetLogger(logger log.Logger)
func (*CollectConfig) StartStreamCollect ¶
func (c *CollectConfig) StartStreamCollect(ctx context.Context) error
func (*CollectConfig) StopStreamCollect ¶
func (c *CollectConfig) StopStreamCollect()
func (*CollectConfig) UnmarshalYAML ¶
func (c *CollectConfig) UnmarshalYAML(value *yaml.Node) error
type CollectContext ¶
type CollectContext struct { *CollectConfig context.Context DatasourceName string DatasourceUrl string // contains filtered or unexported fields }
func (*CollectContext) Collect ¶
func (c *CollectContext) Collect(proMetrics chan<- prometheus.Metric)
func (*CollectContext) Describe ¶
func (c *CollectContext) Describe(_ chan<- *prometheus.Desc)
type Collects ¶
type Collects []CollectConfig
func (Collects) Get ¶
func (c Collects) Get(name string) *CollectConfig
func (*Collects) StartStreamCollect ¶
func (*Collects) StopStreamCollect ¶
func (c *Collects) StopStreamCollect()
type ConnReader ¶
func NewConnReader ¶
func NewConnReader(conn net.Conn, transferTime time.Duration) *ConnReader
type DataFormat ¶
type DataFormat string
const ( Regex DataFormat = "regex" Json DataFormat = "json" Xml DataFormat = "xml" Yaml DataFormat = "yaml" )
func (DataFormat) ToLower ¶
func (d DataFormat) ToLower() DataFormat
type Datapoint ¶
func (*Datapoint) UnmarshalJSON ¶
type Datasource ¶
type Datasource struct { Name string `yaml:"name,omitempty"` Url string `yaml:"url"` AllowReplace bool `yaml:"allow_replace,omitempty"` Type DatasourceType `yaml:"type"` Timeout time.Duration `yaml:"timeout"` RelabelConfigs RelabelConfigs `yaml:"relabel_configs,omitempty"` MaxContentLength *int64 `yaml:"max_content_length"` MinContentLength *int `yaml:"min_content_length,omitempty"` LineMaxContentLength *int `yaml:"line_max_content_length"` LineSeparator buffer.SliceString `yaml:"line_separator"` EndOf string `yaml:"end_of,omitempty"` ReadMode DatasourceReadMode `yaml:"read_mode"` Config Streamer `yaml:"-"` Whence int `yaml:"whence"` // Deprecated HTTPConfig *HTTPConfig `yaml:"http,omitempty"` // Deprecated TCPConfig *NetConfig `yaml:"tcp,omitempty"` // Deprecated UDPConfig *NetConfig `yaml:"udp,omitempty"` // contains filtered or unexported fields }
func (*Datasource) Close ¶
func (d *Datasource) Close()
func (*Datasource) GetLineStream ¶
func (d *Datasource) GetLineStream(ctx context.Context, logger log.Logger) (buffer.ReadLineCloser, error)
func (*Datasource) GetStream ¶
func (d *Datasource) GetStream(ctx context.Context) (io.ReadCloser, error)
func (*Datasource) MarshalYAML ¶
func (d *Datasource) MarshalYAML() (interface{}, error)
func (*Datasource) UnmarshalYAML ¶
func (d *Datasource) UnmarshalYAML(value *yaml.Node) error
type DatasourceReadMode ¶
type DatasourceReadMode string
const ( Line DatasourceReadMode = "line" Stream DatasourceReadMode = "stream" StreamLine DatasourceReadMode = "stream-line" FullText DatasourceReadMode = "full-text" Full DatasourceReadMode = "full" )
func (DatasourceReadMode) ToLower ¶
func (d DatasourceReadMode) ToLower() DatasourceReadMode
type DatasourceType ¶
type DatasourceType string
const ( Http DatasourceType = "http" Https DatasourceType = "https" File DatasourceType = "file" Tcp DatasourceType = "tcp" Udp DatasourceType = "udp" )
func (DatasourceType) ToLower ¶
func (d DatasourceType) ToLower() DatasourceType
func (DatasourceType) ToLowerString ¶
func (d DatasourceType) ToLowerString() string
type HTTPConfig ¶
type HTTPConfig struct { HTTPClientConfig promconfig.HTTPClientConfig `yaml:"http_client_config,inline"` Body string `yaml:"body,omitempty"` Headers map[string]string `yaml:"headers,omitempty"` Method string `yaml:"method,omitempty"` ValidStatusCodes []int `yaml:"valid_status_codes,omitempty"` MaxConnectTime time.Duration `yaml:"max_connect_time"` }
func (HTTPConfig) GetStream ¶
func (h HTTPConfig) GetStream(ctx context.Context, name, targetURL string) (io.ReadCloser, error)
func (*HTTPConfig) UnmarshalYAML ¶
func (h *HTTPConfig) UnmarshalYAML(value *yaml.Node) error
type Labels ¶
type Labels []Label
func New ¶
New returns a sorted Labels from the given labels. The caller has to guarantee that all label names are unique.
func (Labels) Bytes ¶
Bytes returns ls as a byte slice. It uses an byte invalid character as a separator and so should not be used for printing.
func (Labels) Get ¶
Get returns the value for the label with the given name. Returns an empty string if the label doesn't exist.
func (Labels) HasDuplicateLabelNames ¶
HasDuplicateLabelNames returns whether ls has duplicate label names. It assumes that the labelset is sorted.
func (Labels) HashForLabels ¶
HashForLabels returns a hash value for the labels matching the provided names. 'names' have to be sorted in ascending order.
func (Labels) HashWithoutLabels ¶
HashWithoutLabels returns a hash value for all labels except those matching the provided names. 'names' have to be sorted in ascending order.
func (Labels) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Labels) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler.
func (Labels) MatchLabels ¶
MatchLabels returns a subset of Labels that matches/does not match with the provided label names based on the 'on' boolean. If on is set to true, it returns the subset of labels that match with the provided label names and its inverse when 'on' is set to false.
func (*Labels) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Labels) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler.
func (Labels) WithLabels ¶
WithLabels returns a new labels.Labels from ls that only contains labels matching names. 'names' have to be sorted in ascending order.
func (Labels) WithoutEmpty ¶
WithoutEmpty returns the labelset without empty labels. May return the same labelset.
func (Labels) WithoutLabels ¶
WithoutLabels returns a new labels.Labels from ls that contains labels not matching names. 'names' have to be sorted in ascending order.
type MetricConfig ¶
type MetricConfig struct { Name string `yaml:"name,omitempty"` RelabelConfigs RelabelConfigs `yaml:"relabel_configs,omitempty" json:"relabel_configs"` Match MetricMatch `yaml:"match"` MetricType MetricType `yaml:"metric_type" json:"metric_type"` // contains filtered or unexported fields }
func (*MetricConfig) BuildRegexp ¶
func (mc *MetricConfig) BuildRegexp(pointPrefix string) (err error)
func (*MetricConfig) BuildTemplate ¶
func (mc *MetricConfig) BuildTemplate(pointPrefix string) (err error)
func (*MetricConfig) GetDatapointsByJson ¶
func (mc *MetricConfig) GetDatapointsByJson(logger log.Logger, data []byte) []Datapoint
func (*MetricConfig) GetDatapointsByRegex ¶
func (mc *MetricConfig) GetDatapointsByRegex(logger log.Logger, data []byte) []Datapoint
func (*MetricConfig) GetDatapointsByXml ¶
func (mc *MetricConfig) GetDatapointsByXml(logger log.Logger, data []byte) []Datapoint
func (*MetricConfig) GetDatapointsByYaml ¶
func (mc *MetricConfig) GetDatapointsByYaml(logger log.Logger, data []byte) []Datapoint
func (*MetricConfig) Relabels ¶
func (mc *MetricConfig) Relabels(logger log.Logger, rcs RelabelConfigs, lvs Labels) (newLvs Labels, err error)
func (*MetricConfig) SetLogger ¶
func (mc *MetricConfig) SetLogger(logger log.Logger)
func (*MetricConfig) UnmarshalJSON ¶
func (mc *MetricConfig) UnmarshalJSON(raw []byte) error
func (*MetricConfig) UnmarshalYAML ¶
func (mc *MetricConfig) UnmarshalYAML(value *yaml.Node) error
type MetricConfigs ¶
type MetricConfigs []*MetricConfig
type MetricGenerator ¶
type MetricGenerator struct { MetricType MetricType Labels Labels Datasource *Datasource Datapoint *MetricConfig Name string // contains filtered or unexported fields }
func NewMetricGenerator ¶
func NewMetricGenerator(logger log.Logger, name string, metricType MetricType) *MetricGenerator
func (*MetricGenerator) GetMetrics ¶
func (m *MetricGenerator) GetMetrics() ([]prometheus.Metric, []error)
type MetricGenerators ¶
type MetricGenerators struct {
// contains filtered or unexported fields
}
func NewMetricGenerators ¶
func NewMetricGenerators(size int, logger log.Logger) *MetricGenerators
func (*MetricGenerators) Ch ¶
func (mgs *MetricGenerators) Ch() chan MetricGenerator
func (*MetricGenerators) Collect ¶
func (mgs *MetricGenerators) Collect(proMetrics chan<- prometheus.Metric)
func (*MetricGenerators) Describe ¶
func (*MetricGenerators) Describe(_ chan<- *prometheus.Desc)
type MetricGroup ¶
type MetricGroup struct {
// contains filtered or unexported fields
}
func (*MetricGroup) Collect ¶
func (mg *MetricGroup) Collect(metrics chan<- prometheus.Metric)
type MetricMatch ¶
type MetricType ¶
type MetricType string
const ( Gauge MetricType = "gauge" Counter MetricType = "counter" Histogram MetricType = "histogram" )
func (MetricType) ToLower ¶
func (d MetricType) ToLower() MetricType
type NetConfig ¶
type NetConfig struct { Send SendConfigs `yaml:"send,omitempty"` MaxTransferTime *time.Duration `yaml:"max_transfer_time"` MaxConnectTime time.Duration `yaml:"max_connect_time"` TLSConfig *config.TLSConfig `yaml:"tls_config,omitempty" json:"tls_config,omitempty"` EndOf string `yaml:"end_of"` // contains filtered or unexported fields }
func NewNetConfig ¶
func (*NetConfig) UnmarshalYAML ¶
type Regexp ¶
func MustNewRegexp ¶
func (Regexp) MarshalYAML ¶
func (*Regexp) UnmarshalJSON ¶
func (*Regexp) UnmarshalYAML ¶
type RelabelConfig ¶
type RelabelConfig struct { // A list of labels from which values are taken and concatenated // with the configured separator in order. SourceLabels model.LabelNames `yaml:"source_labels,flow,omitempty" json:"source_labels"` // Separator is the string between concatenated values from the source labels. Separator string `yaml:"separator,omitempty"` // Regex against which the concatenation is matched. Regex Regexp `yaml:"regex,omitempty"` // Template perform the replacement according to the template Template Template `yaml:"template,omitempty"` // Modulus to take of the hash of concatenated values from the source labels. Modulus uint64 `yaml:"modulus,omitempty"` // TargetLabel is the label to which the resulting string is written in a replacement. // Regexp interpolation is allowed for the replace action. TargetLabel string `yaml:"target_label,omitempty" json:"target_label"` // Replacement is the regex replacement pattern to be used. Replacement string `yaml:"replacement,omitempty"` // Action is the action to be performed for the relabeling. Action Action `yaml:"action,omitempty"` }
func (*RelabelConfig) UnmarshalJSON ¶
func (c *RelabelConfig) UnmarshalJSON(raw []byte) error
func (*RelabelConfig) UnmarshalYAML ¶
func (c *RelabelConfig) UnmarshalYAML(value *yaml.Node) error
type RelabelConfigs ¶
type RelabelConfigs []*RelabelConfig
func (RelabelConfigs) Process ¶
func (rcs RelabelConfigs) Process(labels Labels) (Labels, error)
Process returns a relabeled copy of the given label set. The relabel configurations are applied in order of input. If a label set is dropped, nil is returned. May return the input labelSet modified.
func (RelabelConfigs) String ¶
func (rcs RelabelConfigs) String() string
type SendConfig ¶
type SendConfig struct { Msg string `yaml:"msg,omitempty"` Delay time.Duration `yaml:"delay,omitempty"` }
func (*SendConfig) UnmarshalYAML ¶
func (s *SendConfig) UnmarshalYAML(value *yaml.Node) error
type SendConfigs ¶
type SendConfigs []SendConfig
func (*SendConfigs) UnmarshalYAML ¶
func (s *SendConfigs) UnmarshalYAML(value *yaml.Node) error