rule_files:
  - ../rules/mem9/mnemos/drive9-kimi-alerts.yaml

evaluation_interval: 1m

tests:
  - interval: 1m
    input_series:
      - series: 'drive9_business_events_total{namespace="mem9",event="tenant_provision",provider="tidb_cloud_native_shared",result="error",tenant_id="kimi-provision",tidbcloud_org_id="97"}'
        values: '0+1x12'
      - series: 'drive9_business_events_total{namespace="mem9",event="tenant_provision",provider="tidb_cloud_native_shared",result="error",tenant_id="other-provision",tidbcloud_org_id="98"}'
        values: '0+1x12'
    alert_rule_test:
      - eval_time: 10m
        alertname: Drive9CreateWorkSpaceError
        exp_alerts:
          - exp_labels:
              namespace: mem9
              provider: tidb_cloud_native_shared
              result: error
              tenant_id: kimi-provision
              tidbcloud_org_id: "97"
              severity: major
              component: drive9-kimi
              oncall_team: none
              visibility: external
            exp_annotations:
              summary: "Drive9 (Kimi) workspace creation is failing"
              description: "Drive9 workspace kimi-provision / TiDB org 97 creation has recorded repeated error outcomes for provider tidb_cloud_native_shared over the past 15 minutes. Current value: 10 failures"

  - interval: 1m
    input_series:
      - series: 'drive9_tenant_storage_bytes{namespace="mem9",tenant_id="kimi-storage",tidbcloud_org_id="97",state="confirmed"}'
        values: '91+0x18'
      - series: 'drive9_tenant_storage_bytes{namespace="mem9",tenant_id="kimi-storage",tidbcloud_org_id="97",state="reserved"}'
        values: '0+0x18'
      - series: 'drive9_tenant_storage_bytes{namespace="mem9",tenant_id="kimi-storage",tidbcloud_org_id="97",state="limit"}'
        values: '100+0x18'
      - series: 'drive9_tenant_storage_bytes{namespace="mem9",tenant_id="kimi-storage-zero-limit",tidbcloud_org_id="97",state="confirmed"}'
        values: '100+0x18'
      - series: 'drive9_tenant_storage_bytes{namespace="mem9",tenant_id="kimi-storage-zero-limit",tidbcloud_org_id="97",state="limit"}'
        values: '0+0x18'
      - series: 'drive9_tenant_storage_bytes{namespace="mem9",tenant_id="kimi-storage-boundary",tidbcloud_org_id="97",state="confirmed"}'
        values: '90+0x18'
      - series: 'drive9_tenant_storage_bytes{namespace="mem9",tenant_id="kimi-storage-boundary",tidbcloud_org_id="97",state="limit"}'
        values: '100+0x18'
      - series: 'drive9_tenant_storage_bytes{namespace="mem9",tenant_id="other-storage",tidbcloud_org_id="98",state="confirmed"}'
        values: '99+0x18'
      - series: 'drive9_tenant_storage_bytes{namespace="mem9",tenant_id="other-storage",tidbcloud_org_id="98",state="limit"}'
        values: '100+0x18'
    alert_rule_test:
      - eval_time: 16m
        alertname: Drive9WorkSpaceQuotaNearLimit
        exp_alerts:
          - exp_labels:
              namespace: mem9
              tenant_id: kimi-storage
              tidbcloud_org_id: "97"
              severity: major
              component: drive9-kimi
              oncall_team: none
              visibility: external
            exp_annotations:
              summary: "Drive9 (Kimi) workspace storage quota is near limit"
              description: "Drive9 workspace kimi-storage / TiDB org 97 storage usage has exceeded 90% of its configured limit for 15 minutes. Current value: 91%"
