Hi,
I would like to display alerts using custom query and change text colour based on severity can you please advise how this can be achieved.
The custom query resource does not provide a way to control text color.
The custom query custom table (reporting) resource allows unquoted HTML. You can use this to set the text color, perhaps by using a CASE ... WHEN ... END to choose the color based on some condition.
Edit 2017-05-26: I mixed up which resource type allows HTML tags.
There are ways of incorporating color into custom queries but they are difficult. The example below is generated by the custom sql that follows afterwards
select top 25
EventTime,
NetObjectID,
Events.EventType,
'<img src=/NetPerfMon/images/Event-' + LTRIM(STR(Events.EventType,10)) + '.gif> ' + '<a href=/Orion/View.aspx?View=NodeDetails&NetObject=N:' + LTRIM(STR(NetObjectID,10)) + '><font color=' + Icon + '>' + Message + '</font></a>' as Message
from
events join EventTypes on Events.EventType=EventTypes.EventType
where
NetObjectID in (select nodeid from nodes) and
EventTypes.EventType in (1,2,5,8,9,14,40,41,100,940,941,942,3701)
order by
EventTime desc
NOTE: I removed a portion of the sql where clause to protect the guilty (me!)
Chris
Good point! I forgot about that method.
Thanks for the clarification, can this be used in SWQL?
Like this:
SELECT '<span style="color:' +
CASE Status
WHEN 0 THEN 'red'
WHEN 1 THEN 'green'
WHEN 9 THEN 'purple'
ELSE 'black'
END + '">' + Caption + '</span>' AS ColorCaption
FROM Orion.Nodes
Agreed. Your's is simpler. I was recreating the exact color coding and icon selections in a special event view for a customer.
tdanner
You say this works in the custom query, you sure thats not just in custom table/report? When I try this code in a custom query resource I get this
I can use it successfully in a custom table by checking the allow HTML box.
Is there a bit I'm missing?
And if that is WAI, how many cases of what liquor do I have to buy your devs to get an Allow HTML check box added to the custom query resource? (i'm only slightly joking)
Nice custom SQL Cgregors ! That work well !
Will be possible to change the association with the events by an association with the severity of the alerts ?
'select top 25
events join EventTypes on Events.EventType=EventTypes.EventType'
Love this concept and code that you all have provided. Unfortunately I am still getting an 'invalid query' error when trying to use the CASE statement to append the span styling tags. For now my workaround is to modify the table and use column display settings to present an icon instead of the severity text string.