---
version: v1
display_name: Amazon EBS
namespace: AWS/EBS
query:
  period: 5m
instance:
  dimensions:
    - name: VolumeId
      label: volume_id
metrics:
  - id: volume_read_bytes
    metric_name: VolumeReadBytes
    statistics: [sum]
    rate: true
  - id: volume_write_bytes
    metric_name: VolumeWriteBytes
    statistics: [sum]
    rate: true
  - id: volume_read_ops
    metric_name: VolumeReadOps
    statistics: [sum]
    rate: true
  - id: volume_write_ops
    metric_name: VolumeWriteOps
    statistics: [sum]
    rate: true
  - id: volume_queue_length
    metric_name: VolumeQueueLength
    statistics: [average]
  - id: volume_idle_time
    metric_name: VolumeIdleTime
    statistics: [sum]   # total idle seconds in the period (AWS: Average is not relevant, esp. for Nitro volumes)
  - id: burst_balance
    metric_name: BurstBalance
    statistics: [average]
  # ----------------------------------------------------------------------------------------
  # Opt-in metrics (disabled by default). Select them through rules[].metrics.
  # All are published at the {VolumeId} grain.
  # ----------------------------------------------------------------------------------------
  - id: volume_total_read_time       # total seconds of read ops; divide by read ops for latency
    disabled: true
    metric_name: VolumeTotalReadTime
    statistics: [sum]
    rate: true
  - id: volume_total_write_time
    disabled: true
    metric_name: VolumeTotalWriteTime
    statistics: [sum]
    rate: true
  - id: volume_throughput_percentage  # Provisioned IOPS SSD (io1/io2) only
    disabled: true
    metric_name: VolumeThroughputPercentage
    statistics: [average]
  - id: volume_consumed_read_write_ops  # Provisioned IOPS SSD (io1/io2) only
    disabled: true
    metric_name: VolumeConsumedReadWriteOps
    statistics: [sum]
    rate: true
  # Nitro-only per-volume metrics (VolumeAvgIOPS, VolumeAvgReadLatency, VolumeIOPSExceededCheck, ...)
  # and instance-aggregate EBS (AWS/EC2 + InstanceId: EBSReadBytes/EBSWriteBytes/... -- see the ec2
  # profile) are separate. VolumeStalledIOCheck is available through the disabled ebs_stalled_io
  # profile. See:
  # https://docs.aws.amazon.com/ebs/latest/userguide/using_cloudwatch_ebs.html
  # BurstBalance is emitted only for gp2/st1/sc1 volumes.
template:
  family: EBS
  context_namespace: ebs
  chart_defaults:
    instances:
      by_labels: [account_id, region, volume_id]
  charts:
    - id: aws_cloudwatch_ebs_throughput
      context: throughput
      title: EBS Volume Throughput
      family: Throughput
      units: bytes/s
      algorithm: absolute
      dimensions:
        - selector: volume_read_bytes_sum
          name: read
        - selector: volume_write_bytes_sum
          name: write
    - id: aws_cloudwatch_ebs_iops
      context: iops
      title: EBS Volume IOPS
      family: Throughput
      units: ops/s
      algorithm: absolute
      dimensions:
        - selector: volume_read_ops_sum
          name: read
        - selector: volume_write_ops_sum
          name: write
    - id: aws_cloudwatch_ebs_queue_length
      context: queue_length
      title: EBS Volume Queue Length
      family: Queue
      units: operations
      algorithm: absolute
      dimensions:
        - selector: volume_queue_length_average
          name: queued
    - id: aws_cloudwatch_ebs_idle_time
      context: idle_time
      title: EBS Volume Idle Time
      family: Activity
      units: seconds
      algorithm: absolute
      dimensions:
        - selector: volume_idle_time_sum
          name: idle
    - id: aws_cloudwatch_ebs_burst_balance
      context: burst_balance
      title: EBS Volume Burst Balance
      family: Credits
      units: percentage
      algorithm: absolute
      dimensions:
        - selector: burst_balance_average
          name: balance
    # ----------------------------------------------------------------------------------------
    # Charts for the opt-in metrics above.
    # ----------------------------------------------------------------------------------------
    - id: aws_cloudwatch_ebs_io_time
      context: io_time
      title: EBS Volume I/O Time
      family: Latency
      units: seconds/s
      algorithm: absolute
      dimensions:
        - selector: volume_total_read_time_sum
          name: read
        - selector: volume_total_write_time_sum
          name: write
    - id: aws_cloudwatch_ebs_throughput_percentage
      context: throughput_percentage
      title: EBS Volume Throughput Percentage
      family: Throughput
      units: percentage
      algorithm: absolute
      dimensions:
        - selector: volume_throughput_percentage_average
          name: throughput
    - id: aws_cloudwatch_ebs_consumed_ops
      context: consumed_ops
      title: EBS Volume Consumed Read/Write Ops
      family: Throughput
      units: ops/s
      algorithm: absolute
      dimensions:
        - selector: volume_consumed_read_write_ops_sum
          name: consumed
