---
# Global defaults, applied to all receivers where not explicitly overridden.
# Optional.
defaults:
  # API access fields.
  # api_url: https://jira.tidbcloud.com/
  # MIGRATE RELATED: user and password
  api_url: https://tidb.atlassian.net/
  # MIGRATE RELATED: user and password
  user: charles.m@pingcap.com
  password: ${JIRA_PASSWORD}
  # personal_access_token: NzA4MjQ5NTE2NjY5OrhikLI528+hZgX8pEO7pwiH7P3O
  # The type of JIRA issue to create. Required.
  issue_type: Task
  # Issue priority. Optional.
  priority: Warning
  # Go template invocation for generating the summary. Required.
  summary: '{{ template "jira.summary" . }}'
  # Go template invocation for generating the description. Optional.
  description: '{{ template "jira.description" . }}'
  # State to transition into when reopening a closed issue. Required.
  reopen_state: "Reopen"
  # Do not reopen issues with this resolution. Optional.
  wont_fix_resolution: "Won't Fix"
  # Amount of time after being closed that an issue should be reopened
  # after which, a new issue is created.
  # Optional (default: always reopen)
  reopen_duration: 24h
  components: ['{{ template "jira.component_map" . }}']
  sub_task_type: Sub-task
  auto_resolve:
    state: "Done"

# Receiver definitions. At least one must be defined.
receivers:
  # Must match the Alertmanager receiver name. Required.
  - &jiralert-prod-warning
    name: 'default/observability-alertmanager-config/jiralert-prod-warning'
    # JIRA project to create the issue in. Required.
    project: O11Y
    priority: Warning
    summary: '[PROD]{{ template "jira.summary" . }}'
    components: ['{{ template "jira.component_map" . }}']
    # Copy all Prometheus labels into separate JIRA labels.
    # Optional (default: false).
    add_group_labels: false
    # create_only: true
    comment_changelog: true
    custom_group_labels:
      default: ['alertname', 'cluster_id', 'tenant', 'cluster', 'namespace', 'severity', 'tidb_cluster_id']
      extended:
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            quota-exporter: ['resource']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            data-migration: ['job_id']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            ticdc: ['changefeed']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            tidb: ['instance']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            tikv: ['instance']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            pd: ['instance']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            tiflash: ['instance']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            cluster-ng-service: ['task_name']
        - extracted: '{{ template "jira.summary" . }}'
          conditions:
            RegionalUpgradeOperationTimeout: ['name']
    custom_group_duration: 4h
    # MIGRATE RELATED
    fields:
      # tenant id
      customfield_10157: '{{ template "jira.tenant_id" . }}'
      # cluster id
      customfield_10149: '{{ template "jira.cluster_id" . }}'
      # raw alert data
      customfield_10160: '{{ template "jira.raw_alert_data" . }}'
  - &jiralert-prod-major
    name: 'default/observability-alertmanager-config/jiralert-prod-major'
    # JIRA project to create the issue in. Required.
    project: O11Y
    priority: Major
    summary: '[PROD]{{ template "jira.summary" . }}'
    components: ['{{ template "jira.component_map" . }}']
    # Copy all Prometheus labels into separate JIRA labels.
    # Optional (default: false).
    add_group_labels: false
    # create_only: true
    comment_changelog: true
    custom_group_labels:
      default: ['alertname', 'cluster_id', 'tenant', 'cluster', 'namespace', 'severity', 'tidb_cluster_id']
      extended:
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            quota-exporter: ['resource']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            data-migration: ['job_id']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            ticdc: ['changefeed']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            tidb: ['instance']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            tikv: ['instance']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            pd: ['instance']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            tiflash: ['instance']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            cluster-ng-service: ['task_name']
        - extracted: '{{ template "jira.summary" . }}'
          conditions:
            RegionalUpgradeOperationTimeout: ['name']
        - extracted: '{{ template "jira.summary" . }}'
          conditions:
            ClusterCRScalingDurationTooLong: ['name']
    custom_group_duration: 4h
    fields:
      # tenant id
      customfield_10157: '{{ template "jira.tenant_id" . }}'
      # cluster id
      customfield_10149: '{{ template "jira.cluster_id" . }}'
      # raw alert data
      customfield_10160: '{{ template "jira.raw_alert_data" . }}'
  - &jiralert-prod
    name: 'default/observability-alertmanager-config/jiralert-prod'
    # JIRA project to create the issue in. Required.
    project: O11Y
    priority: Critical
    summary: '[PROD]{{ template "jira.summary" . }}'
    components: ['{{ template "jira.component_map" . }}']
    # Copy all Prometheus labels into separate JIRA labels.
    # Optional (default: false).
    add_group_labels: false
    # create_only: true
    comment_changelog: true
    custom_group_labels:
      default: ['alertname', 'cluster_id', 'tenant', 'cluster', 'namespace', 'severity', 'tidb_cluster_id']
      extended:
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            quota-exporter: ['resource']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            data-migration: ['job_id']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            ticdc: ['changefeed']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            tidb: ['instance']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            tikv: ['instance']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            pd: ['instance']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            tiflash: ['instance']
        - extracted: '{{ template "jira.component_map" . }}'
          conditions:
            cluster-ng-service: ['task_name']
        - extracted: '{{ template "jira.summary" . }}'
          conditions:
            RegionalUpgradeOperationTimeout: ['name']
        - extracted: '{{ template "jira.summary" . }}'
          conditions:
            ClusterCRScalingDurationTooLong: ['name']
    custom_group_duration: 4h
    fields:
      # tenant id
      customfield_10157: '{{ template "jira.tenant_id" . }}'
      # cluster id
      customfield_10149: '{{ template "jira.cluster_id" . }}'
      # raw alert data
      customfield_10160: '{{ template "jira.raw_alert_data" . }}'

  # Aliases without the Prometheus Operator prefix
  # (default/observability-alertmanager-config/). Kept alongside the prefixed
  # receivers so both names resolve during the upstream migration. Each entry
  # below is identical to its anchored counterpart above except for `name`.
  - <<: *jiralert-prod-warning
    name: 'jiralert-prod-warning'
  - <<: *jiralert-prod-major
    name: 'jiralert-prod-major'
  - <<: *jiralert-prod
    name: 'jiralert-prod'

# File containing template definitions. Required.
template: jiralert.tmpl
distributed_locks:
  - 'jiralert-eks-cache-prod-gfdics.serverless.usw1.cache.amazonaws.com:6379'
distributed_locks_timeout: 30s
db_dsn: ${DB_DSN}
clinic_addr: "https://clinic.pingcap.com/clinic/api/v1/dashboard/clusters2?cluster_id="
clinic_token: ${CLINIC_TOKEN}
event_url: "https://e4hr1v4oqh.execute-api.us-west-2.amazonaws.com/activities/"
event_source: "eventbus"
event_key: ${EVENT_KEY}
precheck_path: "/app/config/prod/precheck.yml"
# API access fields.
api_url: https://tidb.atlassian.net/
# MIGRATE RELATED: user and password
user: charles.m@pingcap.com
password: ${JIRA_PASSWORD}