-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rabbitmq exchanges metricset (#6955)
Continues with #6607
- Loading branch information
Showing
18 changed files
with
516 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//// | ||
This file is generated! See scripts/docs_collector.py | ||
//// | ||
|
||
[[metricbeat-metricset-rabbitmq-exchange]] | ||
=== RabbitMQ exchange metricset | ||
|
||
beta[] | ||
|
||
include::../../../module/rabbitmq/exchange/_meta/docs.asciidoc[] | ||
|
||
|
||
==== Fields | ||
|
||
For a description of each field in the metricset, see the | ||
<<exported-fields-rabbitmq,exported fields>> section. | ||
|
||
Here is an example document generated by this metricset: | ||
|
||
[source,json] | ||
---- | ||
include::../../../module/rabbitmq/exchange/_meta/data.json[] | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
metricbeat/module/rabbitmq/_meta/testdata/exchange_sample_response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[ | ||
{ | ||
"message_stats": { | ||
"publish_in": 100, | ||
"publish_in_details": { | ||
"rate": 0.5 | ||
}, | ||
"publish_out": 99, | ||
"publish_out_details": { | ||
"rate": 0.9 | ||
} | ||
}, | ||
"user_who_performed_action": "guest", | ||
"name": "exchange.name", | ||
"vhost": "/", | ||
"type": "fanout", | ||
"durable": true, | ||
"auto_delete": false, | ||
"internal": false, | ||
"arguments": {} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"@timestamp": "2017-10-12T08:05:34.853Z", | ||
"beat": { | ||
"hostname": "host.example.com", | ||
"name": "host.example.com" | ||
}, | ||
"metricset": { | ||
"host": "localhost:15672", | ||
"module": "rabbitmq", | ||
"name": "exchange", | ||
"rtt": 115 | ||
}, | ||
"rabbitmq": { | ||
"exchange": { | ||
"arguments": {}, | ||
"auto_delete": false, | ||
"durable": true, | ||
"internal": false, | ||
"messages": { | ||
"ack": {}, | ||
"confirm": {}, | ||
"deliver_get": {}, | ||
"publish": {}, | ||
"publish_in": { | ||
"count": 607, | ||
"details": { | ||
"rate": 4 | ||
} | ||
}, | ||
"publish_out": { | ||
"count": 547, | ||
"details": { | ||
"rate": 4 | ||
} | ||
}, | ||
"redeliver": {}, | ||
"return_unroutable": {} | ||
}, | ||
"name": "", | ||
"type": "direct", | ||
"user": "rmq-internal", | ||
"vhost": "/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
=== rabbitmq exchange MetricSet | ||
|
||
This is the exchange metricset of the module rabbitmq. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
- name: exchange | ||
type: group | ||
description: > | ||
exchange | ||
release: beta | ||
fields: | ||
- name: name | ||
type: keyword | ||
description: > | ||
The name of the queue with non-ASCII characters escaped as in C. | ||
- name: vhost | ||
type: keyword | ||
description: > | ||
Virtual host name with non-ASCII characters escaped as in C. | ||
- name: durable | ||
type: boolean | ||
description: > | ||
Whether or not the queue survives server restarts. | ||
- name: auto_delete | ||
type: boolean | ||
description: > | ||
Whether the queue will be deleted automatically when no longer used. | ||
- name: internal | ||
type: boolean | ||
description: > | ||
Whether the exchange is internal, i.e. cannot be directly published to by a client. | ||
- name: user | ||
type: keyword | ||
description: > | ||
User who created the exchange. | ||
- name: messages.publish_in.count | ||
type: long | ||
description: > | ||
Count of messages published "in" to an exchange, i.e. not taking account of routing. | ||
- name: messages.publish_in.details.rate | ||
type: float | ||
description: > | ||
How much the exchange publish-in count has changed per second in the most recent sampling interval. | ||
- name: messages.publish_out.count | ||
type: long | ||
description: > | ||
Count of messages published "out" of an exchange, i.e. taking account of routing. | ||
- name: messages.publish_out.details.rate | ||
type: float | ||
description: > | ||
How much the exchange publish-out count has changed per second in the most recent sampling interval. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package exchange | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"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" | ||
) | ||
|
||
var ( | ||
schema = s.Schema{ | ||
"name": c.Str("name"), | ||
"vhost": c.Str("vhost"), | ||
"type": c.Str("type"), | ||
"durable": c.Bool("durable"), | ||
"auto_delete": c.Bool("auto_delete"), | ||
"internal": c.Bool("internal"), | ||
"arguments": c.Dict("arguments", s.Schema{}), | ||
"user": c.Str("user_who_performed_action", s.Optional), | ||
"messages": c.Dict("message_stats", s.Schema{ | ||
"publish_in": s.Object{ | ||
"count": c.Int("publish_in", s.Optional), | ||
"details": c.Dict("publish_in_details", s.Schema{ | ||
"rate": c.Float("rate"), | ||
}, c.DictOptional), | ||
}, | ||
"publish_out": s.Object{ | ||
"count": c.Int("publish_out", s.Optional), | ||
"details": c.Dict("publish_out_details", s.Schema{ | ||
"rate": c.Float("rate"), | ||
}, c.DictOptional), | ||
}, | ||
}, c.DictOptional), | ||
} | ||
) | ||
|
||
func eventsMapping(content []byte) ([]common.MapStr, error) { | ||
var exchanges []map[string]interface{} | ||
err := json.Unmarshal(content, &exchanges) | ||
if err != nil { | ||
logp.Err("Error: ", err) | ||
return nil, err | ||
} | ||
|
||
events := []common.MapStr{} | ||
errors := s.NewErrors() | ||
|
||
for _, exchange := range exchanges { | ||
event, errs := eventMapping(exchange) | ||
events = append(events, event) | ||
errors.AddErrors(errs) | ||
} | ||
|
||
return events, errors | ||
} | ||
|
||
func eventMapping(exchange map[string]interface{}) (common.MapStr, *s.Errors) { | ||
return schema.Apply(exchange) | ||
} |
Oops, something went wrong.