Grafana - create alert Jinja2 rule template with LLM

Grafana - create alert Jinja2 rule template with LLM

To use existing operational documentation to create an auto-resolve template in Grafana, please follow the steps below

  1. Modify existing documentation / create new documentation to include Eyer relevant context on what should be alerted or not (like severity, correlations, nodes and metrics affected etc). As an example, please see the following Google doc https://docs.google.com/document/d/1aUaupaYOBo1EsDaTRuIx8lOVG08yVAmC7TRVGTh1dSo/edit?usp=sharing

  2. Export the document(s) as PDF or another readable format for a LLM.

  3. Access your LLM and provide the following prompt and then attach your document(s)

    1. In Grafana, I have a Jinja2 template that will automatically resolve alerts based on given conditions. All conditions not met will trigger an alert. The current template is shown below: {{ ((payload["learning_status"] > 1) or (payload["nodes_affected"] < 4) or (payload["severity"] != "severe") or ("storage" in payload | string) or ("test" in payload | string) or ("cn" in payload | string)) or (("virtualmachines" not in payload["node"]["name"]) or (payload["severity"] != "severe") or (payload["learning_status"] > 1)) }} I want you to create a similar Grafana Jinja2 template based on the text I paste after this prompt. The template should define which alerts should auto-resolve and which should always trigger, strictly following the descriptions in the provided text. Important constraints for the template: Use only payload["field"] or payload["field"]["subfield"] (not dot notation). Use only simple boolean operators (and, or, not). Use only string checks with in / not in. Use payload | string (with spaces around the pipe) for string coercion. Do not use Python methods like .startswith() or include comments inside {{ ... }} blocks. Wrap everything in a single {{ (...) }} block. When parsing the documentation, extract both: Ignore conditions (alerts that should be auto-resolved). Always-alert conditions (alerts that must trigger and cannot be ignored). Then generate the final Grafana-compatible template.
    2. Copy the Jinja2 template generated into your Grafana auto-resolution field and hit “save”