cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 7

Custom Dashboard Widget to Display Muted Nodes

Jump to solution

Hello everyone, 

We are looking to create a custom widget on our SolarWinds dashboard that lists any nodes that have been placed into maintenance mode and have had alerts muted. We have a working custom widget that lists unmanged and muted nodes, however we are trying to narrow it down to just muted nodes. I have attached the SWQL code from our working widget and the code from the widget that we are trying to modify to see only muted nodes. The one we are attempting to build displays the data we want in SWQL studio, but not when putting the code into the widget on the dashboard. All we see is "there was an error processing this request." I hope I have selected the proper location for this post. Please let me know if additional info is needed. 

Thank you in advance! 

- Trevor

0 Kudos
1 Solution

So the query has 3 nested queries in it, but the outermost query doesn't have anything defining the order, which is what the web UI gets mad about.  See the last line here for the fix:

 

## This code displays only muted nodes in SWQL, however displays no data on the SolarWinds "Custom Query" dashboard widget ##

SELECT 
'Muted' as [Status]
,n.caption
,tostring(tolocal(SuppressFrom)) as [From]
,case when SuppressUntil is null or SuppressUntil = '9999-01-01 00:00:00' then 'Not set'
else tostring(tolocal(SuppressUntil )) end AS [Until]
,case when SuppressUntil is null or SuppressUntil = '9999-01-01 00:00:00' then '-'
else tostring(daydiff(getutcdate(), asup.SuppressUntil)) end as [Days Left]
,n.DetailsURL AS [_LinkFor_Node]
,'/Orion/images/StatusIcons/Small-' + n.StatusLED AS [_IconFor_Node]
, ae.AccountID AS [Account]

FROM Orion.AlertSuppression asup 
join orion.nodes n on asup.entityuri=n.uri
join (
    SELECT ae.NetObjectID, max(ae.timeloggedutc) as recent
    FROM Orion.AuditingEvents ae
    WHERE ae.auditingactiontype.actiontype in ('Orion.AlertSuppressionChanged','Orion.AlertSuppressionAdded')
    group BY ae.netobjectid) mostrecent ON mostrecent.NetObjectID = n.NodeID
join (
    SELECT ae.NetObjectID, ae.AccountID, ae.timeloggedutc
    FROM Orion.AuditingEvents ae
    WHERE ae.auditingactiontype.actiontype in ('Orion.AlertSuppressionChanged','Orion.AlertSuppressionAdded')
    Order BY ae.TimeLoggedUtc desc) ae ON ae.NetObjectID = n.NodeID and ae.timeloggedutc=mostrecent.recent

order by n.caption

 

- Marc Netterfield, Github

View solution in original post

0 Kudos
5 Replies

So the query has 3 nested queries in it, but the outermost query doesn't have anything defining the order, which is what the web UI gets mad about.  See the last line here for the fix:

 

## This code displays only muted nodes in SWQL, however displays no data on the SolarWinds "Custom Query" dashboard widget ##

SELECT 
'Muted' as [Status]
,n.caption
,tostring(tolocal(SuppressFrom)) as [From]
,case when SuppressUntil is null or SuppressUntil = '9999-01-01 00:00:00' then 'Not set'
else tostring(tolocal(SuppressUntil )) end AS [Until]
,case when SuppressUntil is null or SuppressUntil = '9999-01-01 00:00:00' then '-'
else tostring(daydiff(getutcdate(), asup.SuppressUntil)) end as [Days Left]
,n.DetailsURL AS [_LinkFor_Node]
,'/Orion/images/StatusIcons/Small-' + n.StatusLED AS [_IconFor_Node]
, ae.AccountID AS [Account]

FROM Orion.AlertSuppression asup 
join orion.nodes n on asup.entityuri=n.uri
join (
    SELECT ae.NetObjectID, max(ae.timeloggedutc) as recent
    FROM Orion.AuditingEvents ae
    WHERE ae.auditingactiontype.actiontype in ('Orion.AlertSuppressionChanged','Orion.AlertSuppressionAdded')
    group BY ae.netobjectid) mostrecent ON mostrecent.NetObjectID = n.NodeID
join (
    SELECT ae.NetObjectID, ae.AccountID, ae.timeloggedutc
    FROM Orion.AuditingEvents ae
    WHERE ae.auditingactiontype.actiontype in ('Orion.AlertSuppressionChanged','Orion.AlertSuppressionAdded')
    Order BY ae.TimeLoggedUtc desc) ae ON ae.NetObjectID = n.NodeID and ae.timeloggedutc=mostrecent.recent

order by n.caption

 

- Marc Netterfield, Github

View solution in original post

0 Kudos

This did it, thank you! 

0 Kudos

The one that doesnt work doesn't seem to have an order by, for some reason the web ui gets fussy when relatively complex queries dont specify the order by.  The issue comes up at least once a month.

- Marc Netterfield, Github
0 Kudos

Thank you both for the replies. Apologies, this is a bit outside of my normal area. By chance, could you provide an example of specifying an order by? In the code that is not working in the widget, I found the following line: Order BY ae.TimeLoggedUtc desc) ae ON ae.NetObjectID = n.NodeID and ae.timeloggedutc=mostrecent.recent

Thank you, 

- Trevor

0 Kudos
Level 12

This is the error I am seeing in Orion.Web.log when running the query:

ioan_bucsa_0-1598639227921.png

It's odd that SWQL queries work differently from Studio than from the web application. I always tested my queries in SWQL Studio first and was under the impression that the back-end mechanism is identical.

0 Kudos