Skip to content

Library with types and serializing utils for azureMonitorCommonAlertSchema

License

Notifications You must be signed in to change notification settings

JWMB/AzureMonitorCommonAlertSchemaTypes

Repository files navigation

.NET

AzureMonitorCommonAlertSchemaTypes

A .NETStandard 2.0 library with types and serializing utils for azureMonitorCommonAlertSchema

Work in progress

Rant

No type information seems to be provided by Microsoft for handling alert payloads - no JSON Schema and no type libraries. This library is built on guesswork based on various example payloads. Lots of properties are of type string in this library, but are probably enums in reality. How can we find out?

Also overall design principles seem lacking.

  • Sometimes properties are camelCase, sometimes PascalCase.
  • Compare ServiceHealthAlertContext with ResourceHealthAlertContext - some properties sound like they should be shared, but the types differ.
  • GreaterThan AND Greater Than - also LessThan AND Lower Than..?

Supported variations

(Auto-generated information)

  • ActivityLogAlertContext - example
  • LogAlertsV2AlertContext
    • DynamicThresholdCriteria - example
    • LogQueryCriteria - example
    • SingleResourceMultipleMetricCriteria - example
    • WebtestLocationAvailabilityCriteria
  • LogAnalyticsAlertContext - example
  • ResourceHealthAlertContext - example
  • ServiceHealthAlertContext - example
  • SmartAlertContext - example

See ActionGroupTests for the payloads generated by Azure ActionGroup tester (also this)

The respective unit tests can be found in ActionGroupTests.cs

Example usage in AzureAlerts2Slack or

var alert = Types.AlertJsonSerializerSettings.DeserializeOrThrow(requestBody);
if (ctx is Types.AlertContexts.LogAnalyticsAlertContext ctxLogAnalytics)
{
    Console.Log($"{alert.Data.Essentials.AlertRule} - tables:{string.Join(", ", ctxLogAnalytics.SearchResults.Tables.Select(o => o.Name))}");
}

Repo that uses this library in an Azure Function for posting to Slack: AzureAlerts2Slack

Related 3rd-party repos

About

Library with types and serializing utils for azureMonitorCommonAlertSchema

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages