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: add CloudWatch queries #236

Merged
merged 4 commits into from
Apr 6, 2021
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
6 changes: 3 additions & 3 deletions aws/eks/cloudwatch_log.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resource "aws_cloudwatch_log_group" "notification-canada-ca-eks-cluster-logs" {
resource "aws_cloudwatch_log_metric_filter" "web-500-errors" {
name = "web-500-errors"
pattern = "\"\\\" 500 \""
log_group_name = "/aws/containerinsights/${aws_eks_cluster.notification-canada-ca-eks-cluster.name}/application"
log_group_name = local.eks_application_log_group

metric_transformation {
name = "500-errors"
Expand All @@ -25,7 +25,7 @@ resource "aws_cloudwatch_log_metric_filter" "web-500-errors" {
resource "aws_cloudwatch_log_metric_filter" "celery-error" {
name = "celery-error"
pattern = "\"ERROR/Worker\""
log_group_name = "/aws/containerinsights/${aws_eks_cluster.notification-canada-ca-eks-cluster.name}/application"
log_group_name = local.eks_application_log_group

metric_transformation {
name = "celery-error"
Expand All @@ -37,7 +37,7 @@ resource "aws_cloudwatch_log_metric_filter" "celery-error" {
resource "aws_cloudwatch_log_metric_filter" "over-daily-rate-limit" {
name = "over-daily-rate-limit"
pattern = "has been rate limited for daily use sent"
log_group_name = "/aws/containerinsights/${aws_eks_cluster.notification-canada-ca-eks-cluster.name}/application"
log_group_name = local.eks_application_log_group

metric_transformation {
name = "over-daily-rate-limit"
Expand Down
46 changes: 46 additions & 0 deletions aws/eks/cloudwatch_queries.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
resource "aws_cloudwatch_query_definition" "admin-api-50X-errors" {
Copy link
Contributor Author

@AntoineAugusti AntoineAugusti Apr 6, 2021

Choose a reason for hiding this comment

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

Those queries have been copy/pasted from the AWS console in production

name = "ADMIN & API - 50X errors"

log_group_names = [
local.eks_application_log_group
]

query_string = <<QUERY
fields @timestamp, log, kubernetes.labels.app as app, kubernetes.pod_name as pod_name, @logStream
| filter kubernetes.labels.app like /admin|api/
| filter @message like /HTTP\/\d+\.\d+\\" 50\d/
| sort @timestamp desc
| limit 20
QUERY
}

resource "aws_cloudwatch_query_definition" "celery-errors" {
name = "Celery errors"

log_group_names = [
local.eks_application_log_group
]

query_string = <<QUERY
fields @timestamp, log, kubernetes.labels.app as app, kubernetes.pod_name as pod_name, @logStream
| filter kubernetes.labels.app like /^celery/
| filter strcontains(@message, 'ERROR/Worker')
| sort @timestamp desc
| limit 20
QUERY
}

resource "aws_cloudwatch_query_definition" "services-over-daily-rate-limit" {
name = "Services going over daily rate limits"

log_group_names = [
local.eks_application_log_group
]

query_string = <<QUERY
fields @timestamp, log, @logStream
| filter strcontains(@message, 'has been rate limited for daily use sent')
| sort @timestamp desc
| limit 20
QUERY
}
4 changes: 4 additions & 0 deletions aws/eks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ variable "alb_log_bucket" {
variable "eks_cluster_name" {
type = string
}

locals {
eks_application_log_group = "/aws/containerinsights/${var.eks_cluster_name}/application"
}