Skip to content

Commit

Permalink
[Metricbeat] HAProxy info fields adjust to ECS (#10568)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruflin authored Feb 5, 2019
1 parent e97e9c7 commit 3b50cc4
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Update a few elasticsearch.* fields to map to ECS. {pull}10350[10350]
- Update a few logstash.* fields to map to ECS. {pull}10350[10350]
- Update a few kibana.* fields to map to ECS. {pull}10350[10350]
- Update haproxy.* fields to map to ECS. {pull}10558[10558]
- Update haproxy.* fields to map to ECS. {pull}10558[10558] {pull}10568[10568]

*Packetbeat*

Expand Down
5 changes: 5 additions & 0 deletions dev-tools/ecs-migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,11 @@
alias: true
beat: metricbeat

- from: haproxy.info.pid
to: process.pid
alias: true
beat: metricbeat

### Mongodb

- from: mongodb.status.version
Expand Down
4 changes: 3 additions & 1 deletion metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9410,7 +9410,9 @@ Process number.
*`haproxy.info.pid`*::
+
--
type: long
type: alias
alias to: process.pid
Process ID.
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/haproxy/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions metricbeat/module/haproxy/info/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"max": 0,
"total": 0
},
"total": 223
"total": 30
},
"idle": {
"pct": 1
Expand All @@ -42,7 +42,6 @@
"bytes": 0
}
},
"pid": 8,
"pipes": {
"free": 0,
"max": 0,
Expand All @@ -51,7 +50,7 @@
"process_num": 1,
"processes": 1,
"requests": {
"total": 223
"total": 30
},
"run_queue": 0,
"session": {
Expand Down Expand Up @@ -91,7 +90,7 @@
"tasks": 7,
"ulimit_n": 8034,
"uptime": {
"sec": 236
"sec": 30
},
"zlib_mem_usage": {
"max": 0,
Expand All @@ -102,6 +101,9 @@
"metricset": {
"name": "info"
},
"process": {
"pid": 7
},
"service": {
"address": "127.0.0.1:14567",
"type": "haproxy"
Expand Down
4 changes: 3 additions & 1 deletion metricbeat/module/haproxy/info/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
Process number.
- name: pid
type: long
type: alias
path: process.pid
migration: true
description: >
Process ID.
Expand Down
14 changes: 12 additions & 2 deletions metricbeat/module/haproxy/info/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package info

import (
"github.com/elastic/beats/libbeat/common"
s "github.com/elastic/beats/libbeat/common/schema"
c "github.com/elastic/beats/libbeat/common/schema/mapstrstr"
"github.com/elastic/beats/metricbeat/mb"
Expand Down Expand Up @@ -163,7 +164,16 @@ func eventMapping(info *haproxy.Info, r mb.ReporterV2) {

}

event := mb.Event{}
event.MetricSetFields, _ = schema.Apply(source)
event := mb.Event{
RootFields: common.MapStr{},
}

fields, _ := schema.Apply(source)
if processID, err := fields.GetValue("pid"); err == nil {
event.RootFields.Put("process.pid", processID)
fields.Delete("pid")
}

event.MetricSetFields = fields
r.Event(event)
}
2 changes: 1 addition & 1 deletion metricbeat/tests/system/test_haproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _test_info(self):
self.assertEqual(len(output), 1)
evt = output[0]

self.assertItemsEqual(self.de_dot(HAPROXY_FIELDS), evt.keys(), evt)
self.assertItemsEqual(self.de_dot(HAPROXY_FIELDS + ["process"]), evt.keys(), evt)

self.assert_fields_are_documented(evt)

Expand Down

0 comments on commit 3b50cc4

Please sign in to comment.