-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SMS (SNS) stored queries from CWI into Terraform / SMS (pinpoint) new…
… queries (#1574) * Added SMS (SNS) stored queries from CWI into Terraform * Added pinpoint-carrier-dwell-times CWLI query * Added the pinpoint-failures-by-carrier query * Added coalesce + labels * Added warning alarms for the main telecoms when one of these fail. * Rework the interntional sending query on the SNS side * Brought forward SNS queries into Pinpoint + fixed queries * Performed a few renames and fixed indices refs * Added optional switch to the new log metric filter. * Trigger AI code [review] * Fixed the typo * Renamed duplicate query * Renamed duplicate alarm names * Added count on pinpoint log groups, expect build failures
- Loading branch information
1 parent
2c24989
commit 3c5df00
Showing
8 changed files
with
503 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
resource "aws_cloudwatch_query_definition" "sms-sns-blocked-as-spam" { | ||
count = var.cloudwatch_enabled ? 1 : 0 | ||
name = "SMS (SNS) / Block as spam" | ||
|
||
log_group_names = [ | ||
aws_cloudwatch_log_group.sns_deliveries_failures[0].name | ||
] | ||
|
||
query_string = <<QUERY | ||
fields @timestamp as Timestamp, delivery.phoneCarrier as Carrier, delivery.providerResponse as `Provider response`, delivery.destination as `Destination phone number` | ||
| filter delivery.providerResponse like 'spam' | ||
| sort Timestamp desc | ||
| limit 100 | ||
} | ||
QUERY | ||
} | ||
|
||
resource "aws_cloudwatch_query_definition" "sms-sns-carrier-dwell-times" { | ||
count = var.cloudwatch_enabled ? 1 : 0 | ||
name = "SMS (SNS) / Carrier dwell times" | ||
|
||
log_group_names = [ | ||
aws_cloudwatch_log_group.sns_deliveries[0].name, | ||
aws_cloudwatch_log_group.sns_deliveries_failures[0].name | ||
] | ||
|
||
query_string = <<QUERY | ||
stats avg(delivery.dwellTimeMsUntilDeviceAck / 1000 / 60) as Avg_carrier_time_minutes, | ||
| count(*) as Number by delivery.phoneCarrier as Carrier | ||
QUERY | ||
} | ||
|
||
resource "aws_cloudwatch_query_definition" "sms-sns-get-failures" { | ||
count = var.cloudwatch_enabled ? 1 : 0 | ||
name = "SMS (SNS) / Get failures" | ||
|
||
log_group_names = [ | ||
aws_cloudwatch_log_group.sns_deliveries_failures[0].name | ||
] | ||
|
||
query_string = <<QUERY | ||
fields @timestamp as Timestamp, status, delivery.phoneCarrier as Carrier, delivery.providerResponse as `Provider response`, delivery.destination as `Destination phone number`, notification.messageId as messageId, @message | ||
| filter status = 'FAILURE' | ||
| sort Timestamp desc | ||
| limit 200 | ||
QUERY | ||
} | ||
|
||
resource "aws_cloudwatch_query_definition" "sms-sns-get-sms-logs-by-phone-number" { | ||
count = var.cloudwatch_enabled ? 1 : 0 | ||
name = "SMS (SNS) / Get SMS logs by phone number" | ||
|
||
log_group_names = [ | ||
aws_cloudwatch_log_group.sns_deliveries[0].name, | ||
aws_cloudwatch_log_group.sns_deliveries_failures[0].name | ||
] | ||
|
||
query_string = <<QUERY | ||
fields @timestamp as Timestamp, status as Status, notification.messageId as `Message ID`, | ||
delivery.destination as `Destination phone number`, delivery.providerResponse as `Provider response`, | ||
delivery.smsType as `Message type` | ||
| filter delivery.destination like '1416xxxxxxx' | ||
| sort Timestamp desc | ||
| limit 100 | ||
QUERY | ||
} | ||
|
||
resource "aws_cloudwatch_query_definition" "sms-sns-international-sending-status" { | ||
count = var.cloudwatch_enabled ? 1 : 0 | ||
name = "SMS (SNS) / International sending status" | ||
|
||
log_group_names = [ | ||
aws_cloudwatch_log_group.sns_deliveries[0].name, | ||
aws_cloudwatch_log_group.sns_deliveries_failures[0].name | ||
] | ||
|
||
query_string = <<QUERY | ||
fields @timestamp, @message, delivery.mcc as CountryCode, status | ||
| stats count(*) as Event_Count by CountryCode, status | ||
| display CountryCode, status, Event_Count | ||
| sort CountryCode asc | ||
| limit 200 | ||
QUERY | ||
} | ||
|
||
resource "aws_cloudwatch_query_definition" "sms-sns-success-vs-unreachable" { | ||
count = var.cloudwatch_enabled ? 1 : 0 | ||
name = "SMS (SNS) / Success vs Unreachable" | ||
|
||
log_group_names = [ | ||
aws_cloudwatch_log_group.sns_deliveries[0].name, | ||
aws_cloudwatch_log_group.sns_deliveries_failures[0].name | ||
] | ||
|
||
query_string = <<QUERY | ||
fields @timestamp, delivery.providerResponse | ||
| parse delivery.providerResponse "Phone is currently unreachable/*" as @unavailable | ||
| parse delivery.providerResponse "Message has been * by phone" as @available | ||
| sort @timestamp desc | ||
| stats count(@unavailable), count(@available), count(*) by bin(1h) | ||
QUERY | ||
} | ||
|
||
resource "aws_cloudwatch_query_definition" "sms-sns-unreachable-phone-numbers" { | ||
count = var.cloudwatch_enabled ? 1 : 0 | ||
name = "SMS (SNS) / Unreachable phone numbers" | ||
|
||
log_group_names = [ | ||
aws_cloudwatch_log_group.sns_deliveries_failures[0].name | ||
] | ||
|
||
query_string = <<QUERY | ||
fields @timestamp, delivery.providerResponse | ||
| filter delivery.providerResponse like "Phone is currently unreachable/unavailable" | ||
| sort @timestamp desc | ||
| limit 20 | ||
QUERY | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.