-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cloudwatch dashboard for singer taps
- Loading branch information
1 parent
4492899
commit d046f4e
Showing
4 changed files
with
137 additions
and
2 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,120 @@ | ||
locals { | ||
cloudwatch_query_text = <<EOF | ||
filter @message like /(Beginning|Completed) running/ | ||
| filter @message not like /running discovery/ | ||
| filter @message not like /\s--discover\s/ | ||
| parse @message "catalog/${var.taps[0].id}-*-catalog.json" as tablename | ||
| parse @message " (* elapsed)" as elapsed | ||
| fields @timestamp, @message | ||
| sort tablename desc, @timestamp desc | ||
EOF | ||
dashboard_markdown = <<EOF | ||
## Data Pipeline (${var.taps[0].id}-to-${local.target.id}) | ||
Additional Actions: | ||
- [View Running ECS Tasks](https://console.aws.amazon.com/ecs/home?region=${var.environment.aws_region}#/clusters/${module.ecs_cluster.ecs_cluster_name}/tasks) | ||
- [View ECS CloudWatch Logs](${module.ecs_tap_sync_task.ecs_logging_url}) | ||
EOF | ||
} | ||
|
||
resource "aws_cloudwatch_dashboard" "main" { | ||
dashboard_name = "${var.taps[0].id}-to-${local.target.id}-v${var.pipeline_version_number}-dashboard" | ||
dashboard_body = <<EOF | ||
{ | ||
"periodOverride": "auto", | ||
"widgets": [ | ||
{ | ||
"type": "text", | ||
"x": 0, | ||
"y": 0, | ||
"width": 24, | ||
"height": 3, | ||
"properties": { | ||
"markdown": "${ | ||
replace(replace(replace(local.dashboard_markdown, "\\", "\\\\"), "\n", "\\n"), "\"", "\\\"") | ||
}" | ||
} | ||
}, | ||
{ | ||
"type": "metric", | ||
"x": 0, | ||
"y": 4, | ||
"width": 12, | ||
"height": 6, | ||
"properties": { | ||
"metrics": [ | ||
[ | ||
"ECS/ContainerInsights", "TaskCount", | ||
"ClusterName", "${module.ecs_cluster.ecs_cluster_name}" | ||
] | ||
], | ||
"period": 60, | ||
"stat": "Average", | ||
"region": "${var.environment.aws_region}", | ||
"title": "Running ECS Task", | ||
"yAxis": { | ||
"left": { | ||
"min": 0, | ||
"showUnits": false | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "metric", | ||
"x": 12, | ||
"y": 4, | ||
"width": 12, | ||
"height": 6, | ||
"properties": { | ||
"metrics": [ | ||
[ "ECS/ContainerInsights", "CpuReserved", "ClusterName", "${module.ecs_cluster.ecs_cluster_name}", { "id": "m1", "yAxis": "right", "visible": false } ], | ||
[ ".", "CpuUtilized", ".", ".", { "id": "m2", "yAxis": "right" } ], | ||
[ ".", "MemoryReserved", ".", ".", { "id": "m3", "yAxis": "right", "visible": false } ], | ||
[ ".", "MemoryUtilized", ".", ".", { "id": "m4", "yAxis": "right" } ], | ||
[ { "expression": "100*(m2/m1)", "label": "CpuUtilization", "id": "e1" } ], | ||
[ { "expression": "100*(m4/m3)", "label": "MemoryUtilization", "id": "e2" } ] | ||
], | ||
"view": "timeSeries", | ||
"stacked": false, | ||
"region": "${var.environment.aws_region}", | ||
"stat": "Average", | ||
"period": 300, | ||
"yAxis": { | ||
"left": { | ||
"min": 0, | ||
"max": 100, | ||
"label": "Percentage Usage" | ||
}, | ||
"right": { | ||
"label": "Reserved | Utilized", | ||
"showUnits": false, | ||
"min": 0 | ||
} | ||
}, | ||
"legend": { | ||
"position": "bottom" | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "log", | ||
"x": 0, | ||
"y": 9, | ||
"width": 24, | ||
"height": 12, | ||
"properties": { | ||
"query": "SOURCE '${module.ecs_tap_sync_task.cloudwatch_log_group_name}' | ${ | ||
replace(replace(replace(local.cloudwatch_query_text, "\\", "\\\\"), "\n", "\\n"), "\"", "\\\"") | ||
}", | ||
"region": "${var.environment.aws_region}", | ||
"stacked": "false", | ||
"view": "table" | ||
} | ||
} | ||
] | ||
} | ||
EOF | ||
} |
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
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