forked from chrisdamba/SQL-Server-Management-Studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Foglight error count.sql
34 lines (28 loc) · 1.93 KB
/
Foglight error count.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--/****** Script for SelectTopNRows command from SSMS ******/
--SELECT TOP 1000 [alarm_id]
-- ,[id]
-- ,[source_id]
-- ,[message]
-- ,[topology_object_id]
-- ,[is_cleared]
-- ,[is_acknowledged]
-- ,[cleared_time]
-- ,[created_time]
-- ,[severity]
-- ,[cleared_by]
-- ,[ack_time]
-- ,[ack_by]
-- ,[source_name]
-- ,[rule_id]
-- ,[user_defined_data]
-- ,[auto_ack]
SELECT [topology_object_id]
,SUM(CASE [severity] WHEN 4 THEN 1 ELSE 0 END)
,SUM(CASE [severity] WHEN 3 THEN 1 ELSE 0 END)
,SUM(CASE [severity] WHEN 2 THEN 1 ELSE 0 END)
,SUM(CASE [severity] WHEN 1 THEN 1 ELSE 0 END)
,SUM(CASE [severity] WHEN 0 THEN 1 ELSE 0 END)
FROM [foglight].[dbo].[alarm_alarm]
-- WHERE [topology_object_id] IN (SELECT [to_unique_id] FROM [foglight].[dbo].[topology_object] where to_type = 521)
GROUP BY [topology_object_id]
ORDER BY 2 desc, 3 desc, 4 desc, 5 desc, 6 desc