---
version: v1
display_name: AWS S3 Request Metrics
namespace: AWS/S3
disabled: true   # deep-grain profile ({BucketName, FilterId}); opt in with rules[].profiles.include
query:
  period: 1m
# S3 request metrics are opt-in per bucket (a CloudWatch metrics configuration) and are billed at
# CloudWatch custom-metric rates. This profile collects nothing until request metrics are enabled on
# the bucket. See: https://docs.aws.amazon.com/AmazonS3/latest/userguide/metrics-dimensions.html
instance:
  dimensions:
    - name: BucketName
      label: bucket_name
    - name: FilterId
      label: filter_id
metrics:
  - id: all_requests
    metric_name: AllRequests
    statistics: [sum]
    rate: true
  - id: get_requests
    metric_name: GetRequests
    statistics: [sum]
    rate: true
  - id: put_requests
    metric_name: PutRequests
    statistics: [sum]
    rate: true
  - id: delete_requests
    metric_name: DeleteRequests
    statistics: [sum]
    rate: true
  - id: head_requests
    metric_name: HeadRequests
    statistics: [sum]
    rate: true
  - id: errors_4xx
    metric_name: 4xxErrors
    statistics: [sum]
    rate: true
  - id: errors_5xx
    metric_name: 5xxErrors
    statistics: [sum]
    rate: true
  - id: first_byte_latency
    metric_name: FirstByteLatency
    statistics: [average]
  - id: total_request_latency
    metric_name: TotalRequestLatency
    statistics: [average]
  - id: bytes_downloaded
    metric_name: BytesDownloaded
    statistics: [sum]
    rate: true
  - id: bytes_uploaded
    metric_name: BytesUploaded
    statistics: [sum]
    rate: true
  # ----------------------------------------------------------------------------------------
  # Opt-in metrics (disabled by default). Select them through rules[].metrics.
  # All are published at the
  # {BucketName, FilterId} grain, so no other change is needed.
  # ----------------------------------------------------------------------------------------
  - id: list_requests
    disabled: true
    metric_name: ListRequests
    statistics: [sum]
    rate: true
  - id: post_requests
    disabled: true
    metric_name: PostRequests
    statistics: [sum]
    rate: true
  - id: select_requests
    disabled: true
    metric_name: SelectRequests
    statistics: [sum]
    rate: true
  # SelectBytesScanned / SelectBytesReturned are also published at this grain.
template:
  family: S3 Requests
  context_namespace: s3_requests
  chart_defaults:
    instances:
      by_labels: [account_id, region, bucket_name, filter_id]
  charts:
    - id: aws_cloudwatch_s3_requests
      context: requests
      title: S3 Requests
      family: Requests
      units: requests/s
      algorithm: absolute
      dimensions:
        - selector: all_requests_sum
          name: all
        - selector: get_requests_sum
          name: get
        - selector: put_requests_sum
          name: put
        - selector: delete_requests_sum
          name: delete
        - selector: head_requests_sum
          name: head
    - id: aws_cloudwatch_s3_request_errors
      context: request_errors
      title: S3 Request Errors
      family: Errors
      units: errors/s
      algorithm: absolute
      dimensions:
        - selector: errors_4xx_sum
          name: 4xx
        - selector: errors_5xx_sum
          name: 5xx
    - id: aws_cloudwatch_s3_request_latency
      context: request_latency
      title: S3 Request Latency
      family: Latency
      units: milliseconds
      algorithm: absolute
      dimensions:
        - selector: first_byte_latency_average
          name: first_byte
        - selector: total_request_latency_average
          name: total
    - id: aws_cloudwatch_s3_request_traffic
      context: request_traffic
      title: S3 Request Data Transfer
      family: Traffic
      units: bytes/s
      algorithm: absolute
      dimensions:
        - selector: bytes_downloaded_sum
          name: downloaded
        - selector: bytes_uploaded_sum
          name: uploaded
    # ----------------------------------------------------------------------------------------
    # Charts for the opt-in metrics above.
    # ----------------------------------------------------------------------------------------
    - id: aws_cloudwatch_s3_extra_requests
      context: extra_requests
      title: S3 List, Post, and Select Requests
      family: Requests
      units: requests/s
      algorithm: absolute
      dimensions:
        - selector: list_requests_sum
          name: list
        - selector: post_requests_sum
          name: post
        - selector: select_requests_sum
          name: select
