Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Namespace to prometheus helper mappings #11424

Merged
merged 2 commits into from
Mar 25, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we set it only in here if it's not empty? Not sure if otherwise it could have some side effects?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a string, so empty val is "" --> there should be no issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked the code where the event is generated and indeed we check for ""

})
}
}

Expand Down