---
version: v1
display_name: AWS Lambda
namespace: AWS/Lambda
query:
  period: 5m
instance:
  dimensions:
    - name: FunctionName
      label: function_name
metrics:
  - id: invocations
    metric_name: Invocations
    statistics: [sum]
    rate: true
  - id: errors
    metric_name: Errors
    statistics: [sum]
    rate: true
  - id: throttles
    metric_name: Throttles
    statistics: [sum]
    rate: true
  - id: duration
    metric_name: Duration
    statistics: [average, maximum, p90]
  # ----------------------------------------------------------------------------------------
  # Opt-in metrics (disabled by default). Select them through rules[].metrics.
  # All are published at the {FunctionName} grain, so no other change is needed.
  # ----------------------------------------------------------------------------------------
  - id: concurrent_executions
    disabled: true
    metric_name: ConcurrentExecutions
    statistics: [maximum]
  - id: dead_letter_errors
    disabled: true
    metric_name: DeadLetterErrors
    statistics: [sum]
    rate: true
  - id: iterator_age              # stream event-source (Kinesis / DynamoDB Streams) functions
    disabled: true
    metric_name: IteratorAge
    statistics: [maximum]
  # Also published at {FunctionName}: the provisioned-concurrency family (ProvisionedConcurrent-
  # Executions, ProvisionedConcurrencyUtilization, ...), async metrics (AsyncEventAge,
  # AsyncEventsDropped), DestinationDeliveryFailures, RecursiveInvocationsDropped. Event-source-
  # mapping metrics use the {EventSourceMappingUUID} grain and need their own profile. See:
  # https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics-types.html
template:
  family: Lambda
  context_namespace: lambda
  chart_defaults:
    instances:
      by_labels: [account_id, region, function_name]
  charts:
    - id: aws_cloudwatch_lambda_invocations
      context: invocations
      title: Lambda Invocations
      family: Invocations
      units: invocations/s
      algorithm: absolute
      dimensions:
        - selector: invocations_sum
          name: invocations
    - id: aws_cloudwatch_lambda_errors
      context: errors
      title: Lambda Errors and Throttles
      family: Errors
      units: events/s
      algorithm: absolute
      dimensions:
        - selector: errors_sum
          name: errors
        - selector: throttles_sum
          name: throttles
    - id: aws_cloudwatch_lambda_duration
      context: duration
      title: Lambda Duration
      family: Duration
      units: milliseconds
      algorithm: absolute
      dimensions:
        - selector: duration_average
          name: average
        - selector: duration_maximum
          name: maximum
        - selector: duration_p90
          name: p90
    # ----------------------------------------------------------------------------------------
    # Charts for the opt-in metrics above.
    # ----------------------------------------------------------------------------------------
    - id: aws_cloudwatch_lambda_concurrency
      context: concurrent_executions
      title: Lambda Concurrent Executions
      family: Concurrency
      units: executions
      algorithm: absolute
      dimensions:
        - selector: concurrent_executions_maximum
          name: concurrent
    - id: aws_cloudwatch_lambda_dead_letter_errors
      context: dead_letter_errors
      title: Lambda Dead Letter Errors
      family: Errors
      units: errors/s
      algorithm: absolute
      dimensions:
        - selector: dead_letter_errors_sum
          name: dead_letter
    - id: aws_cloudwatch_lambda_iterator_age
      context: iterator_age
      title: Lambda Iterator Age
      family: Streams
      units: milliseconds
      algorithm: absolute
      dimensions:
        - selector: iterator_age_maximum
          name: age
