rabbitmq / rabbitmq-prometheus

A minimalistic Prometheus exporter of core RabbitMQ metrics
Other
147 stars 110 forks source link

Default RabbitMQ node/color labelling regex #33

Closed Aakcht closed 4 years ago

Aakcht commented 4 years ago

Hello, the documentation at https://www.rabbitmq.com/prometheus.html says:

Colour Labelling in Graphs All metrics on all graphs are associated with specific node names. For example, all metrics drawn in green are for the node that contains 0 in its name, e.g. rabbit@rmq0. This makes is easy to correlate metrics of a specific node across graphs. Metrics for the first node, which is assumed to contain 0 in its name, will always appear as green across all graphs. It is important to remember this aspect when using the RabbitMQ Overview dashboard. If a different node naming convention is used, the colours will appear inconsistent across graphs: green may represent e.g. rabbit@foo in one graph, and e.g. rabbit@bar in another graph. When this is the case, the panels must be updated to use a different node naming scheme.

According to the documentation, node naming scheme used in K8S deployment example should work. The nodename there is rabbit@$(MY_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.cluster.local , so assuming $MY_POD_NAMESPACE doesn't have any numbers in it , the colour labelling should work fine. But actually it doesn't work, because the regex used in the dashboards is /^rabbit@\w+0/ for zero node. Maybe it's possible to change the regex to something like /^rabbit@.*?0.*/, /^rabbit@.*?1.*/, etc ? With the change color labelling in the dashboards should work for with kubernetes deployments without additional changes in the dashboards.

michaelklishin commented 4 years ago

You are welcome to submit a PR with the proposed change. This is open source software after all ;)

@gerhard @dcorbacho is the regex we use at the moment intentional?

michaelklishin commented 4 years ago

And to be clear, this plugin or its Grafana dashboards are not specific to this peer discovery example. It would be nice to support some common naming patterns out of the box but the example is just that, an example of peer discovery on Kubernetes with an explicit production non-suitability disclaimer.

michaelklishin commented 4 years ago

@mkuratczyk is there a common node naming scheme you'd recommend?

Aakcht commented 4 years ago

Well assuming StatefulSet is used in Kubernetes, the node naming scheme will always look somewhat similar to the peer discovery example. I'll submit a PR then, I just want to be sure that it won't break something in non-kubernetes deployments.

Aakcht commented 4 years ago

After closer inspecion it turned out that the problem is only with - in pods names in statefulsets, and I think that it is also should be possible to have . in a nodename before pod number, so I added a PR that changes ^rabbit@\w+0 to ^rabbit@[\w.-]+0.