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

Rabbitmq exchanges metricset #6607

Closed
wants to merge 10 commits into from
Closed

Rabbitmq exchanges metricset #6607

wants to merge 10 commits into from

Conversation

kvalev
Copy link
Contributor

@kvalev kvalev commented Mar 20, 2018

This pull requests add a new metricset for RabbitMQ exchanges.

Related to #6442

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

Copy link
Member

@ruflin ruflin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. Left a few comments but still need to have a closer look.

@@ -21,7 +21,7 @@ in <<configuration-metricbeat>>. Here is an example configuration:
----
metricbeat.modules:
- module: rabbitmq
metricsets: ["node", "queue", "connection"]
metricsets: ["node", "queue", "connection", "exchange"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminds me we should sort metricsets alphabetical (I can do that in a follow up PR).

@@ -0,0 +1,19 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance you could create a data.json here? The command you need is as following:

go test -tags=integration github.com/elastic/beats/metricbeat/module/rabbitmq/exchange/... -data

It assumes you have rabbitmq running on localhost.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command does not generate the full json file (the message stats are missing). Am I missing something?

{
    "@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,
            "name": "",
            "type": "direct",
            "vhost": "/"
        }
    }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if something is wrong in the metricset if they are missing?

"rate": c.Float("rate"),
}),
},
"publish_in": s.Object{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make the above publish.total.count and this one here publish.in and the following publish.out. Is it correct the the above is just the total?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The advantage of keeping it as publish_in is that all the groups of metrics under messages have the same structure, and they are also kept as a more direct mapping of source metrics.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm always in favor or having all the related metrics under on group but it's really hard to have a clear rule here. I'm good with both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I am not sure what "publish" is supposed to be. The official documentation says "Count of messages published.", but in my environment it is always 0, although publish_in and publish_out are both 0+.
Regarding the naming - it is up to you as I am not familiar with the metric set naming guidelines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it as is for now

assert.EqualValues(t, false, event["auto_delete"])
assert.EqualValues(t, false, event["internal"])

messages := event["messages"].(common.MapStr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if for the comparison here you could create a common.MapStr with all fields inside with the expected values and then compare it? Would probably make the code a bit more readable and easier to extend.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried doing that, but the Equals comparison fails for some reason, although the maps are identical (albeit in a different order):

	Error:      	Not equal:
	            	expected: common.MapStr{"return_unroutable":common.MapStr{"count":40, "details":common.MapStr{"rate":123.123}}, "redeliver":common.MapStr{"count":30, "details":common.MapStr{"rate":0.123}}, "publish":common.MapStr{"count":123, "details":common.MapStr{"rate":0.1}}, "publish_in":common.MapStr{"count":100, "details":common.MapStr{"rate":0.5}}, "publish_out":common.MapStr{"count":99, "details":common.MapStr{"rate":0.9}}, "ack":common.MapStr{"count":60, "details":common.MapStr{"rate":12.5}}, "deliver_get":common.MapStr{"details":common.MapStr{"rate":43.21}, "count":50}, "confirm":common.MapStr{"count":120, "details":common.MapStr{"rate":98.63}}}
	            	actual  : common.MapStr{"ack":common.MapStr{"count":60, "details":common.MapStr{"rate":12.5}}, "deliver_get":common.MapStr{"count":50, "details":common.MapStr{"rate":43.21}}, "confirm":common.MapStr{"count":120, "details":common.MapStr{"rate":98.63}}, "return_unroutable":common.MapStr{"count":40, "details":common.MapStr{"rate":123.123}}, "redeliver":common.MapStr{"count":30, "details":common.MapStr{"rate":0.123}}, "publish":common.MapStr{"count":123, "details":common.MapStr{"rate":0.1}}, "publish_in":common.MapStr{"count":100, "details":common.MapStr{"rate":0.5}}, "publish_out":common.MapStr{"details":common.MapStr{"rate":0.9}, "count":99}}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets leave it as is then for now. I remember there was something like DeepEqual but we can look into this later.

@ruflin ruflin requested a review from jsoriano March 21, 2018 13:18
@jsoriano
Copy link
Member

@kvalev branch needs rebase

@spotlesscoder
Copy link

@kvalev will you find the time to finish this PR in the near future? I need this feature soon

@ruflin
Copy link
Member

ruflin commented Apr 12, 2018

@kvalev I case you can't find the time to finish this PR, lets us know so we can take it over (or perhaps @CodingSpiderFox? ) to get it merged.

Copy link
Member

@ruflin ruflin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kvalev Just realised that there was also some feedback from our side missing. Sorry about that. Could you rebase the PR on master?

@@ -0,0 +1,19 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if something is wrong in the metricset if they are missing?

"rate": c.Float("rate"),
}),
},
"publish_in": s.Object{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it as is for now

@spotlesscoder
Copy link

I'm not good doing git stuff. Still learning. How can I do the rebase? Fork this repo, pull the branch kvalev and push it to my repo, rebase it on master and then open another PR?

@kvalev
Copy link
Contributor Author

kvalev commented Apr 17, 2018

@ruflin I verified it again against my local RabbitMQ instance and it seems that in case the exchanges were not used recently (probably since last restart), the messages_stats section is missing. Even if there were some messages, not all subsection will be returned by the RabbitMQ - only the ones that are not 0. This is also the reason why the data.json generation returns a very basic data skeleton. If I understand it correctly, the data generation uses the Dockerfile to start a RabbitMQ instance and fetch the data from there. However given that the instance was just started it does not report any stats back. If I publish some test messages (using rabbitmqadmin), parts of the stats sections are present. Should I change the Dockerfile to add some test data, so that the data.json generation returns something meaningful? I dont know whether this will break something else.
I also made all exchange stat sections optional - I hope this was the right way to do it.
I also had to cast all integers to int64 in the unit test for the map comparison to work.

@jsoriano
Copy link
Member

jenkins, test this please

@ruflin
Copy link
Member

ruflin commented Apr 19, 2018

@kvalev I like the idea of populating some data before the test. It could also be part of the test instead of the docker image, like this it also work if done with a local instance.

@spotlesscoder
Copy link

@kvalev I like the idea of populating some data before the test. It could also be part of the test instead of the docker image, like this it also work if done with a local instance.

So what is the actual TODO here?

@jsoriano
Copy link
Member

I have created PR #6955 to resolve pending issues

ruflin pushed a commit that referenced this pull request May 8, 2018
@ruflin
Copy link
Member

ruflin commented May 8, 2018

Closing as #6955 was merged. @kvalev Thanks a lot for your work and kicking this off.

@ruflin ruflin closed this May 8, 2018
stevea78 pushed a commit to stevea78/beats that referenced this pull request May 20, 2018
stevea78 pushed a commit to stevea78/beats that referenced this pull request May 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants