Documentation ¶
Index ¶
- Variables
- func MetricSetBuilder(mapping *MetricsMapping) func(base mb.BaseMetricSet) (mb.MetricSet, error)
- type LabelMap
- type MetricMap
- func BooleanMetric(field string, options ...MetricOption) MetricMap
- func InfoMetric(options ...MetricOption) MetricMap
- func KeywordMetric(field, keyword string, options ...MetricOption) MetricMap
- func LabelMetric(field, label string, options ...MetricOption) MetricMap
- func Metric(field string, options ...MetricOption) MetricMap
- type MetricOption
- type MetricsMapping
- type Prometheus
Constants ¶
This section is empty.
Variables ¶
var ( // HostParser validates Prometheus URLs HostParser = parse.URLHostParserBuilder{ DefaultScheme: defaultScheme, DefaultPath: defaultPath, }.Build() )
Functions ¶
func MetricSetBuilder ¶
func MetricSetBuilder(mapping *MetricsMapping) func(base mb.BaseMetricSet) (mb.MetricSet, error)
MetricSetBuilder returns a builder function for a new Prometheus metricset using the given mapping
Types ¶
type LabelMap ¶
type LabelMap interface { // GetField returns the resulting field name GetField() string // IsKey returns true if the label is a key label IsKey() bool }
LabelMap defines the mapping from Prometheus label to a Metricbeat field
type MetricMap ¶
type MetricMap interface { // GetOptions returns the list of metric options GetOptions() []MetricOption // GetField returns the resulting field name GetField() string // GetValue returns the resulting value GetValue(m *dto.Metric) interface{} }
MetricMap defines the mapping from Prometheus metric to a Metricbeat field
func BooleanMetric ¶
func BooleanMetric(field string, options ...MetricOption) MetricMap
BooleanMetric maps a Prometheus metric to a Metricbeat field of bool type
func InfoMetric ¶
func InfoMetric(options ...MetricOption) MetricMap
InfoMetric obtains info labels from the given metric and puts them into events matching all the key labels present in the metric
func KeywordMetric ¶
func KeywordMetric(field, keyword string, options ...MetricOption) MetricMap
KeywordMetric maps a Prometheus metric to a Metricbeat field, stores the given keyword when source metric value is 1
func LabelMetric ¶
func LabelMetric(field, label string, options ...MetricOption) MetricMap
LabelMetric maps a Prometheus metric to a Metricbeat field, stores the value of a given label on it if the gauge value is 1
func Metric ¶
func Metric(field string, options ...MetricOption) MetricMap
Metric directly maps a Prometheus metric to a Metricbeat field
type MetricOption ¶
type MetricOption interface { // Process a tuple of field, value and labels from a metric, return the same tuple updated Process(field string, value interface{}, labels common.MapStr) (string, interface{}, common.MapStr) }
MetricOption adds settings to Metric objects behavior
func OpFilter ¶
func OpFilter(filter map[string]string) MetricOption
OpFilter only processes metrics matching the given filter
func OpLowercaseValue ¶
func OpLowercaseValue() MetricOption
OpLowercaseValue lowercases the value if it's a string
func OpMultiplyBuckets ¶
func OpMultiplyBuckets(multiplier float64) MetricOption
OpMultiplyBuckets multiplies bucket labels in histograms, useful to change units
type MetricsMapping ¶
type MetricsMapping struct { // Metrics translates from prometheus metric name to Metricbeat fields Metrics map[string]MetricMap // Namespace for metrics managed by this mapping Namespace string // Labels translate from prometheus label names to Metricbeat fields Labels map[string]LabelMap // ExtraFields adds the given fields to all events coming from `GetProcessedMetrics` ExtraFields map[string]string }
MetricsMapping defines mapping settings for Prometheus metrics, to be used with `GetProcessedMetrics`
type Prometheus ¶
type Prometheus interface { // GetFamilies requests metric families from prometheus endpoint and returns them GetFamilies() ([]*dto.MetricFamily, error) GetProcessedMetrics(mapping *MetricsMapping) ([]common.MapStr, error) ReportProcessedMetrics(mapping *MetricsMapping, r mb.ReporterV2) error }
Prometheus helper retrieves prometheus formatted metrics
func NewPrometheusClient ¶
func NewPrometheusClient(base mb.BaseMetricSet) (Prometheus, error)
NewPrometheusClient creates new prometheus helper