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 node only reports metrics of itself by default #6971

Merged
merged 1 commit into from
May 15, 2018

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Apr 28, 2018

A configuration option is added, node.collect that can be set to
cluster to have the previous behaviour. The default is node.

Fixes #6556

return &apiOverview, nil
}

func (m *MetricSet) Fetch() (common.MapStr, error) {

Choose a reason for hiding this comment

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

exported method MetricSet.Fetch should have comment or be unexported

}, nil
}

func (m *MetricSet) Fetch() ([]common.MapStr, error) {
content, err := m.HTTP.FetchContent()
type ApiOverview struct {

Choose a reason for hiding this comment

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

exported type ApiOverview should have comment or be unexported
type ApiOverview should be APIOverview

return &apiOverview, nil
}

func (m *MetricSet) Fetch() (common.MapStr, error) {

Choose a reason for hiding this comment

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

exported method MetricSet.Fetch should have comment or be unexported

}, nil
}

func (m *MetricSet) Fetch() ([]common.MapStr, error) {
content, err := m.HTTP.FetchContent()
type ApiOverview struct {

Choose a reason for hiding this comment

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

exported type ApiOverview should have comment or be unexported
type ApiOverview should be APIOverview

@jsoriano jsoriano force-pushed the rabbitmq-self-node branch 3 times, most recently from 8a51a6a to b5cb2d8 Compare April 28, 2018 11:09
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.

I like the change to the default to only have 1 node by default. I'm wondering if there should be a config option to still be able to receive information for all nodes. This has the advantage that it allows to monitor rabbitmq nodes also in the case Metricbeat can't be installed on each node and is monitored from a central place. This can also happen in a follow up PR. WDYT?

}, nil
}

func (m *MetricSet) Fetch() ([]common.MapStr, error) {
content, err := m.HTTP.FetchContent()
type apiOverview struct {
Copy link
Member

Choose a reason for hiding this comment

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

We normally keep all the mapping code in data.json. But happy to change this convention :-)

@jsoriano
Copy link
Member Author

Ok, agree to allow the user to still collect metrics from all the nodes.

overview *helper.HTTP
}

type AllMetricSet struct {

Choose a reason for hiding this comment

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

exported type AllMetricSet should have comment or be unexported

@@ -27,33 +34,108 @@ func init() {
)
}

type MetricSet struct {
type SelfMetricSet struct {

Choose a reason for hiding this comment

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

exported type SelfMetricSet should have comment or be unexported

package node

const (
ConfigModeSelf = "self"

Choose a reason for hiding this comment

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

exported const ConfigModeSelf should have comment (or a comment on this block) or be unexported

@jsoriano
Copy link
Member Author

Added node.mode config flag to choose between self (new default) and all (previous behaviour), to collect metrics only from the node we are connecting to, or from the whole cluster.

@jsoriano jsoriano changed the title Rabbitmq node only reports metrics of itself Rabbitmq node only reports metrics of itself by default Apr 30, 2018
@@ -86,6 +86,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di
- Don't stop Metricbeat if aerospike server is down. {pull}6874[6874]
- disk reads and write count metrics in RabbitMQ queue metricset made optional. {issue}6876[6876]
- Add mapping for docker metrics per cpu. {pull}6843[6843]
- RabbitMQ node metricset only collects metrics of the instance it connects to, `node.mode: all` can be used to collect all nodes as before. {issue}6556[6556] {pull}6971[6971]
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if we should move it to breaking changes.

Copy link
Member

Choose a reason for hiding this comment

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

Going forth and back on this too. It is a breaking change but because the previous implementation was a bug instead of a feature.

We could move it under breaking change but mention there that it was a bug?

@@ -1 +1,10 @@
This is the `node` metricset of the RabbitMQ module.

It collects metrics of nodes, it has two modes that can be selected with the
Copy link
Member

Choose a reason for hiding this comment

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

This is the node metricset of the RabbitMQ module and collects metrics about RabbitMQ nodes.

The metricset has two modes to collect data which can be selected with the node.mode setting:

It collects metrics of nodes, it has two modes that can be selected with the
`node.mode` setting:

* `self`: collects metrics only from the node from whose endpoint `metricbeat`
Copy link
Member

Choose a reason for hiding this comment

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

collects metrics only from the node metricbeat is connected to.

Should we add a note here that the recommended one is localhost? In the docker case multiple nodes will be configured in the hosts but still self should be used.

* `self`: collects metrics only from the node from whose endpoint `metricbeat`
is collecting metrics. This is the default, and the recommended mode when
`metricbeat` is deployed in the same node as the RabbitMQ server.
* `all`: collects metrics from all the nodes. This is recommended when
Copy link
Member

Choose a reason for hiding this comment

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

Should we call the config node.collection and the options are node or cluster. I'm trying to find an other name for mode that better describes what it does and the config option on what data it collects. Either it's only from the node or from all nodes / cluster. Writing this perhaps node and all would fit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, changing to node.collect with values node and cluster.

}

// Fetch metrics from all rabbitmq nodes in the cluster
func (m *AllMetricSet) Fetch() ([]common.MapStr, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of using 2 different MetricSet types we could move the Metricset to the reporter interface instead (see elasticsearch metricsets). Like this we would not have to make a difference if one or multiple events are reported.

@jsoriano jsoriano added in progress Pull request is currently in progress. and removed review labels May 8, 2018
@@ -27,33 +33,113 @@ func init() {
)
}

type MetricSet struct {
// NodeMetricSet is the MetricSet type used when node.collect is "node"
type NodeMetricSet struct {

Choose a reason for hiding this comment

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

type name will be used as node.NodeMetricSet by other packages, and that stutters; consider calling this MetricSet

@jsoriano
Copy link
Member Author

jsoriano commented May 9, 2018

Implemented using reporter V2 api now.

func eventMapping(node map[string]interface{}) (common.MapStr, *s.Errors) {
return schema.Apply(node)
func eventMapping(r mb.ReporterV2, node map[string]interface{}) {
event, _ := schema.Apply(node)
Copy link
Member Author

Choose a reason for hiding this comment

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

I tried not to ignore errors here, but Apply is returning an error that seems like an empty list of missing fields (Literally: "Required fields are missing: "). This happens also with the existing code, so this is not a regression. I leave investigating this for a future PR.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we need a better general approach here. LGTM for now. Check out my recent changes in the elasticsearch module. There I use the errors for testing purpose only.

@jsoriano jsoriano force-pushed the rabbitmq-self-node branch 2 times, most recently from 7fd0bde to ed5c789 Compare May 9, 2018 16:49
@jsoriano jsoriano added review and removed in progress Pull request is currently in progress. labels May 11, 2018
@ruflin
Copy link
Member

ruflin commented May 11, 2018

jenkins, test this

@jsoriano jsoriano force-pushed the rabbitmq-self-node branch 2 times, most recently from 9ea5ee9 to 19fab91 Compare May 15, 2018 08:32
A configuration option is added, `node.collect` that can be set to
`cluster` to have the previous behaviour. The default is `node`.
@ruflin ruflin merged commit f85dbf8 into elastic:master May 15, 2018
stevea78 pushed a commit to stevea78/beats that referenced this pull request May 20, 2018
A configuration option is added, `node.collect` that can be set to
`cluster` to have the previous behaviour. The default is `node`.
stevea78 pushed a commit to stevea78/beats that referenced this pull request May 20, 2018
A configuration option is added, `node.collect` that can be set to
`cluster` to have the previous behaviour. The default is `node`.
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.

3 participants