---
version: v1
display_name: AWS SQS
namespace: AWS/SQS
query:
  period: 5m
instance:
  dimensions:
    - name: QueueName
      label: queue_name
metrics:
  - id: number_of_messages_sent
    metric_name: NumberOfMessagesSent
    statistics: [sum]
    rate: true
  - id: number_of_messages_received
    metric_name: NumberOfMessagesReceived
    statistics: [sum]
    rate: true
  - id: number_of_messages_deleted
    metric_name: NumberOfMessagesDeleted
    statistics: [sum]
    rate: true
  - id: number_of_empty_receives
    metric_name: NumberOfEmptyReceives
    statistics: [sum]
    rate: true
  - id: approximate_age_of_oldest_message
    metric_name: ApproximateAgeOfOldestMessage
    statistics: [maximum]
  - id: sent_message_size
    metric_name: SentMessageSize
    statistics: [average]
  - id: approximate_number_of_messages_visible
    metric_name: ApproximateNumberOfMessagesVisible
    statistics: [average]
  - id: approximate_number_of_messages_not_visible
    metric_name: ApproximateNumberOfMessagesNotVisible
    statistics: [average]
  - id: approximate_number_of_messages_delayed
    metric_name: ApproximateNumberOfMessagesDelayed
    statistics: [average]
  # ----------------------------------------------------------------------------------------
  # Opt-in metrics (disabled by default). Select them through rules[].metrics.
  # Both are published at the {QueueName} grain (FIFO queues only), so no other change is needed.
  # ----------------------------------------------------------------------------------------
  - id: number_of_deduplicated_sent_messages
    disabled: true
    metric_name: NumberOfDeduplicatedSentMessages
    statistics: [sum]
    rate: true
  - id: approximate_number_of_groups_with_inflight_messages
    disabled: true
    metric_name: ApproximateNumberOfGroupsWithInflightMessages
    statistics: [average]
  # Fair-queue metrics (ApproximateNumberOfNoisyGroups, *InQuietGroups) are also published at
  # {QueueName} when fair queues are used. See:
  # https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-available-cloudwatch-metrics.html
template:
  family: SQS
  context_namespace: sqs
  chart_defaults:
    instances:
      by_labels: [account_id, region, queue_name]
  charts:
    - id: aws_cloudwatch_sqs_message_throughput
      context: message_throughput
      title: SQS Message Throughput
      family: Messages
      units: messages/s
      algorithm: absolute
      dimensions:
        - selector: number_of_messages_sent_sum
          name: sent
        - selector: number_of_messages_received_sum
          name: received
        - selector: number_of_messages_deleted_sum
          name: deleted
    - id: aws_cloudwatch_sqs_empty_receives
      context: empty_receives
      title: SQS Empty Receives
      family: Messages
      units: receives/s
      algorithm: absolute
      dimensions:
        - selector: number_of_empty_receives_sum
          name: empty
    - id: aws_cloudwatch_sqs_queue_depth
      context: queue_depth
      title: SQS Queue Depth
      family: Queue
      units: messages
      algorithm: absolute
      dimensions:
        - selector: approximate_number_of_messages_visible_average
          name: visible
        - selector: approximate_number_of_messages_not_visible_average
          name: not_visible
        - selector: approximate_number_of_messages_delayed_average
          name: delayed
    - id: aws_cloudwatch_sqs_oldest_message_age
      context: oldest_message_age
      title: SQS Age of Oldest Message
      family: Queue
      units: seconds
      algorithm: absolute
      dimensions:
        - selector: approximate_age_of_oldest_message_maximum
          name: age
    - id: aws_cloudwatch_sqs_message_size
      context: message_size
      title: SQS Sent Message Size
      family: Messages
      units: bytes
      algorithm: absolute
      dimensions:
        - selector: sent_message_size_average
          name: size
    # ----------------------------------------------------------------------------------------
    # Charts for the opt-in metrics above.
    # ----------------------------------------------------------------------------------------
    - id: aws_cloudwatch_sqs_deduplicated_messages
      context: deduplicated_messages
      title: SQS Deduplicated Sent Messages
      family: Messages
      units: messages/s
      algorithm: absolute
      dimensions:
        - selector: number_of_deduplicated_sent_messages_sum
          name: deduplicated
    - id: aws_cloudwatch_sqs_inflight_groups
      context: inflight_message_groups
      title: SQS Message Groups With Inflight Messages
      family: Queue
      units: groups
      algorithm: absolute
      dimensions:
        - selector: approximate_number_of_groups_with_inflight_messages_average
          name: groups
