About Abbot
Abbot is a programmable bot that turns your team chat into a shared command center. We handle all the boilerplate of building and running these conmmands so that you can focus on making tools that help you ship faster.
We built Abbot because we saw the power of this style of work (called ChatOps), when we worked at GitHub. ChatOps made it possible for GitHub to work productively without meetings, while globally distributed. We think it’s a pretty great way to work, so we made it easy to use in Slack, Discord, and Microsoft Teams.
You can read more about Abbot here, check out our blog, or take a look at some of the other cool packages available as a one-click install from Abbot’s Package Directory.
README
Similar to the cloud-event skill, use this skill to subscribe to Azure alerts.
Setup is simple. After installing this skill:
- Attach the skill to the chat room where you want to receive alerts:
@abbot attach azure-alert
- That creates an HTTP trigger and responds with the URL to the triggers page. Go there to get the trigger URL.
- Now in Azure Portal, create an alert and for the Action Group, you can use the trigger URL as a webhook. Make sure the webhook is using the common alert schema.
That’s it!
Right now, when you get an alert, it will look like:
Received Sev4 alert Phil is Testing (Id: /subscriptions/114d4132-6977-430c-a803-38afcadd0e8b/providers/Microsoft.AlertsManagement/alerts/8f4c69a7-deff-41d6-a6dc-3853eb02a46b)
I could use some feedback on what you’d want to see in the message. Note that once you install the package, you can edit the skill yourself to format the message the way you want.
Usage
This package has no usage examples
Code
if (Bot.IsRequest && Bot.Request.IsJson) {
var alert = Bot.Request.DeserializeBodyAs<Alert>();
var essentials = alert.Data.Essentials;
await Bot.ReplyAsync($”Received {essentials.Severity} alert {essentials.AlertRule} (Id: {essentials.AlertId})”);
}
public class Alert {
public string SchemaId {get; set;}
public AlertData Data {get;set;}
}
public class AlertData {
public Essentials Essentials {get; set;}
public JObject AlertContext {get; set;}
}
public class Essentials {
// The unique resource ID identifying the alert instance.
public string AlertId {get; set;}
// The name of the alert rule that generated the alert instance.
public string AlertRule {get; set;}
// The severity of the alert. Possible values: Sev0, Sev1, Sev2, Sev3, or Sev4.
public string Severity {get; set;}
// Identifies the signal on which the alert rule was defined. Possible values: Metric, Log, or Activity Log.
public string SignalType {get; set;}
// When an alert fires, the alert’s monitor condition is set to Fired. When the underlying condition that caused the alert to fire clears, the monitor condition is set to Resolved.
public string MonitorCondition {get; set;}
// The monitoring service or solution that generated the alert. The fields for the alert context are dictated by the monitoring service.
public string MonitoringService {get;set;}
// The list of the Azure Resource Manager IDs that are affected targets of an alert. For a log alert defined on a Log Analytics workspace or Application Insights instance, it’s the respective workspace or application.
public List<string> AlertTargetIDs {get; set;}
// The list of affected resources of an alert. The configuration items can be different from the alert targets in some cases, e.g. in metric-for-log or log alerts defined on a Log Analytics workspace, where the configuration items are the actual resources sending the telemetry, and not the workspace. This field is used by ITSM systems to correlate alerts to resources in a CMDB.
public List<string> ConfigurationItems {get; set;}
// The ID of the alert instance, as generated by the monitoring service generating it.
public string OriginAlertId {get;set;}
// The date and time when the alert instance was fired in Coordinated Universal Time (UTC).
public DateTime FiredDateTime {get; set;}
// The date and time when the monitor condition for the alert instance is set to Resolved in UTC. Currently only applicable for metric alerts.
public DateTime? ResolvedDateTime {get;set;}
// The description, as defined in the alert rule.
public string Description {get;set;}
// The version number for the essentials section.
public string EssentialsVersion {get;set;}
// The version number for the alertContext section.
public string AlertContextVersion {get;set;}
}