Skip to content

Commit

Permalink
feat(discord_gcp_alerts): include policy name in alert title (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored May 3, 2023
1 parent a3a630f commit 1cb8154
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/discord_gcp_alerts/lib/src/gcp_alert_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ Handler gcpAlertHandler({required String webhookUrl, http.Client? client}) {
final url = incident?.url;
final resource = incident?.resourceName;
final conditionName = incident?.conditionName;
final policyName = incident?.policyName ?? 'GCP Alert';
final discordPayload = {
'embeds': [
{
'title': 'GCP Alert',
'title': '🚨 $policyName 🚨',
'description': summary,
'url': url,
'color': 0xFF0000,
Expand Down
4 changes: 4 additions & 0 deletions packages/discord_gcp_alerts/lib/src/models/gcp_alert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Incident {
this.summary,
this.resourceName,
this.conditionName,
this.policyName,
});

/// Creates an [Incident] from a JSON [Map].
Expand All @@ -52,6 +53,9 @@ class Incident {
/// A summary of the incident.
final String? summary;

/// The name of the policy associated with the incident.
final String? policyName;

/// The name of the resource.
final String? resourceName;

Expand Down
4 changes: 3 additions & 1 deletion packages/discord_gcp_alerts/lib/src/models/gcp_alert.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void main() {
body: json.encode({
'embeds': [
{
'title': 'GCP Alert',
'title': '🚨 projects/12345/alertPolicies/12345 🚨',
'description': 'Test Incident',
'url': 'http://www.example.com',
'color': 16711680,
Expand Down

0 comments on commit 1cb8154

Please sign in to comment.