-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Rabbitmq exchanges metricset #6955
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0dc7bbd
RabbitMQ exchange metricset
kvalev 375a553
Added rabbitmq exchange data.json with some data, variables renamed a…
jsoriano 78dea89
Removed unused rabbitmq exchange fields
jsoriano 51e862e
Return inmediatelly if rabbitmq json parsing fails
jsoriano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally in case of empty objects they should not be added. Perhaps an issue in the schema? Not a blocker of the PR but worth mentioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't found how to avoid it, they are definned as optional
schema.Object
s, there would be other way to define them?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ruflin would it be ok to define the schema with dotted field names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this will have any affect on the output in the data.json?
For the empty objects: Can you try to set the surrounding doc as optional too? Just had a look at
ack
and I think it's not set to optional.