Can't override query when adding alert rule via API

Hello, I am trying to add rules to several LibreNMS via API and I ran into this problem:

- Steps to reproduce the issue.

  1. Add the new rule via API using a custom query and set “override_query” to “on”:
curl -X POST -d '{"devices":"-1","severity": "critical", "extra": "{\"mute\":false,\"count\":\"-1\",\"delay\":300,\"invert\":false,\"interval\":10800,\"recovery\":true,\"options\":{\"override_query\":\"on\"}}", "disabled": 0, "name": "Processor usage AVG", "query": "SELECT *,AVG(processors.processor_usage) as cpu_avg FROM devices,processors WHERE (devices.device_id = ? AND devices.device_id = processors.device_id) AND (devices.status = 1 && (devices.disabled = 0 && devices.ignore = 0)) = 1 HAVING AVG(processors.processor_usage)  > 80", "builder": "{\"condition\":\"AND\",\"rules\":[{\"id\":\"processors.processor_usage\",\"field\":\"processors.processor_usage\",\"type\":\"string\",\"input\":\"text\",\"operator\":\"greater\",\"value\":\"80\"}],\"valid\":true}", "proc": "", "invert_map": 0}' -H 'X-Auth-Token: 26xxxc58xxx72d3462xxxxxx'

Answer from the API:

“status”: “ok”

  1. The rule was added, but when you check the result you get this:
        "id": 24,
        "rule": "",
        "severity": "critical",
        "extra": "{\"mute\":false,\"count\":null,\"delay\":300,\"interval\":300,\"options\":{\"override_query\":null}}",
        "disabled": 0,
        "name": "Processor usage AVG",
        "query": "SELECT * FROM devices,processors WHERE (devices.device_id = ? AND devices.device_id = processors.device_id) AND processors.processor_usage > 80",
        "builder": "{\"condition\":\"AND\",\"rules\":[{\"id\":\"processors.processor_usage\",\"field\":\"processors.processor_usage\",\"type\":\"string\",\"input\":\"text\",\"operator\":\"greater\",\"value\":\"80\"}],\"valid\":true}",
        "proc": null,
        "invert_map": 0

Note how “override_query” is set to null and “interval” is set to 300 even though I sent different values.

I’m not sure if the configuration I’m sending is well formed, but the OK answer makes me think it is.
Any hint on how to debug this will be greatly appreciated.

- The output of ./validate.php


Component Version
LibreNMS 21.2.0
DB Schema 2021_02_09_084318_remove_perf_times (199)
PHP 7.4.3
Python 3.8.5
MySQL 10.3.25-MariaDB-0ubuntu0.20.04.1
RRDTool 1.7.2


[OK] Composer Version: 2.0.11
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
[WARN] Global lnms shortcut not installed. lnms command must be run with full path
sudo ln -s /opt/librenms/lnms /usr/bin/lnms
[WARN] Bash completion not installed. lnms command tab completion unavailable.
sudo cp /opt/librenms/misc/lnms-completion.bash /etc/bash_completion.d/

Thank you!

This topic was automatically closed 186 days after the last reply. New replies are no longer allowed.