groups:
- name: pd/pd-sche-server
  rules:
  - alert: SchedServerHighCPU
    expr: (sum(rate(container_cpu_usage_seconds_total{namespace="tidb-serverless", pod=~"pd-sche-server-.*", container!="POD", container!=""}[2m])) by (pod) / sum(kube_pod_container_resource_limits{namespace="tidb-serverless", pod=~"pd-sche-server-.*", resource="cpu"}) by (pod)) > 0.7
    for: 2m
    labels:
      severity: critical
      response_class: page
      tier: serverless
      provider_type: aws-free-tier
      component: pd
      oncall_team: serverless
    annotations:
      message: 'region: {{ $labels.region }}, instance: {{ $labels.instance }}'
      runbook_url:
      value: '{{ $value }}'
      summary: "Shed Server CPU usage exceeds the threshold"
  - alert: SchedServerCPUThrottled
    expr: (sum(rate(container_cpu_cfs_throttled_periods_total{namespace="tidb-serverless", pod=~"pd-sche-server-.*", container!="POD", container!=""}[2m])) by (pod) / sum(rate(container_cpu_cfs_periods_total{namespace="tidb-serverless", pod=~"pd-sche-server-.*", container!="POD", container!=""}[2m])) by (pod)) > 0.3
    for: 2m
    labels:
      severity: critical
      response_class: page
      tier: serverless
      provider_type: aws-free-tier
      component: pd
      oncall_team: serverless
    annotations:
      message: 'region: {{ $labels.region }}, pod: {{ $labels.pod }}, CPU throttle ratio is {{ $value | humanizePercentage }}, exceeds 30% threshold.'
      runbook_url:
      value: '{{ $value }}'
      summary: "Sched Server CPU throttling exceeds the threshold"
  - alert: SchedServerHighMemory
    expr: (sum(container_memory_working_set_bytes{namespace="tidb-serverless", pod=~"pd-sche-server-.*", container!="POD", container!="", image!=""}) by (namespace, pod) / sum(kube_pod_container_resource_limits{namespace="tidb-serverless", pod=~"pd-sche-server-.*", resource="memory"}) by (namespace, pod)) > 0.7
    for: 2m
    labels:
      severity: major
      response_class: ticket
      tier: serverless
      provider_type: aws-free-tier
      component: pd
      oncall_team: serverless
    annotations:
      message: 'region: {{ $labels.region }}, pod: {{ $labels.pod }}, Sched Server memory usage is {{ $value | humanizePercentage }}, exceeds 70% threshold.'
      runbook_url:
      value: '{{ $value }}'
      summary: "Sched Server memory usage exceeds the threshold"
