Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(discord_gcp_alerts): include policy name in alert title #431

Merged
merged 3 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 🚨',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol. Much more descriptive!

'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 🚨',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this representative of what the titles will look like?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No that was just the sample all of our policy names are much nicer like "Artifact Proxy Missing Artifact"

'description': 'Test Incident',
'url': 'http://www.example.com',
'color': 16711680,
Expand Down