---
extractors:
  component: "{{ with .JiraWebhookEvent.Issue.Fields.Components }}{{ (index . 0).Name }}{{ end }}"
  project: "{{ .JiraWebhookEvent.Issue.Fields.Project.Key }}"
  priority: "{{ .JiraWebhookEvent.Issue.Fields.Priority.Name }}"
  type: "{{ .JiraWebhookEvent.Issue.Fields.Type.Name }}"
  webhook_event: "{{ .JiraWebhookEvent.WebhookEvent }}"
  changed_fields: "{{range .JiraWebhookEvent.Changelog.Items}}<{{.Field}}>{{end}}"
  summary: "{{ .JiraWebhookEvent.Issue.Fields.Summary }}"
  # MIGRATE RELATED, done
  alert_required: "{{ with .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10223 }}{{ .value }}{{ end }}"
  alarm: "{{ with .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10150 }}{{ .value }}{{ end }}"
  account_code: "{{ .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10217 }}"
  visibility: "{{ (.JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10160 | tryUnmarshalJson).labels.visibility }}"
  status_cat: "{{ .JiraWebhookEvent.Issue.Fields.Status.StatusCategory.Key }}"
  provider_type: "{{ (.JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10160 | tryUnmarshalJson).labels.provider_type }}"
  o11y_biz_type: "{{ (.JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10160 | tryUnmarshalJson).labels.o11y_biz_type }}"
  tenant_id: "{{ .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10157 }}"
  cluster_id: "{{ .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10149 }}"
  alertname: "{{ (.JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10160 | tryUnmarshalJson).labels.alertname }}"
  kind: "{{ .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10159 }}"
  cluster_name: "{{ .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10162 }}"
  tier: "{{ (.JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10160 | tryUnmarshalJson).labels.tier }}"
  daytime: "{{if isDayTime}}day{{else}}night{{end}}"
  ticket_environment: "{{ with .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10050 }}{{ .value }}{{ end }}"
  tidbcloud_org_asset: "{{ with .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10110 }}{{ (index . 0).objectId }}{{ end }}"
  o11y_project_id: "{{ (.JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10160 | tryUnmarshalJson).labels.o11y_project_id }}"
