Skip to content

Commit

Permalink
Add Namespace to prometheus helper mappings (#11424)
Browse files Browse the repository at this point in the history
Add Namespace to prometheus helper mappings
  • Loading branch information
Pablo Mercado authored Mar 25, 2019
1 parent 65a20db commit 4267241
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ The list below covers the major changes between 7.0.0-beta1 and master only.
- Filebeat modules can now use ingest pipelines in YAML format. {pull}11209[11209]
- Added support for using PYTHON_EXE to control what Python interpreter is used
by `make` and `mage`. Example: `export PYTHON_EXE=python2.7`. {pull}11212[11212]
- Prometheus helper for metricbeat contains now `Namespace` field for `prometheus.MetricsMappings` {pull}11424[11424]
10 changes: 8 additions & 2 deletions metricbeat/helper/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ func (p *prometheus) GetFamilies() ([]*dto.MetricFamily, error) {

// MetricsMapping defines mapping settings for Prometheus metrics, to be used with `GetProcessedMetrics`
type MetricsMapping struct {
// Metrics translates from from prometheus metric name to Metricbeat fields
// 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

Expand Down Expand Up @@ -213,7 +216,10 @@ func (p *prometheus) ReportProcessedMetrics(mapping *MetricsMapping, r mb.Report
return
}
for _, event := range events {
r.Event(mb.Event{MetricSetFields: event})
r.Event(mb.Event{
MetricSetFields: event,
Namespace: mapping.Namespace,
})
}
}

Expand Down

0 comments on commit 4267241

Please sign in to comment.