Skip to content

Commit

Permalink
Add missing namespace field in http server metricset (elastic#7890)
Browse files Browse the repository at this point in the history
This PR adds back the missing `metricset.namespace` field in to payloads generated by http server.

(cherry picked from commit 08dfd03)
  • Loading branch information
vjsamuel authored and jsoriano committed Nov 14, 2018
1 parent 5dfec00 commit 5616fd7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ https://github.com/elastic/beats/compare/v6.5.0...6.x[Check the HEAD diff]

*Metricbeat*

- Add missing namespace field in http server metricset {pull}7890[7890]

*Packetbeat*

*Winlogbeat*
Expand Down
14 changes: 9 additions & 5 deletions metricbeat/module/http/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
package server

import (
"github.com/elastic/beats/libbeat/common"
"fmt"

"github.com/elastic/beats/libbeat/common/cfgwarn"
serverhelper "github.com/elastic/beats/metricbeat/helper/server"
"github.com/elastic/beats/metricbeat/helper/server/http"
Expand Down Expand Up @@ -83,10 +84,13 @@ func (m *MetricSet) Run(reporter mb.PushReporterV2) {
reporter.Error(err)
} else {
event := mb.Event{}
event.ModuleFields = common.MapStr{}
metricSetName := fields[mb.NamespaceKey].(string)
delete(fields, mb.NamespaceKey)
event.ModuleFields.Put(metricSetName, fields)
ns, ok := fields[mb.NamespaceKey].(string)
if ok {
ns = fmt.Sprintf("http.%s", ns)
delete(fields, mb.NamespaceKey)
}
event.MetricSetFields = fields
event.Namespace = ns
reporter.Event(event)
}

Expand Down

0 comments on commit 5616fd7

Please sign in to comment.