---
version: v1
display_name: Amazon DocumentDB
namespace: AWS/DocDB
query:
  period: 5m
instance:
  dimensions:
    - name: DBInstanceIdentifier
      label: db_instance_identifier
metrics:
  - id: cpu_utilization
    metric_name: CPUUtilization
    statistics: [average]
  - id: freeable_memory
    metric_name: FreeableMemory
    statistics: [average]
  - id: database_connections
    metric_name: DatabaseConnections
    statistics: [average]
  - id: buffer_cache_hit_ratio
    metric_name: BufferCacheHitRatio
    statistics: [average]
  - id: read_iops
    metric_name: ReadIOPS
    statistics: [average]
  - id: write_iops
    metric_name: WriteIOPS
    statistics: [average]
  - id: read_latency
    metric_name: ReadLatency
    statistics: [average]
  - id: write_latency
    metric_name: WriteLatency
    statistics: [average]
  - id: read_throughput
    metric_name: ReadThroughput
    statistics: [average]
  - id: write_throughput
    metric_name: WriteThroughput
    statistics: [average]
  - id: db_instance_replica_lag
    metric_name: DBInstanceReplicaLag
    statistics: [average]
  - id: database_cursors_timed_out
    metric_name: DatabaseCursorsTimedOut
    statistics: [sum]
    rate: true
  # ----------------------------------------------------------------------------------------
  # Opt-in metrics (disabled by default). Select them through rules[].metrics.
  # All are published at the {DBInstanceIdentifier}
  # grain.
  # ----------------------------------------------------------------------------------------
  - id: swap_usage
    disabled: true
    metric_name: SwapUsage
    statistics: [average]
  - id: disk_queue_depth
    disabled: true
    metric_name: DiskQueueDepth
    statistics: [average]
  - id: documents_inserted
    disabled: true
    metric_name: DocumentsInserted
    statistics: [sum]
    rate: true
  - id: documents_deleted
    disabled: true
    metric_name: DocumentsDeleted
    statistics: [sum]
    rate: true
  # Opcounters (OpcountersInsert/Query/Update/Delete), transactions, and network-throughput metrics are
  # also per-instance. Cluster-shared volume metrics use {DBClusterIdentifier} (VolumeBytesUsed,
  # VolumeReadIOPs, ...) -- a separate profile. See:
  # https://docs.aws.amazon.com/documentdb/latest/developerguide/cloud_watch.html
template:
  family: DocumentDB
  context_namespace: docdb
  chart_defaults:
    instances:
      by_labels: [account_id, region, db_instance_identifier]
  charts:
    - id: aws_cloudwatch_docdb_cpu
      context: cpu
      title: DocumentDB CPU Utilization
      family: CPU
      units: percentage
      algorithm: absolute
      dimensions:
        - selector: cpu_utilization_average
          name: cpu
    - id: aws_cloudwatch_docdb_memory
      context: freeable_memory
      title: DocumentDB Freeable Memory
      family: Memory
      units: bytes
      algorithm: absolute
      dimensions:
        - selector: freeable_memory_average
          name: freeable
    - id: aws_cloudwatch_docdb_connections
      context: connections
      title: DocumentDB Connections
      family: Connections
      units: connections
      algorithm: absolute
      dimensions:
        - selector: database_connections_average
          name: connections
    - id: aws_cloudwatch_docdb_cache
      context: buffer_cache_hit_ratio
      title: DocumentDB Buffer Cache Hit Ratio
      family: Cache
      units: percentage
      algorithm: absolute
      dimensions:
        - selector: buffer_cache_hit_ratio_average
          name: hit_ratio
    - id: aws_cloudwatch_docdb_iops
      context: iops
      title: DocumentDB Disk IOPS
      family: Throughput
      units: ops/s
      algorithm: absolute
      dimensions:
        - selector: read_iops_average
          name: read
        - selector: write_iops_average
          name: write
    - id: aws_cloudwatch_docdb_latency
      context: latency
      title: DocumentDB Disk Latency
      family: Latency
      units: milliseconds
      algorithm: absolute
      dimensions:
        - selector: read_latency_average
          name: read
        - selector: write_latency_average
          name: write
    - id: aws_cloudwatch_docdb_throughput
      context: throughput
      title: DocumentDB Disk Throughput
      family: Throughput
      units: bytes/s
      algorithm: absolute
      dimensions:
        - selector: read_throughput_average
          name: read
        - selector: write_throughput_average
          name: write
    - id: aws_cloudwatch_docdb_replica_lag
      context: replica_lag
      title: DocumentDB Replica Lag
      family: Replication
      units: milliseconds
      algorithm: absolute
      dimensions:
        - selector: db_instance_replica_lag_average
          name: lag
    - id: aws_cloudwatch_docdb_cursors_timed_out
      context: cursors_timed_out
      title: DocumentDB Cursors Timed Out
      family: Cursors
      units: cursors/s
      algorithm: absolute
      dimensions:
        - selector: database_cursors_timed_out_sum
          name: timed_out
    # ----------------------------------------------------------------------------------------
    # Charts for the opt-in metrics above.
    # ----------------------------------------------------------------------------------------
    - id: aws_cloudwatch_docdb_documents
      context: documents
      title: DocumentDB Document Operations
      family: Operations
      units: documents/s
      algorithm: absolute
      dimensions:
        - selector: documents_inserted_sum
          name: inserted
        - selector: documents_deleted_sum
          name: deleted
    - id: aws_cloudwatch_docdb_swap
      context: swap_usage
      title: DocumentDB Swap Usage
      family: Memory
      units: bytes
      algorithm: absolute
      dimensions:
        - selector: swap_usage_average
          name: swap
    - id: aws_cloudwatch_docdb_disk_queue
      context: disk_queue_depth
      title: DocumentDB Disk Queue Depth
      family: Disk
      units: operations
      algorithm: absolute
      dimensions:
        - selector: disk_queue_depth_average
          name: queued
