---
version: v1
display_name: Amazon Kinesis Data Streams
namespace: AWS/Kinesis
query:
  period: 5m
instance:
  dimensions:
    - name: StreamName
      label: stream_name
metrics:
  - id: incoming_bytes
    metric_name: IncomingBytes
    statistics: [sum]
    rate: true
  - id: incoming_records
    metric_name: IncomingRecords
    statistics: [sum]
    rate: true
  - id: get_records_bytes
    metric_name: GetRecords.Bytes
    statistics: [sum]
    rate: true
  - id: get_records_records
    metric_name: GetRecords.Records
    statistics: [sum]
    rate: true
  - id: get_records_iterator_age
    metric_name: GetRecords.IteratorAgeMilliseconds
    statistics: [maximum]
  - id: get_records_latency
    metric_name: GetRecords.Latency
    statistics: [average]
  - id: put_record_latency
    metric_name: PutRecord.Latency
    statistics: [average]
  - id: put_records_latency
    metric_name: PutRecords.Latency
    statistics: [average]
  - id: read_throughput_exceeded
    metric_name: ReadProvisionedThroughputExceeded
    statistics: [average]
  - id: write_throughput_exceeded
    metric_name: WriteProvisionedThroughputExceeded
    statistics: [average]
  - id: put_records_failed
    metric_name: PutRecords.FailedRecords
    statistics: [sum]
    rate: true
  - id: put_records_throttled
    metric_name: PutRecords.ThrottledRecords
    statistics: [sum]
    rate: true
  # ----------------------------------------------------------------------------------------
  # Opt-in metrics (disabled by default). Select them through rules[].metrics.
  # All are published at the {StreamName} grain.
  # ----------------------------------------------------------------------------------------
  - id: put_record_bytes
    disabled: true
    metric_name: PutRecord.Bytes
    statistics: [sum]
    rate: true
  - id: put_records_bytes
    disabled: true
    metric_name: PutRecords.Bytes
    statistics: [sum]
    rate: true
  # Enhanced SHARD-level metrics use the {StreamName, ShardId} grain (opt-in via
  # EnableEnhancedMonitoring, billed as custom metrics); enhanced fan-out consumers use
  # {StreamName, ConsumerName}. Both need their own profile. See:
  # https://docs.aws.amazon.com/streams/latest/dev/monitoring-with-cloudwatch.html
template:
  family: Kinesis
  context_namespace: kinesis
  chart_defaults:
    instances:
      by_labels: [account_id, region, stream_name]
  charts:
    - id: aws_cloudwatch_kinesis_throughput
      context: throughput
      title: Kinesis Data Throughput
      family: Throughput
      units: bytes/s
      algorithm: absolute
      dimensions:
        - selector: incoming_bytes_sum
          name: incoming
        - selector: get_records_bytes_sum
          name: outgoing
    - id: aws_cloudwatch_kinesis_records
      context: records
      title: Kinesis Records
      family: Records
      units: records/s
      algorithm: absolute
      dimensions:
        - selector: incoming_records_sum
          name: incoming
        - selector: get_records_records_sum
          name: outgoing
    - id: aws_cloudwatch_kinesis_iterator_age
      context: iterator_age
      title: Kinesis GetRecords Iterator Age
      family: Consumers
      units: milliseconds
      algorithm: absolute
      dimensions:
        - selector: get_records_iterator_age_maximum
          name: iterator_age
    - id: aws_cloudwatch_kinesis_latency
      context: latency
      title: Kinesis Operation Latency
      family: Latency
      units: milliseconds
      algorithm: absolute
      dimensions:
        - selector: get_records_latency_average
          name: get_records
        - selector: put_record_latency_average
          name: put_record
        - selector: put_records_latency_average
          name: put_records
    - id: aws_cloudwatch_kinesis_throttling
      context: throughput_exceeded
      title: Kinesis Throughput Exceeded
      family: Throttling
      units: events
      algorithm: absolute
      dimensions:
        - selector: read_throughput_exceeded_average
          name: read
        - selector: write_throughput_exceeded_average
          name: write
    - id: aws_cloudwatch_kinesis_put_errors
      context: put_errors
      title: Kinesis PutRecords Rejected
      family: Errors
      units: records/s
      algorithm: absolute
      dimensions:
        - selector: put_records_failed_sum
          name: failed
        - selector: put_records_throttled_sum
          name: throttled
    # ----------------------------------------------------------------------------------------
    # Charts for the opt-in metrics above.
    # ----------------------------------------------------------------------------------------
    - id: aws_cloudwatch_kinesis_put_bytes
      context: put_bytes
      title: Kinesis Put Bytes
      family: Throughput
      units: bytes/s
      algorithm: absolute
      dimensions:
        - selector: put_record_bytes_sum
          name: put_record
        - selector: put_records_bytes_sum
          name: put_records
