Skip to main content
Sumo Logic

Collect RabbitMQ Logs and Metrics for Kubernetes environments

This page explains how to collect RabbitMQ Logs and Metrics for Kubernetes environments.

In a Kubernetes environment, we use the Telegraf Operator, which is packaged with our Kubernetes collection. You can learn more about it here.The diagram below illustrates how data is collected from RabbitMQ in a Kubernetes environment. In the architecture shown below, there are four services that make up the metric collection pipeline: Telegraf, Prometheus, Fluentd and FluentBit.

The first service in the pipeline is Telegraf. Telegraf collects metrics from RabbitMQ. Note that we’re running Telegraf in each pod we want to collect metrics from as a sidecar deployment for example, Telegraf runs in the same pod as the containers it monitors. Telegraf uses the RabbitMQ input plugin to obtain metrics. (For simplicity, the diagram doesn’t show the input plugins.) The injection of the Telegraf sidecar container is done by the Telegraf Operator. We also have Fluentbit that collects logs written to standard out and forwards them to FluentD, which in turn sends all the logs and metrics data to a Sumo Logic HTTP Source.

Follow the below instructions to set up the metric collection:

  1. Configure Metrics Collection

    1. Setup Kubernetes Collection with the Telegraf operator

    2. Add annotations on your RabbitMQ pods

  2. Configure Logs Collection

    1. Configure logging in RabbitMQ.

    2. Add labels on your RabbitMQ pods to capture logs from standard output.

    3. Collecting RabbitMQ Logs from a Log file.

Prerequisites

It’s assumed that you are using the latest helm chart version if not upgrade using the instructions here.

Step 1 Configure Metrics Collection

This section explains the steps to collect RabbitMQ metrics from a Kubernetes environment.

In a Kubernetes environment, we use the Telegraf Operator, which is packaged with our Kubernetes collection. You can learn more on this here. Follow the steps listed below to collect metrics from a Kubernetes environment:

  1. Setup Kubernetes Collection with the Telegraf Operator.

  2. Add annotations on your RabbitMQ pods

On your RabbitMQ Pods, add the following annotations:.

  annotations:
    telegraf.influxdata.com/class: sumologic-prometheus
    prometheus.io/scrape: "true"
    prometheus.io/port: "9273"
    telegraf.influxdata.com/inputs: |+
[[inputs.rabbitmq]]
url = "http://localhost:15672"
username = "<username_CHANGE_ME>"
password = "<password_CHANGE_ME>"
insecure_skip_verify = false
queue_name_include = []
queue_name_exclude = []
[inputs.rabbitmq.tags]
     environment="prod_CHANGE_ME"
     component="messaging"
     messaging_system="rabbitmq"
     messaging_cluster="rabbitmq_on_k8s_CHANGE_ME"

Please enter values for the following parameters (marked in bold_CHANGE_ME above):

  • telegraf.influxdata.com/inputs - This contains the required configuration for the Telegraf RabbitMQ Input plugin. Please refer to this doc for more information on configuring the RabbitMQMongoDB input plugin for Telegraf. Note: As telegraf will be run as a sidecar the host should always be localhost.

    • In the input plugins section, which is [[inputs.rabbitmq]]: 

      • url - The URL of the RabbitMQ server for Management HTTP Endpoint. Please see this doc for more information on additional parameters for configuring the RabbitMQ input plugin for Telegraf.

      • username: The Username of RabbitMQ's admin account . The default is “guest”.

      • password:  The password of RabbitMQ's admin account. The default is “guest”.

    • In the tags section, which is [inputs.rabbitmq.tags]

      • environment - This is the deployment environment where the RabbitMQ cluster identified by the value of servers resides. For example: dev, prod or qa. While this value is optional we highly recommend setting it. 

      • messaging_cluster - Enter a name to identify this RabbitMQ cluster. This cluster name will be shown in the Sumo Logic dashboards. 

