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

[Metricbeat] Align rabbitmq with ECS and have module fields #10563

Merged
merged 5 commits into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- 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 rabbitmq.* fields to map to ECS. {pull}10563[10563]

*Packetbeat*

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

### Rabbitmq

- from: rabbitmq.connection.node
to: rabbitmq.node.name
alias: true
beat: metricbeat

- from: rabbitmq.connection.vhost
to: rabbitmq.vhost
alias: true
beat: metricbeat

- from: rabbitmq.connection.user
to: user.name
alias: true
beat: metricbeat

- from: rabbitmq.exchange.vhost
to: rabbitmq.vhost
alias: true
beat: metricbeat

- from: rabbitmq.exchange.user
to: user.name
alias: true
beat: metricbeat

- from: rabbitmq.queue.node
to: rabbitmq.node.name
alias: true
beat: metricbeat

- from: rabbitmq.queue.vhost
to: rabbitmq.vhost
alias: true
beat: metricbeat


### Redis

- from: php_fpm.status.pid
Expand Down
62 changes: 44 additions & 18 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -19831,6 +19831,26 @@ RabbitMQ module



*`rabbitmq.node.name`*::
+
--
type: keyword

Node name


--

*`rabbitmq.vhost`*::
+
--
type: keyword

Virtual host name with non-ASCII characters escaped as in C.


--

[float]
== connection fields

Expand All @@ -19841,7 +19861,9 @@ connection
*`rabbitmq.connection.name`*::
+
--
type: keyword
type: alias

alias to: rabbitmq.name

The name of the connection with non-ASCII characters escaped as in C.

Expand All @@ -19851,7 +19873,9 @@ The name of the connection with non-ASCII characters escaped as in C.
*`rabbitmq.connection.vhost`*::
+
--
type: keyword
type: alias

alias to: rabbitmq.vhost

Virtual host name with non-ASCII characters escaped as in C.

Expand All @@ -19861,7 +19885,9 @@ Virtual host name with non-ASCII characters escaped as in C.
*`rabbitmq.connection.user`*::
+
--
type: keyword
type: alias

alias to: user.name

User name.

Expand All @@ -19871,7 +19897,9 @@ User name.
*`rabbitmq.connection.node`*::
+
--
type: keyword
type: alias

alias to: rabbitmq.node.name

Node name.

Expand Down Expand Up @@ -20030,7 +20058,9 @@ The name of the queue with non-ASCII characters escaped as in C.
*`rabbitmq.exchange.vhost`*::
+
--
type: keyword
type: alias

alias to: rabbitmq.vhost

Virtual host name with non-ASCII characters escaped as in C.

Expand Down Expand Up @@ -20070,7 +20100,9 @@ Whether the exchange is internal, i.e. cannot be directly published to by a clie
*`rabbitmq.exchange.user`*::
+
--
type: keyword
type: alias

alias to: user.name

User who created the exchange.

Expand Down Expand Up @@ -20384,16 +20416,6 @@ type: long
Number of messages which have been written to the message store.


--

*`rabbitmq.node.name`*::
+
--
type: keyword

Node name


--

*`rabbitmq.node.proc.total`*::
Expand Down Expand Up @@ -20526,7 +20548,9 @@ The name of the queue with non-ASCII characters escaped as in C.
*`rabbitmq.queue.vhost`*::
+
--
type: keyword
type: alias

alias to: rabbitmq.vhost

Virtual host name with non-ASCII characters escaped as in C.

Expand Down Expand Up @@ -20566,7 +20590,9 @@ Whether the queue is exclusive (i.e. has owner_pid).
*`rabbitmq.queue.node`*::
+
--
type: keyword
type: alias

alias to: rabbitmq.node.name

Node name.

Expand Down
9 changes: 9 additions & 0 deletions metricbeat/module/rabbitmq/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@
type: group
description: >
fields:
- name: node.name
type: keyword
description: >
Node name

