resource "datadog_dashboard" "aws_step_functions_prod_dashboard" {
  description = <<-EOT
            This dashboard shows you performance and status metrics for state machines running with AWS Step Functions, and focuses on steps that invoke AWS Lambda functions. See Datadog's documentation on the [AWS Step Functions integration](https://docs.datadoghq.com/integrations/amazon_step_functions/).
            If your state machine is running [activities](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-activities.html), metrics are available for per-activity status and execution time—clone and customize this dashboard to add them.
        EOT
  layout_type = "free"
  title       = "AWS Step Functions (PROD)"
  url         = "/dashboard/q3v-eg4-af9/aws-step-functions-prod"
  template_variable {
    defaults = ["323555055331"]
    name     = "scope"
    prefix   = "aws_account"
  }
  template_variable {
    defaults = ["*"]
    name     = "statemachinearn"
    prefix   = "mdc.delphi.etl.apps.appname"
  }
  template_variable {
    defaults = ["*"]
    name     = "lambdafunctionarn"
    prefix   = "lambdafunctionarn"
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      show_legend = false
      title       = "Average execution time by state machine"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "line"
        on_right_yaxis = false
        q              = "avg:aws.states.execution_time{$scope,$statemachinearn,$lambdafunctionarn} by {statemachinearn}"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 0
      y               = 69
    }
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      show_legend = false
      title       = "p95 execution time by state machine"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "line"
        on_right_yaxis = false
        q              = "avg:aws.states.execution_time.p95{$scope,$statemachinearn,$lambdafunctionarn} by {statemachinearn}"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 0
      y               = 53
    }
  }
  widget {
    toplist_definition {
      title       = "Slowest state machines (p95 execution time)"
      title_align = "left"
      title_size  = "16"
      request {
        q = "top(avg:aws.states.execution_time.p95{$scope,$statemachinearn,$lambdafunctionarn} by {statemachinearn}, 10, 'mean', 'desc')"
        style {
          palette = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 0
      y               = 37
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      precision   = 2
      title       = "Slowest execution"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "max"
        q          = "max:aws.states.execution_time.maximum{$scope,$statemachinearn,$lambdafunctionarn}"
        conditional_formats {
          comparator = ">="
          hide_value = false
          palette    = "white_on_red"
          value      = 0
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 15
      x               = 0
      y               = 21
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      precision   = 2
      title       = "Fastest execution"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "min"
        q          = "min:aws.states.execution_time.minimum{$scope,$statemachinearn,$lambdafunctionarn}"
        conditional_formats {
          comparator = ">="
          hide_value = false
          palette    = "white_on_green"
          value      = 0
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 15
      x               = 16
      y               = 21
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      precision   = 2
      title       = "Avg execution"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "avg"
        q          = "avg:aws.states.execution_time{$scope,$statemachinearn,$lambdafunctionarn}"
        conditional_formats {
          comparator = ">="
          hide_value = false
          palette    = "white_on_gray"
          value      = 0
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 15
      x               = 32
      y               = 21
    }
  }
  widget {
    note_definition {
      background_color = "gray"
      content          = "State machine execution time"
      font_size        = "18"
      has_padding      = false
      show_tick        = true
      text_align       = "center"
      tick_edge        = "bottom"
      tick_pos         = "50%"
    }
    widget_layout {
      height          = 6
      is_column_break = false
      width           = 47
      x               = 0
      y               = 14
    }
  }
  widget {
    note_definition {
      background_color = "gray"
      content          = "State machine execution issues"
      font_size        = "18"
      has_padding      = false
      show_tick        = true
      text_align       = "left"
      tick_edge        = "bottom"
      tick_pos         = "50%"
    }
    widget_layout {
      height          = 6
      is_column_break = false
      width           = 47
      x               = 49
      y               = 40
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      precision   = 2
      title       = "Aborted"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "sum"
        q          = "sum:aws.states.executions_aborted{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        conditional_formats {
          comparator = ">"
          hide_value = false
          palette    = "white_on_red"
          value      = 0
        }
        conditional_formats {
          comparator = "<"
          hide_value = false
          palette    = "white_on_green"
          value      = 1
        }
      }
    }
    widget_layout {
      height          = 11
      is_column_break = false
      width           = 11
      x               = 49
      y               = 47
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      precision   = 2
      title       = "Failed"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "sum"
        q          = "sum:aws.states.executions_failed{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        conditional_formats {
          comparator = ">"
          hide_value = false
          palette    = "white_on_red"
          value      = 0
        }
        conditional_formats {
          comparator = "<"
          hide_value = false
          palette    = "white_on_green"
          value      = 1
        }
      }
    }
    widget_layout {
      height          = 11
      is_column_break = false
      width           = 11
      x               = 85
      y               = 47
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      precision   = 2
      title       = "Throttled"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "sum"
        q          = "sum:aws.states.execution_throttled{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        conditional_formats {
          comparator = ">"
          hide_value = false
          palette    = "white_on_red"
          value      = 0
        }
        conditional_formats {
          comparator = "<"
          hide_value = false
          palette    = "white_on_green"
          value      = 1
        }
      }
    }
    widget_layout {
      height          = 11
      is_column_break = false
      width           = 11
      x               = 61
      y               = 47
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      precision   = 2
      title       = "Timed out"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "sum"
        q          = "sum:aws.states.executions_timed_out{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        conditional_formats {
          comparator = ">"
          hide_value = false
          palette    = "white_on_red"
          value      = 0
        }
        conditional_formats {
          comparator = "<"
          hide_value = false
          palette    = "white_on_green"
          value      = 1
        }
      }
    }
    widget_layout {
      height          = 11
      is_column_break = false
      width           = 11
      x               = 73
      y               = 47
    }
  }
  widget {
    image_definition {
      has_background = false
      has_border     = false
      sizing         = "center"
      url            = "https://static.datadoghq.com/static/images/saas_logos/bot/amazon_step_functions.png"
    }
    widget_layout {
      height          = 12
      is_column_break = false
      width           = 47
      x               = 0
      y               = 0
    }
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      show_legend = false
      title       = "Executions started"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "bars"
        on_right_yaxis = false
        q              = "sum:aws.states.executions_started{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 49
      y               = 7
    }
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      show_legend = false
      title       = "Executions succeeded"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "bars"
        on_right_yaxis = false
        q              = "sum:aws.states.executions_succeeded{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 49
      y               = 23
    }
  }
  widget {
    note_definition {
      background_color = "gray"
      content          = "Steps running Lambda functions"
      font_size        = "18"
      has_padding      = false
      show_tick        = true
      text_align       = "center"
      tick_edge        = "bottom"
      tick_pos         = "50%"
    }
    widget_layout {
      height          = 6
      is_column_break = false
      width           = 95
      x               = 98
      y               = 52
    }
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      show_legend = false
      title       = "p95 run time by step"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "area"
        on_right_yaxis = false
        q              = "avg:aws.states.lambda_function_time.p95{$scope,$statemachinearn,$lambdafunctionarn} by {stepname}"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 98
      y               = 59
    }
  }
  widget {
    toplist_definition {
      title       = "Slowest steps (p95 run time)"
      title_align = "left"
      title_size  = "16"
      request {
        q = "top(avg:aws.states.lambda_function_time.p95{$scope,$statemachinearn,$lambdafunctionarn} by {stepname}, 10, 'mean', 'desc')"
        style {
          palette = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 146
      y               = 59
    }
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      show_legend = false
      title       = "p95 schedule time by step"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "area"
        on_right_yaxis = false
        q              = "avg:aws.states.lambda_function_schedule_time.p95{$scope,$statemachinearn,$lambdafunctionarn} by {stepname}"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 98
      y               = 75
    }
  }
  widget {
    toplist_definition {
      title       = "Slowest steps (p95 schedule time)"
      title_align = "left"
      title_size  = "16"
      request {
        q = "top(avg:aws.states.lambda_function_schedule_time.p95{$scope,$statemachinearn,$lambdafunctionarn} by {stepname}, 10, 'mean', 'desc')"
        style {
          palette = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 146
      y               = 75
    }
  }
  widget {
    note_definition {
      background_color = "gray"
      content          = "Lambda state execution status"
      font_size        = "18"
      has_padding      = false
      show_tick        = true
      text_align       = "left"
      tick_edge        = "bottom"
      tick_pos         = "50%"
    }
    widget_layout {
      height          = 6
      is_column_break = false
      width           = 47
      x               = 98
      y               = 0
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      precision   = 2
      title       = "Failed"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "sum"
        q          = "sum:aws.states.lambda_functions_failed{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        conditional_formats {
          comparator = ">"
          hide_value = false
          palette    = "white_on_red"
          value      = 0
        }
        conditional_formats {
          comparator = "<"
          hide_value = false
          palette    = "white_on_green"
          value      = 1
        }
      }
    }
    widget_layout {
      height          = 11
      is_column_break = false
      width           = 11
      x               = 147
      y               = 7
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      precision   = 2
      title       = "Timed out"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "sum"
        q          = "sum:aws.states.lambda_functions_timed_out{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        conditional_formats {
          comparator = ">"
          hide_value = false
          palette    = "white_on_red"
          value      = 0
        }
        conditional_formats {
          comparator = "<"
          hide_value = false
          palette    = "white_on_green"
          value      = 1
        }
      }
    }
    widget_layout {
      height          = 11
      is_column_break = false
      width           = 11
      x               = 159
      y               = 7
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      precision   = 2
      title       = "Started"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "sum"
        q          = "sum:aws.states.lambda_functions_started{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        conditional_formats {
          comparator = ">="
          hide_value = false
          palette    = "white_on_gray"
          value      = 0
        }
      }
    }
    widget_layout {
      height          = 11
      is_column_break = false
      width           = 11
      x               = 122
      y               = 7
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      precision   = 2
      title       = "Scheduled"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "sum"
        q          = "sum:aws.states.lambda_functions_scheduled{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        conditional_formats {
          comparator = ">="
          hide_value = false
          palette    = "white_on_gray"
          value      = 0
        }
      }
    }
    widget_layout {
      height          = 11
      is_column_break = false
      width           = 11
      x               = 110
      y               = 7
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      precision   = 2
      title       = "Succeeded"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "sum"
        q          = "sum:aws.states.lambda_functions_succeeded{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        conditional_formats {
          comparator = ">"
          hide_value = false
          palette    = "white_on_green"
          value      = 0
        }
        conditional_formats {
          comparator = "<"
          hide_value = false
          palette    = "white_on_gray"
          value      = 1
        }
      }
    }
    widget_layout {
      height          = 11
      is_column_break = false
      width           = 11
      x               = 98
      y               = 7
    }
  }
  widget {
    note_definition {
      background_color = "gray"
      content          = "State machine execution status"
      font_size        = "18"
      has_padding      = false
      show_tick        = true
      text_align       = "center"
      tick_edge        = "bottom"
      tick_pos         = "50%"
    }
    widget_layout {
      height          = 6
      is_column_break = false
      width           = 47
      x               = 49
      y               = 0
    }
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      show_legend = false
      title       = "State machine executions with issues (by issue)"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "bars"
        on_right_yaxis = false
        q              = "sum:aws.states.executions_aborted{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
      request {
        display_type   = "bars"
        on_right_yaxis = false
        q              = "sum:aws.states.executions_failed{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
      request {
        display_type   = "bars"
        on_right_yaxis = false
        q              = "sum:aws.states.execution_throttled{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
      request {
        display_type   = "bars"
        on_right_yaxis = false
        q              = "sum:aws.states.executions_timed_out{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 49
      y               = 82
    }
  }
  widget {
    toplist_definition {
      title       = "State machines with the most execution issues"
      title_align = "left"
      title_size  = "16"
      request {
        q = "top(sum:aws.states.executions_failed{$scope,$statemachinearn,$lambdafunctionarn} by {statemachinearn}.as_count()+sum:aws.states.executions_aborted{$scope,$statemachinearn,$lambdafunctionarn} by {statemachinearn}.as_count()+sum:aws.states.execution_throttled{$scope,$statemachinearn,$lambdafunctionarn} by {statemachinearn}.as_count()+sum:aws.states.executions_timed_out{$scope,$statemachinearn,$lambdafunctionarn} by {statemachinearn}.as_count(),10,'sum','desc')"
        style {
          palette = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 49
      y               = 66
    }
  }
  widget {
    toplist_definition {
      title       = "Lambda steps with the most failures or timeouts"
      title_align = "left"
      title_size  = "16"
      request {
        q = "top(sum:aws.states.lambda_functions_failed{$scope,$statemachinearn,$lambdafunctionarn} by {lambdafunctionarn}.as_count()+sum:aws.states.lambda_functions_timed_out{$scope,$statemachinearn,$lambdafunctionarn} by {lambdafunctionarn}.as_count(),10,'sum','desc')"
        style {
          palette = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 147
      y               = 19
    }
  }
  widget {
    note_definition {
      background_color = "yellow"
      content          = "Includes aborted, failed, throttled, and timed out executions"
      font_size        = "14"
      has_padding      = false
      show_tick        = true
      text_align       = "left"
      tick_edge        = "bottom"
      tick_pos         = "50%"
    }
    widget_layout {
      height          = 6
      is_column_break = false
      width           = 47
      x               = 49
      y               = 59
    }
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      show_legend = false
      title       = "Lambda state executions with failures or timeouts"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "bars"
        on_right_yaxis = false
        q              = "sum:aws.states.lambda_functions_failed{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
      request {
        display_type   = "bars"
        on_right_yaxis = false
        q              = "sum:aws.states.lambda_functions_timed_out{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 147
      y               = 35
    }
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      show_legend = false
      title       = "Lambda state executions succeeded"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "bars"
        on_right_yaxis = false
        q              = "sum:aws.states.lambda_functions_succeeded{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 98
      y               = 35
    }
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      show_legend = false
      title       = "Lambda state executions started"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "bars"
        on_right_yaxis = false
        q              = "sum:aws.states.lambda_functions_started{$scope,$statemachinearn,$lambdafunctionarn}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 98
      y               = 19
    }
  }
  widget {
    note_definition {
      background_color = "gray"
      content          = "Lambda state execution issues"
      font_size        = "18"
      has_padding      = false
      show_tick        = true
      text_align       = "left"
      tick_edge        = "bottom"
      tick_pos         = "50%"
    }
    widget_layout {
      height          = 6
      is_column_break = false
      width           = 47
      x               = 147
      y               = 0
    }
  }
}

resource "datadog_dashboard" "prod_delphi_sfn_dashboard" {
  description = <<-EOT
      This dashboard reports the performance and usage of your AWS Lambda functions, helping you optimize them and monitor your billable execution time. Further reading on monitoring AWS Lambda:

      - [How to monitor Lambda functions](https://www.datadoghq.com/blog/how-to-monitor-lambda-functions/)

      - [Datadog's Lambda Layer: Monitor custom serverless metrics](https://www.datadoghq.com/blog/datadog-lambda-layer/)

      - [Datadog's AWS Lambda integration docs](https://docs.datadoghq.com/integrations/amazon_lambda/)

      Clone this template dashboard to make changes and add your own graph widgets.
        EOT
  layout_type = "free"
  title       = "Prod Delphi SFN"
  url         = "/dashboard/hrt-hzf-3m4/prod-delphi-sfn"
  template_variable {
    defaults = ["*"]
    name     = "function"
    prefix   = "functionname"
  }
  template_variable {
    defaults = ["*"]
    name     = "region"
    prefix   = "region"
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      live_span   = "1d"
      show_legend = false
      title       = "Started/Failed/Succeded"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "line"
        on_right_yaxis = false
        q              = "avg:aws.states.executions_started{platform:delphi,environment:production} by {statemachinearn}.as_count()"
        style {
          line_type  = "dashed"
          line_width = "thin"
          palette    = "grey"
        }
      }
      request {
        display_type   = "line"
        on_right_yaxis = false
        q              = "avg:aws.states.executions_succeeded{platform:delphi,environment:production} by {statemachinearn}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "cool"
        }
      }
      request {
        display_type   = "line"
        on_right_yaxis = false
        q              = "avg:aws.states.executions_failed{platform:delphi,environment:production} by {statemachinearn}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "orange"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 70
      y               = 7
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      live_span   = "1h"
      precision   = 2
      title       = "Throttled invocation attempts"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "avg"
        q          = "avg:aws.states.execution_throttled{platform:delphi,environment:production}.as_count()"
      }
    }
    widget_layout {
      height          = 10
      is_column_break = false
      width           = 21
      x               = 0
      y               = 31
    }
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      live_span   = "1d"
      show_legend = false
      title       = "Average execution time by step machine"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "area"
        on_right_yaxis = false
        q              = "avg:aws.states.execution_time{platform:delphi,environment:production} by {statemachinearn}"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 22
      y               = 7
    }
  }
  widget {
    note_definition {
      background_color = "gray"
      content          = "Invocations"
      font_size        = "18"
      has_padding      = false
      show_tick        = true
      text_align       = "center"
      tick_edge        = "bottom"
      tick_pos         = "50%"
    }
    widget_layout {
      height          = 5
      is_column_break = false
      width           = 47
      x               = 70
      y               = 0
    }
  }
  widget {
    note_definition {
      background_color = "gray"
      content          = "Errors"
      font_size        = "18"
      has_padding      = false
      show_tick        = true
      text_align       = "center"
      tick_edge        = "bottom"
      tick_pos         = "50%"
    }
    widget_layout {
      height          = 5
      is_column_break = false
      width           = 47
      x               = 22
      y               = 23
    }
  }
  widget {
    note_definition {
      background_color = "gray"
      content          = "Execution time"
      font_size        = "18"
      has_padding      = false
      show_tick        = true
      text_align       = "center"
      tick_edge        = "bottom"
      tick_pos         = "50%"
    }
    widget_layout {
      height          = 5
      is_column_break = false
      width           = 47
      x               = 22
      y               = 0
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      live_span   = "1d"
      precision   = 2
      title       = "Cumulative execution time"
      title_align = "center"
      title_size  = "16"
      request {
        aggregator = "sum"
        q          = "avg:aws.states.execution_time{environment:production,platform:delphi} by {service}"
      }
    }
    widget_layout {
      height          = 9
      is_column_break = false
      width           = 21
      x               = 0
      y               = 0
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      live_span   = "1d"
      precision   = 2
      title       = "Errors"
      title_align = "center"
      title_size  = "16"
      request {
        aggregator = "sum"
        q          = "sum:aws.states.executions_failed{platform:delphi,environment:production}.as_count()"
        conditional_formats {
          comparator = ">"
          hide_value = false
          palette    = "white_on_red"
          value      = 5
        }
        conditional_formats {
          comparator = "<="
          hide_value = false
          palette    = "white_on_green"
          value      = 5
        }
      }
    }
    widget_layout {
      height          = 9
      is_column_break = false
      width           = 21
      x               = 0
      y               = 20
    }
  }
  widget {
    timeseries_definition {
      legend_size = "0"
      live_span   = "1d"
      show_legend = false
      title       = "Failures"
      title_align = "left"
      title_size  = "16"
      request {
        display_type   = "bars"
        on_right_yaxis = false
        q              = "avg:aws.states.executions_failed{platform:delphi,environment:production}.as_count()"
        style {
          line_type  = "solid"
          line_width = "normal"
          palette    = "dog_classic"
        }
      }
    }
    widget_layout {
      height          = 15
      is_column_break = false
      width           = 47
      x               = 22
      y               = 30
    }
  }
  widget {
    query_value_definition {
      autoscale   = true
      live_span   = "1d"
      precision   = 2
      title       = "Succeded"
      title_align = "left"
      title_size  = "16"
      request {
        aggregator = "sum"
        q          = "sum:aws.states.executions_succeeded{platform:delphi,environment:production}.as_count()"
      }
    }
    widget_layout {
      height          = 9
      is_column_break = false
      width           = 21
      x               = 0
      y               = 10
    }
  }
}
