Grafana requires time range for alert rule creation with instant PromQL quieriy

Finally, managed to get my alerting rule yaml to work . This is the format of the file:

apiVersion: 1

groups:

  • orgId: 1
    name: network
    folder: alerts
    interval: 60s
    rules:
    • uid: 2
      title: My rule
      condition: B
      data:
      • refId: A
        queryType: ‘’
        relativeTimeRange:
        from: 600
        to: 0
        datasourceUid: 123456
        model:
        editorMode: code
        expression: ‘some expression’
        intervalMs: 1000
        maxDataPoints: 43200
        legendFormat: __auto
        range: true
        refId: A
      • refId: B
        queryType: ‘’
        relativeTimeRange:
        from: 0
        to: 0
        datasourceUid: -100
        model:
        conditions:
        - evaluator:
        params:
        - 2000
        type: gt
        operator:
        type: and
        query:
        params:
        - A
        reducer:
        params:
        type: last
        type: query
        datasource:
        type: expr
        uid: “-100”
        expression: A
        intervalMs: 1000
        maxDataPoints: 43200
        refId: B
        type: classic_conditions
        noDataState: NoData
        for: 3m
        annotations:
        summary: Test
        labels:
        env: testnet