(Apologies for the long question)
Hi, We have a service running that monitors our queues every 15 minutes and outputs the result to a number of things (company IM, logs, Table storage). I am looking for a nice way to translate the data into "smart" text to output to our IM.
The service monitors 3 things (Alerts) and the result object looks like
public class ServiceMonitorResult
{
public string Name
public int Count
public int Age
public int Delta
// our 3 alerts
public IAlert CountAlert // can be null
public IAlert DeltaAlert // can be null
public IAlert AgeAlert // can be null
}
public interface IAlert
{
AlertStatus Status// enum : New - Continuing - Ended
...
public string MessageText // usually like $"{ServiceName (very long)} {alert status} breached {Alert} with value X at {DateTime.Now}. Started At {startedAt}"
}
When this result gets sent out on our compay IM, the result can sometimes be very verbose. We have over 200 services, if we have an average of 10% breaches, that is 20 messages/15 mins !!
You can imagine in times when there are multiple fauliures how many message you would get.
I have removed the MessageText from the IAlert to have another class that is responsible for building the message based on the Alert status. The reason for that is the result of this monitoring needs to be displayed differently - for example in IM it needs to be compact and clear ; it doesnt matter much in table storage because its used for analysis and is not read by humans.
Given that:
- These alerts can be null , and if they are not they can have a status of New, Continuing or ended.
- I am interested in showing services that have at least one alert with status New
- I am interested in showing services that have at least one alert with status Ended
What I am trying do is use sort of design pattern/algorithim instead of having nested if else statements that will be turn into spagehetti and will be unefficient to maintain/understand . I have had a look at the interpretor pattern but it doesnt look like it will work here. Any ideas?
Example of monitoring input
ServiceName:CountAlertStatus /AgeAlertSatus / DeltaAlertStatus
- service100:N/-/E
- Service101:N/N/C
- Service102:-/-/-
- Service103:C/C/C
- Service104:C/E/N
- Service105:N/N/N
- Service106:E/E/E
(N:new , C: continuring:, E: ended, -:null alert)
Desired output
- service100 : Count (X) breached and Delta is not breached anymore at {Now}
- service101 : Count (X) and Age (Y) breached. Delta is still breached (Z) at {Now}
- Service104 : Delta (X) breached and Age not breached anymore. Count Still breached at {Now}
- Service105 : Count (X) Age(Y) and Delta (Z) breached at {now}
- Service106 : Count (X) Age(Y) and Delta (Z) breach ended at {now}
service102 & service103 will NOT show any alerts because they are null / Continuing and therefore we do not care
Aucun commentaire:
Enregistrer un commentaire