groups:
# Be cautious to change the group name unless you know what you are doing
- name: ticdc-customer
  rules:
  - alert: TiCDCCheckpointHighDelay
    expr: ticdc_owner_checkpoint_ts_lag{} > 600
    for: 1m
    labels:
      tier: serverless
      visibility: external
      severity: major
      component: ticdc
      ruleID: "10"
      status : active
      canEdit : all
      monitorTarget: "Changefeed latency"
      operator: "is larger than {threshold} seconds"
      description: Changefeed latency is more than {threshold} seconds
      message: |
        The latency of Changefeed {{ $labels.changefeed }} of <a href="https://TiDBCloudDomainName/clusters/{{ $labels.cluster_id }}/changefeed">instance TiDBClusterName</a> is more than {threshold} seconds.
        Check the changefeed status in the Changefeed Page and Changefeed Detail Page of the TiDB Cloud console, where you can find some error messages to help diagnose this issue.
        Possible reasons that can trigger this alert include:
        1. The overall traffic in the upstream has increased, causing the existing changefeed specification to be insufficient to handle it.
           If the traffic increase is temporary, the changefeed latency will automatically recover after the traffic returns to normal.
           If the traffic increase is continuous, you need to scale up the changefeed.
        2. The downstream or network is abnormal. In this case, resolve this abnormality first.
        3. Tables lack indexes if the downstream is RDS, which might cause low write performance and high latency. In this case, you need to add the necessary indexes to the upstream or downstream.
        If the problem cannot be fixed from your side, you can contact TiDB Cloud Support for further assistance.
    annotations:
      message: |
        The latency of Changefeed {{ $labels.changefeed }} of <a href="https://TiDBCloudDomainName/clusters/{{ $labels.cluster_id }}/changefeed">instance TiDBClusterName</a> is more than {threshold} seconds.
        Check the changefeed status in the Changefeed Page and Changefeed Detail Page of the TiDB Cloud console, where you can find some error messages to help diagnose this issue.
        Possible reasons that can trigger this alert include:
        1. The overall traffic in the upstream has increased, causing the existing changefeed specification to be insufficient to handle it.
           If the traffic increase is temporary, the changefeed latency will automatically recover after the traffic returns to normal.
           If the traffic increase is continuous, you need to scale up the changefeed.
        2. The downstream or network is abnormal. In this case, resolve this abnormality first.
        3. Tables lack indexes if the downstream is RDS, which might cause low write performance and high latency. In this case, you need to add the necessary indexes to the upstream or downstream.
        If the problem cannot be fixed from your side, you can contact TiDB Cloud Support for further assistance.
      description: Changefeed latency is more than {threshold} seconds
  - alert: ChangefeedIsFailed
    expr: ticdc_owner_status{} == 2
    labels:
      tier: serverless
      visibility: external
      severity: critical
      component: ticdc
      ruleID: "15"
      status: active
      canEdit: status
      monitorTarget: "Changefeed status"
      operator: "is failed"
      description: Changefeed status is failed
      message: >
        The status of Changefeed {{ $labels.changefeed }} of <a href="https://TiDBCloudDomainName/clusters/{{ $labels.cluster_id }}/changefeed">instance TiDBClusterName</a> is failed.
        Check the changefeed status in the Changefeed Page and Changefeed Detail Page of the TiDB Cloud console, where you can find some error messages to help diagnose this issue.
        If the problem cannot be fixed from your side, you can contact TiDB Cloud Support for further assistance.
    annotations:
      message: >
        The status of Changefeed {{ $labels.changefeed }} of <a href="https://TiDBCloudDomainName/clusters/{{ $labels.cluster_id }}/changefeed">instance TiDBClusterName</a> is failed.
        Check the changefeed status in the Changefeed Page and Changefeed Detail Page of the TiDB Cloud console, where you can find some error messages to help diagnose this issue.
        If the problem cannot be fixed from your side, you can contact TiDB Cloud Support for further assistance.
      description: Changefeed status is failed
  - alert: ChangefeedIsWarning
    expr: ticdc_owner_status{} == 6
    for: 5m
    labels:
      tier: serverless
      visibility: external
      severity: major
      component: ticdc
      ruleID: "20"
      status: active
      canEdit: status
      monitorTarget: "Changefeed status"
      operator: "is warning"
      description: Changefeed status is warning
      message: >
        The status of Changefeed {{ $labels.changefeed }} of <a href="https://TiDBCloudDomainName/clusters/{{ $labels.cluster_id }}/changefeed">instance TiDBClusterName</a> is warning.
        Check the changefeed status in the Changefeed Page and Changefeed Detail Page of the TiDB Cloud console, where you can find some error messages to help diagnose this issue.
        If the problem cannot be fixed from your side, you can contact TiDB Cloud Support for further assistance.
    annotations:
      message: >
        The status of Changefeed {{ $labels.changefeed }} of <a href="https://TiDBCloudDomainName/clusters/{{ $labels.cluster_id }}/changefeed">instance TiDBClusterName</a> is warning.
        Check the changefeed status in the Changefeed Page and Changefeed Detail Page of the TiDB Cloud console, where you can find some error messages to help diagnose this issue.
        If the problem cannot be fixed from your side, you can contact TiDB Cloud Support for further assistance.
      description: Changefeed status is warning