routes:
  # Daytime subset demo for cloudfb special path.
  # Replace alertname regex with your real subset.
  - receiver: cloudfb-day-hu-special
    continue: false
    match:
      project: ^O11YDEV$
      webhook_event: jira:issue_created
      summary: ^CLOUDFB$
      daytime: ^day$
      alertname: ^(DiskUsageTooHigh|CPUSaturationHigh)$
  - receiver: cloudfb
    continue: true
    match:
      project: ^O11YDEV$
      webhook_event: jira:issue_created
      summary: ^CLOUDFB$
  - receiver: cloudfb-leader
    continue: false
    match:
      project: ^O11YDEV$
      webhook_event: jira:issue_created
      summary: ^CLOUDFB$
  - receiver: test-notify-card
    continue: false
    match:
      project: ^O11YDEV$
      webhook_event: jira:issue_created
      summary: ^TESTNOTIFY$
  - receiver: test-multi-escalate
    continue: false
    match:
      project: ^O11YDEV$
      webhook_event: jira:issue_created
      summary: ^TESTMULTIESCALATE$
  - receiver: test
    continue: true
    match:
      project: ^O11YDEV$
      webhook_event: jira:issue_created
      summary: ^TEST

  - receiver: test-infra-staging
    continue: true
    match:
      project: ^O11YSTAG$
      webhook_event: jira:issue_created
      type: ^Task$
      priority: Critical|Major|Warning
      tenant_id: ^1369847559692509618$
  - receiver: platform-staging-dev
    continue: true
    match:
      project: ^(TCASTAG|TCADEV|O11YSTAG|O11YDEV)$
      webhook_event: jira:issue_created
      type: ^Task$
      priority: Critical|Major|Warning
      component: ^(api-gateway|dataservice)$
  - receiver: account-staging-dev
    continue: true
    match:
      project: ^(TCASTAG|TCADEV|O11YSTAG|O11YDEV)$
      webhook_event: jira:issue_created
      type: ^Task$
      priority: Critical|Major|Warning
      component: ^account-server$
  - receiver: billing-staging-dev
    continue: true
    match:
      project: ^(TCASTAG|TCADEV|O11YSTAG|O11YDEV)$
      webhook_event: jira:issue_created
      type: ^Task$
      priority: Critical|Major|Warning
      component: ^(billing-server)$
  - receiver: auto-staging-dev
    continue: true
    match:
      project: ^(O11YSTAG|O11YDEV)$
      webhook_event: jira:issue_created
      type: ^Task$
      priority: Critical|Major|Warning
      component: ^(observability-global-server|observability-regional-server|o11y|vmagent|loki|thanos|metrics-server|alertmanager|ngmonitoring|chaos-svc|chaos-provider)$
  - receiver: serverless-staging-dev
    continue: true
    match:
      project: ^(TCASTAG|TCADEV|O11YSTAG|O11YDEV)$
      webhook_event: jira:issue_created
      type: ^Task$
      priority: Critical|Major|Warning
      provider_type: ^aws-free-tier$
      "!o11y_project_id": us-east-1-f02
  - receiver: serverless-staging-dev
    continue: true
    match:
      project: ^(TCASTAG|TCADEV|O11YSTAG|O11YDEV)$
      webhook_event: jira:issue_created
      type: ^Task$
      priority: Critical|Major|Warning
      o11y_biz_type: devtier$
      "!o11y_project_id": us-east-1-f02
  - receiver: aipower-dev
    continue: true
    match:
      project: ^(O11YSTAG|O11YDEV)$
      webhook_event: jira:issue_created
      type: ^Task$
      component: ^aipower$
  - receiver: dev-dp
    continue: true
    match:
      project: ^(O11YSTAG|O11YDEV)$
      webhook_event: jira:issue_created
      type: ^Task$
      component: ^(br|lightning|dm|ticdc|import/export)$
      priority: Critical|Major
      "!visibility": ^external$
  - receiver: oncall-assign
    continue: true
    match:
      project: ^O11YDEV$
      webhook_event: jira:issue_updated
      changed_fields: <priority>
      component: resilience-test
  - receiver: oncall
    continue: true
    match:
      project: ^O11YDEV$
      webhook_event: jira:issue_updated
      changed_fields: <assignee>|<priority>
      "!priority": ^(P0|P1)$
      "!status_cat": "done"
      summary: ^ONCALLT$
  - receiver: oncall
    continue: true
    match:
      project: ^O11YDEV$
      webhook_event: jira:issue_created
      priority: ^(P0|P1)$
      alert_required: ^No$
      "!status_cat": "done"
      summary: ^ONCALLT$
  - receiver: next-gen-cc
    continue: true
    match:
      project: ^(O11YDEV|O11YSTAG)$
      webhook_event: jira:issue_created
      type: ^Task$
      priority: Critical|Major
      component: ^(dataplane-controller|next-gen-br)$
  - receiver: next-gen-cluster-service-cc
    continue: true
    match:
      project: ^(O11YDEV|O11YSTAG)$
      webhook_event: jira:issue_created
      type: ^Task$
      priority: Critical|Major
      component: ^(cluster-ng-service|ng-auto-scaler|)$
  # - receiver: next-gen-cc-kernel
  #   continue: true
  #   match:
  #     project: ^(O11YSTAG)$
  #     webhook_event: jira:issue_created
  #     type: ^Task$
  #     priority: Critical|Major
  #     component: ^(pd|tikv|tiflash|ticdc|tidb|tiproxy|tidb-worker|br|next-gen-br-kernel|resilience|ticdc-kernel)$
  #     "!tenant_id": ^(1369847559692509643|1369847559692509653|1369847559692509647)$
  #     tier: next-gen
  #     "!cluster_id": ^(9|1983334640806526976)
  - receiver: guardian-alert
    continue: true
    match:
      project: ^(O11YDEV|O11YSTAG)$
      webhook_event: jira:issue_created
      type: ^Task$
      priority: Critical|Major
      alertname: ^(Total|Max)Ti(DB|KV|Flash)(Memory|CPU)UsageTooHigh$
      tenant_id: ^(1372813089209061633|1372813089209238420|1372813089209256793)$
  # - receiver: next-gen-assign
  #   continue: true
  #   match:
  #     project: ^(O11YDEV|O11YSTAG)$
  #     webhook_event: jira:issue_created
  #     type: ^Task$
  #     priority: Critical|Major
  #     component: ^(pd|tikv|tiflash|ticdc|tidb|tiproxy|tidb-worker|br|next-gen-br-kernel)$
  #     tier: next-gen
  #     "!tenant_id": ^(1369847559692509643|1369847559692509653|1369847559692509647)$
  #     "!cluster_id": ^9
  - receiver: big3-http-forward
    continue: true
    match:
      project: ^O11YDEV$
      webhook_event: jira:issue_created
      type: ^Task$
      summary: ^BIG3HTTPFORWARD$
  # - receiver: next-gen-assign
  #   continue: true
  #   match:
  #     project: ^(O11YSTAG)$
  #     webhook_event: jira:issue_created
  #     type: ^Task$
  #     priority: Critical|Major
  #     component: ^(pd|tikv|tiflash|ticdc|tidb|tiproxy|tidb-worker|br|next-gen-br-kernel)$
  #     tier: next-gen
  #     "!tenant_id": ^(1369847559692509643|1369847559692509653|1369847559692509647)$
  #     "!cluster_id": ^(9|1983334640806526976)
  - receiver: next-gen-import-cc
    continue: true
    match:
      project: ^(O11YDEV|O11YSTAG)$
      webhook_event: jira:issue_created
      type: ^Task$
      component: ^next-gen-import$
  - receiver: next-gen-stg-cc
    continue: true
    match:
      project: ^O11YSTAG$
      webhook_event: jira:issue_created
      type: ^Task$
      component: ^dataplane-controller$
  # tidbcloud org asset mapping
  # wetech - 43824
  # bingoplus - 280501/467201
  # - receiver: guardian-jsm-ticket
  #   continue: true
  #   match:
  #     project: ^(TCID|ST)$
  #     ticket_environment: ^test$
  #     webhook_event: jira:issue_created
  #     tidbcloud_org_asset: ^(43824|280501|467201)$
  - receiver: regression_test
    continue: true
    match:
      project: ^(TCASTAG|TCADEV|O11YSTAG|O11YDEV)$
      webhook_event: jira:issue_created
      type: ^Task$
      priority: Critical|Major|Warning
      provider_type: ^aws-free-tier$
      o11y_project_id: us-east-1-f02
  - receiver: regression_test
    continue: true
    match:
      project: ^(TCASTAG|TCADEV|O11YSTAG|O11YDEV)$
      webhook_event: jira:issue_created
      type: ^Task$
      priority: Critical|Major|Warning
      o11y_biz_type: devtier$
      o11y_project_id: us-east-1-f02