- name: vhost
type: keyword
description: >
Virtual host name with non-ASCII characters escaped as in C.
16 changes: 10 additions & 6 deletions metricbeat/module/rabbitmq/connection/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"frame_max": 131072,
"host": "::1",
"name": "[::1]:60938 -\u003e [::1]:5672",
"node": "nodename",
"octet_count": {
"received": 3764,
"sent": 3840
Expand All @@ -34,13 +33,18 @@
"port": 60938
},
"port": 5672,
"type": "network",
"user": "guest",
"vhost": "/"
}
"type": "network"
},
"node": {
"name": "nodename"
},
"vhost": "/"
},
"service": {
"address": "127.0.0.1:54352",
"address": "127.0.0.1:53939",
"type": "rabbitmq"
},
"user": {
"name": "guest"
}
}
16 changes: 12 additions & 4 deletions metricbeat/module/rabbitmq/connection/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,27 @@
release: ga
fields:
- name: name
type: keyword
type: alias
path: rabbitmq.name
migration: true
description: >
The name of the connection with non-ASCII characters escaped as in C.
- name: vhost
type: keyword
type: alias
path: rabbitmq.vhost
migration: true
description: >
Virtual host name with non-ASCII characters escaped as in C.
- name: user
type: keyword
type: alias
path: user.name
migration: true
description: >
User name.
- name: node
type: keyword
type: alias
path: rabbitmq.node.name
migration: true
description: >
Node name.
- name: channels
Expand Down
3 changes: 0 additions & 3 deletions metricbeat/module/rabbitmq/connection/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ func TestFetchEventContents(t *testing.T) {
event := ee.(common.MapStr)

assert.EqualValues(t, "[::1]:60938 -> [::1]:5672", event["name"])
assert.EqualValues(t, "/", event["vhost"])
assert.EqualValues(t, "guest", event["user"])
assert.EqualValues(t, "nodename", event["node"])
webmat marked this conversation as resolved.
Show resolved Hide resolved
assert.EqualValues(t, 8, event["channels"])
assert.EqualValues(t, 65535, event["channel_max"])
assert.EqualValues(t, 131072, event["frame_max"])
Expand Down
21 changes: 21 additions & 0 deletions metricbeat/module/rabbitmq/connection/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/joeshaw/multierror"

"github.com/elastic/beats/libbeat/common"
s "github.com/elastic/beats/libbeat/common/schema"
c "github.com/elastic/beats/libbeat/common/schema/mapstriface"
"github.com/elastic/beats/libbeat/logp"
Expand Down Expand Up @@ -80,8 +81,28 @@ func eventsMapping(content []byte, r mb.ReporterV2) {

func eventMapping(connection map[string]interface{}, r mb.ReporterV2) error {
fields, err := schema.Apply(connection)

rootFields := common.MapStr{}
if v, err := fields.GetValue("user"); err == nil {
rootFields.Put("user.name", v)
fields.Delete("user")
}

moduleFields := common.MapStr{}
if v, err := fields.GetValue("vhost"); err == nil {
moduleFields.Put("vhost", v)
fields.Delete("vhost")
}

if v, err := fields.GetValue("node"); err == nil {
moduleFields.Put("node.name", v)
fields.Delete("node")
}

event := mb.Event{
MetricSetFields: fields,
RootFields: rootFields,
ModuleFields: moduleFields,
}
r.Event(event)
return err
Expand Down
12 changes: 7 additions & 5 deletions metricbeat/module/rabbitmq/exchange/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
}
},
"name": "exchange.name",
"type": "fanout",
"user": "guest",
"vhost": "/"
}
"type": "fanout"
},
"vhost": "/"
},
"service": {
"address": "127.0.0.1:55006",
"address": "127.0.0.1:53926",
"type": "rabbitmq"
},
"user": {
"name": "guest"
}
}
8 changes: 6 additions & 2 deletions metricbeat/module/rabbitmq/exchange/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
description: >
The name of the queue with non-ASCII characters escaped as in C.
- name: vhost
type: keyword
type: alias
path: rabbitmq.vhost
migration: true
description: >
Virtual host name with non-ASCII characters escaped as in C.
- name: durable
Expand All @@ -25,7 +27,9 @@
description: >
Whether the exchange is internal, i.e. cannot be directly published to by a client.
- name: user
type: keyword
type: alias
path: user.name
migration: true
description: >
User who created the exchange.

Expand Down
20 changes: 18 additions & 2 deletions metricbeat/module/rabbitmq/exchange/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/joeshaw/multierror"

"github.com/elastic/beats/libbeat/common"
s "github.com/elastic/beats/libbeat/common/schema"
c "github.com/elastic/beats/libbeat/common/schema/mapstriface"
"github.com/elastic/beats/libbeat/logp"
Expand Down Expand Up @@ -84,8 +85,23 @@ func eventMapping(exchange map[string]interface{}, r mb.ReporterV2) error {
return err
}

event := mb.Event{}
event.MetricSetFields = fields
rootFields := common.MapStr{}
if v, err := fields.GetValue("user"); err == nil {
rootFields.Put("user.name", v)
fields.Delete("user")
}

moduleFields := common.MapStr{}
if v, err := fields.GetValue("vhost"); err == nil {
moduleFields.Put("vhost", v)
fields.Delete("vhost")
}

event := mb.Event{
MetricSetFields: fields,
RootFields: rootFields,
ModuleFields: moduleFields,
}
r.Event(event)
return nil
}
2 changes: 0 additions & 2 deletions metricbeat/module/rabbitmq/exchange/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ func TestFetchEventContents(t *testing.T) {
}

assert.Equal(t, "exchange.name", event["name"])
assert.Equal(t, "guest", event["user"])
assert.Equal(t, "/", event["vhost"])
webmat marked this conversation as resolved.
Show resolved Hide resolved
assert.Equal(t, true, event["durable"])
assert.Equal(t, false, event["auto_delete"])
assert.Equal(t, false, event["internal"])
Expand Down
Loading