groups:
- name: next-gen-tiflash-kernel-governance.rules
  rules:
  - alert: TiFlashCPUCoreUsageOver80NextGen
    expr: |-
      100
        *
          max by (tenant_id, tidb_cluster_id, cluster_id, sharedpool_id) (
              sum by (tenant_id, tidb_cluster_id, cluster_id, sharedpool_id, instance) (
                rate(tiflash_proxy_process_cpu_seconds_total{component=~".*tiflash.*", job=~".*tiflash.*"}[2m])
              )
              /
              on(tenant_id, tidb_cluster_id, cluster_id, sharedpool_id, instance)
              tiflash_proxy_tikv_server_cpu_cores_quota{component=~".*tiflash.*", job=~".*tiflash.*"}
          )
      >
        80
    for: 5m
    labels:
      tier: next-gen
      severity: major
      response_class: ticket
      component: tiflash
      stability_governance: next-gen-kernel-governance
      visibility: internal
      source_component: tiflash
      oncall_team: tiflash
    annotations:
      summary: TiFlash single node CPU usage over 80%
      description: 'TiFlash single node CPU usage exceeds 80% of total core usage. cluster: {{ $labels.cluster_id }}, value: {{ $value }}'
  - alert: TiFlashDowntimeOver30MinNextGen
    expr: up{component=~".*tiflash.*",job=~".*tiflash.*"} == 0
    for: 30m
    labels:
      tier: next-gen
      severity: critical
      response_class: page
      component: tiflash
      stability_governance: next-gen-kernel-governance
      visibility: internal
      source_component: tiflash
      oncall_team: tiflash
    annotations:
      summary: '{{ $labels.component }} server has been down for over 30 minutes'
      description: 'Cluster: {{ $labels.cluster_id }}, Instance: {{ $labels.instance }} (Component: {{ $labels.component }}) is down for more than 30 minutes.'
