groups:
  - name: tikv-s3-throughput.rules
    rules:
      - alert: TiKVWithHighS3Throughput
        annotations:
          message: alicloud/{{ $labels.region }} current s3 {{ $labels.type }} throughput is {{ $value }}Gbps, more then 80% of the target {{ $labels.type }} bandwidth 40Gbps for 2m.
        expr: |
          (sum(rate(kv_engine_dfs_throughput_bytes{provider_type="alicloud-serverless",region="cn-hongkong",type="get"}[1m])*8.6) by (type, region))/1024/1024/1024 > 40*0.8
        for: 2m
        labels:
          tier: serverless
          severity: critical
          response_class: page
          provider_type: aws-free-tier
          component: s3
          oncall_team: serverless
      - alert: TiKVWithHighS3Throughput
        annotations:
          message: alicloud/{{ $labels.region }} current s3 {{ $labels.type }} throughput is {{ $value }}Gbps, more then 80% of the target {{ $labels.type }} bandwidth 25Gbps for 2m.
        expr: |
          (sum(rate(kv_engine_dfs_throughput_bytes{provider_type="alicloud-serverless",region="ap-northeast-1",type="get"}[1m])*8.6) by (type, region))/1024/1024/1024 > 25*0.8
        for: 2m
        labels:
          tier: serverless
          severity: critical
          response_class: page
          provider_type: aws-free-tier
          component: s3
          oncall_team: serverless
      - alert: TiKVWithHighS3Throughput
        annotations:
          message: alicloud/{{ $labels.region }} current s3 {{ $labels.type }} throughput is {{ $value }}Gbps, more then 80% of the target {{ $labels.type }} bandwidth 10Gbps for 2m.
        expr: |
          (sum(rate(kv_engine_dfs_throughput_bytes{provider_type="alicloud-serverless",region=~"cn-hongkong|ap-northeast-1",type="put"}[1m])*8.6) by (type, region))/1024/1024/1024 > 10*0.8
        for: 2m
        labels:
          tier: serverless
          severity: critical
          response_class: page
          provider_type: aws-free-tier
          component: s3
          oncall_team: serverless
      - alert: TiKVWithHighS3Throughput
        annotations:
          message: alicloud/{{ $labels.region }} current s3 {{ $labels.type }} throughput is {{ $value }}Gbps, more then 50% of the target {{ $labels.type }} bandwidth 40Gbps for 2m.
        expr: |
          40*0.8 >= (sum(rate(kv_engine_dfs_throughput_bytes{provider_type="alicloud-serverless",region="cn-hongkong",type="get"}[1m])*8.6) by (type, region))/1024/1024/1024 > 40*0.5
        for: 2m
        labels:
          tier: serverless
          severity: warning
          provider_type: aws-free-tier
          component: s3
          oncall_team: serverless
      - alert: TiKVWithHighS3Throughput
        annotations:
          message: alicloud/{{ $labels.region }} current s3 {{ $labels.type }} throughput is {{ $value }}Gbps, more then 50% of the target {{ $labels.type }} bandwidth 25Gbps for 2m.
        expr: |
          25*0.8 >= (sum(rate(kv_engine_dfs_throughput_bytes{provider_type="alicloud-serverless",region="ap-northeast-1",type="get"}[1m])*8.6) by (type, region))/1024/1024/1024 > 25*0.5
        for: 2m
        labels:
          tier: serverless
          severity: warning
          provider_type: aws-free-tier
          component: s3
          oncall_team: serverless
      - alert: TiKVWithHighS3Throughput
        annotations:
          message: alicloud/{{ $labels.region }} current s3 {{ $labels.type }} throughput is {{ $value }}Gbps, more then 50% of the target {{ $labels.type }} bandwidth 10Gbps for 2m.
        expr: |
          10*0.8 >= (sum(rate(kv_engine_dfs_throughput_bytes{provider_type="alicloud-serverless",region=~"cn-hongkong|ap-northeast-1",type="put"}[1m])*8.6) by (type, region))/1024/1024/1024 > 10*0.5
        for: 2m
        labels:
          tier: serverless
          severity: warning
          provider_type: aws-free-tier
          component: s3
          oncall_team: serverless
      - alert: TiKVWithS3ThroughputSurge
        annotations:
          message: alicloud/{{ $labels.region }} s3 {{ $labels.type }} throughput p95 in the last 5m is {{ printf "%.2f" $value }}Gbps, more than 150% of the p95 1h ago.
        expr: |
          quantile_over_time(
            0.95,
            (
              (
                sum(rate(kv_engine_dfs_throughput_bytes{provider_type="alicloud-serverless",region=~"cn-hongkong|ap-northeast-1",type=~"get|put"}[1m]) * 8.6) by (type, region)
              ) / 1024 / 1024 / 1024
            )[10m:1m]
          )
          >
          1.5 * clamp_min(
            quantile_over_time(
              0.95,
              (
                (
                  sum(rate(kv_engine_dfs_throughput_bytes{provider_type="alicloud-serverless",region=~"cn-hongkong|ap-northeast-1",type=~"get|put"}[1m] offset 1h) * 8.6) by (type, region)
                ) / 1024 / 1024 / 1024
              )[10m:1m]
            ),
            1
          )
        for: 5m
        labels:
          tier: serverless
          severity: warning
          provider_type: aws-free-tier
          component: s3
          oncall_team: serverless
