Skip to content

Commit

Permalink
Add missing namespace field in http server metricset (elastic#7890) (e…
Browse files Browse the repository at this point in the history
…lastic#9071)

This PR adds back the missing `metricset.namespace` field in to payloads generated by http server.

(cherry picked from commit 21e1600)

Co-authored-by: Vijay Samuel <[email protected]>
  • Loading branch information
jsoriano and vjsamuel authored Nov 19, 2018
1 parent 23daf04 commit 3759a51
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ https://github.com/elastic/beats/compare/v6.4.0...v6.5.0[View commits]
- Fix range colors in multiple visualizations. {issue}8633[8633] {pull}8634[8634]
- Fix incorrect header parsing on http metricbeat module {issue}8564[8564] {pull}8585[8585]
- Fixed a panic when the kvm module cannot establish a connection to libvirtd. {issue}7792[7792].
- Add missing namespace field in http server metricset {pull}7890[7890]
*Packetbeat*
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 3759a51

Please sign in to comment.