Search code examples
grafanainfluxdb

Auto select new rows in Grafana (InfluxDB)


I have a measurement in InfluxDB that is named Tasks and look like this:

recordname,failure,waiting,timestamp

And in Grafana I have two panels, one for waiting and one for failure. Example:

SELECT "failure" 
FROM "Tasks" 
WHERE 
  ("recordname" = 'Random_record_name') 
  AND time >= now() - 24h 
GROUP BY "recordname";

The data only uploads in Influx if there is a task that fails or is waiting. Therefore I cannot add all the queries for each recordname until they happen. Is there a way to format the query to select all failures for all recordnames so I don't have to manually add them?


Solution

  • You may just want to remove the filter on the recordname:

    SELECT "failure" 
    FROM "Tasks" 
    WHERE 
      time >= now() - 24h 
    GROUP BY "recordname";
    

    This will return a series for each recordname in your database.

    Since you mention Grafana in your question I will add (as a suggestion) to set the alias of the query to $tag_recordname. This way your series will be named according to recordname (the default is a bit less readable).