SWQL - IF query for modern dashboard

Hello,

I'm building a KPI widget to keep an eye on the response time of a node, and I need it to display some text based on the current value.
i.e.: If the response time is lower than 300ms it'll display the word OK and if higher than 300ms it'll display NOT OK

The below query retrieves the value but not sure how to add/structure the IF statement for swql. 

I'll appreciate the guidance.

SELECT
ResponseTime
FROM Orion.NodesStats
WHERE
NodeID LIKE '1'

  • You could try something like below. I have the BETWEEN 0 and 300 as down/unmanaged nodes have a ResponseTime field of -1 and External nodes are -2.  I'm not sure you can change the colours of the widget as the thresholds are looking for numerical values, not text.

    SELECT CASE WHEN ResponseTime BETWEEN 0 AND 300 THEN 'OK'
        ELSE 'NOT OK'
    END AS [Node_Status]
    FROM Orion.Nodes
    WHERE NodeID = 1
    

  • Thanks shuth! It worked, I also made it work with a little variation but I found yours more simple. 

    SELECT 
    CASE 
    WHEN ResponseTime > 300 THEN 'NotOK' WHEN ResponseTime < 300 THEN 'OK' ELSE 'Down' 
    END AS NodeStatus
    FROM Orion.NodesStats
    WHERE NodeID LIKE '1'