Here’s an explanation for additional values set by this configuration that we request you please do not modify as they will cause the Sumo Logic apps to not function correctly.

  • telegraf.influxdata.com/class: sumologic-prometheus - This instructs the Telegraf operator what output to use. This should not be changed.

  • prometheus.io/scrape: "true" - This ensures our Prometheus will scrape the metrics.

  • prometheus.io/port: "9273" - This tells prometheus what ports to scrape on. This should not be changed.

  • telegraf.influxdata.com/inputs

    • In the tags section, that is  [inputs.rabbitmq.tags]

      • component: “messaging” - This value is used by Sumo Logic apps to identify application components. 

      • messaging_system: “rabbitmq” - This value identifies the messaging system.

For all other parameters please see this doc for more properties that can be configured in the Telegraf agent globally.

  1. Sumo Logic Kubernetes collection will automatically start collecting metrics from the pods having the labels and annotations defined in the previous step. 

  2. Verify metrics in Sumo Logic.

Step 2 Configure Logs Collection

This section explains the steps to collect RabbitMQ logs from a Kubernetes environment.

  1. Add labels on your RabbitMQ pods to capture logs from standard output.

Make sure that the logs from RabbitMQ are sent to stdout. For more details see this doc.

Follow the instructions below to capture RabbitMQRabbitMQ logs from stdout on Kubernetes.

  1. Apply following labels to the RabbitMQ pods:

 labels:

    environment: "prod_CHANGE_ME"

    component: "messaging"

    messaging_system: "rabbitmq"

    messaging_cluster: "rabbitmq_on_k8s_CHANGE_ME

Enter in values for the following parameters (marked in bold_CHANGE_ME above):

  • environment. This is the deployment environment where the RabbitMQ cluster identified by the value of servers resides. For example: dev, prod or qa. While this value is optional we highly recommend setting it.
  • messsaging_cluster. Enter a name to identify this RabbitMQ cluster. This cluster name will be shown in the Sumo Logic dashboards.

Here’s an explanation for additional values set by this configuration that we request you do not modify as they will cause the Sumo Logic apps to not function correctly.

  • component: “messaging”. This value is used by Sumo Logic apps to identify application components.
  • messaging_system: “rabbitmq”. This value identifies the messaging system.

For all other parameters see this doc for more properties that can be configured in the Telegraf agent globally.

  1. (Optional) Collecting RabbitMQ Logs from a Log File

Follow the  steps below to capture RabbitMQ logs from a log file on Kubernetes.

  1. Determine the location of the RabbitMQ log file on Kubernetes. This can be determined from the RabbitMQ.conf for your RabbitMQ cluster along with the mounts on the RabbitMQ pods.

  2. Install the Sumo Logic tailing sidecar operator.

  3. Add the following annotation in addition to the existing annotations.

annotations:
  tailing-sidecar: sidecarconfig;<mount>:<path_of_RabbitMQ_log_file>/<RabbitMQ_log_file_name>

Example:

annotations:
  tailing-sidecar: sidecarconfig;data:/var/log/rabbitmq/rabbitmq.log
  1. Make sure that the RabbitMQ pods are running and annotations are applied by using the command: kubectl describe pod <RabbitMQ_pod_name>

  2. Sumo Logic Kubernetes collection will automatically start collecting logs from the pods having the annotations defined above.

 

  1. Add an FER to normalize the fields in Kubernetes environments

Labels created in Kubernetes environments automatically are prefixed with pod_labels. To normalize these for our app to work, we need to create a Field Extraction Rule if not already created for Messaging Application Components. To do so:

  1. Go to Manage Data > Logs > Field Extraction Rules.

  2. Click the + Add button on the top right of the table.

  3. The following form appears:

  1. Enter the following options:

  • Rule Name. Enter the name as App Observability - Messaging.
  • Applied At. Choose Ingest Time
  • Scope. Select Specific Data
    • Scope: Enter the following keyword search expression:
      pod_labels_environment=* pod_labels_component=messaging pod_labels_messaging_system=* pod_labels_messaging_cluster=*
  • Parse Expression.Enter the following parse expression:
  1. Click Save to create the rule.