Search code examples
amazon-web-servicesrabbitmqprometheusamazon-mq

How to fetch AmazonMQ nodes for RabbitMQ brokers using API, CLI or Terraform


I'm trying to create AWS Cloudwatch alarm for systemCpuUtilizaiton of each RabbitMQ broker nodes via Terraform. To create the AWS Cloudwatch alarm, I need to provide dimensions (node-name and broker) as mentioned in AWS docs.

Hence, I'm looking to fetch the rabbitMQ broker node-names from AWS (via CLI, or API or Terraform)

Please note: I'm able to see the matrices of each broker nodes in AWS Cloudwatch console, but not from API, SDK or CLI.

I went through the below links but didn't get anything handy https://awscli.amazonaws.com/v2/documentation/api/latest/reference/mq/index.html#cli-aws-mq https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/mq_broker

Please let me know in case I'm missing something.


Solution

  • I have raised the above-mentioned problem to AWS support, below is the solution:

    First of all response from AWS team, AmazonMQ-RabbitMQ broker nodes are managed internally by AWS and currently its not exposed via API or SDK.

    As a result there is NO way to fetch the Rabbit MQ broker node name via API or SDK. Hence its not possible to directly create cloudwatch alarm on Rabbit MQ broker node's systemCpuUtilizaiton, as node name are required dimensions for creating the alert.

    There are two alternative solutions

    1. Query RabbitMQ API to fetch the node-name
    2. Use prometheus/cloudwatch-exporter, to fetch the matrices details from cloud watch where node names are available.

    I have used the second method, below values file to fetch the matrices we are interested

    prometheus-cloudwatch-exporter:
        namespace: monitoring
        enabled: true
        override:
          metrics:
            alb: false
            rds: false
            # ... based on requirement
          alerts:
            ec2: false # based on requirement
          additionalMetrics: |-
            # below configuration will fetch the martics,
            # containing Rabbit MQ broker node names
            - aws_namespace: AWS/AmazonMQ
              aws_metric_name: SystemCpuUtilization
              aws_dimensions: [Broker, Node]
              aws_statistics: [Average]
    
    

    If everything is configured correctly, you should be able to aws_amazonmq_system_cpu_utilization_average martic in prometheus as shown below. Now use Prometheus Alert manager to create alerts on top of this matrics. enter image description here