Alerts unit test expression with AND condition and multiple metrics

Proposal

Hello,

I’m trying to test this alert

    - alert: HostOutOfMemory
      expr: node_memory_MemAvailable_bytes{job="node_exporter"} / node_memory_MemTotal_bytes{job="node_exporter"} * 100 < 5 and rate(node_vmstat_pgmajfault{job="node_exporter"}[1m]) > 1000
      for: 15m
      labels:
        priority: P2
        grouping: alertname
      annotations:
        summary: Host out of memory

This alert contains three timeseries with an AND condition.

But i dont know how I can manage it in unit test

rule_files:
  - ../files/rules/common.yml

evaluation_interval: 1m

tests:
    - interval: 1m
      input_series:
            - series: 'node_memory_MemTotal_bytes{instance="nok", job="node_exporter"}'
              values: 33378373632x60
            - series: 'node_memory_MemAvailable_bytes{instance="nok", job="node_expoter"}'
              values: 1000x60
            - series: 'node_vmstat_pgmajfault{instance="nok", job="node_exporter"}'
              values: 1+200000x60

      alert_rule_test:
        - eval_time: 20m
          alertname: HostOutOfMemory
          exp_alerts:
            - exp_labels:
                priority: P2
                instance: nok
              exp_annotations:
                summary: Host out of memory

How can we handle this type of alert ? Or juste wondering if it’s possible :confused:

Thanks