diff --git a/main.tf b/main.tf index 56366f5..a7f7f14 100644 --- a/main.tf +++ b/main.tf @@ -85,6 +85,11 @@ module "lightstep_aurora_dashboard" { lightstep_project = var.lightstep_project } +module "lightstep_cloudfront_dashboard" { + source = "./modules/cloudfront-dashboard" + lightstep_project = var.lightstep_project +} + module "lightstep_inspector_dashboard" { source = "./modules/inspector-dashboard" lightstep_project = var.lightstep_project @@ -93,4 +98,4 @@ module "lightstep_inspector_dashboard" { module "lightstep_natgateway_dashboard" { source = "./modules/natgateway-dashboard" lightstep_project = var.lightstep_project -} \ No newline at end of file +} diff --git a/modules/cloudfront-dashboard/main.tf b/modules/cloudfront-dashboard/main.tf new file mode 100644 index 0000000..1012ea3 --- /dev/null +++ b/modules/cloudfront-dashboard/main.tf @@ -0,0 +1,116 @@ +terraform { + required_providers { + lightstep = { + source = "lightstep/lightstep" + version = "~> 1.60.2" + } + } + required_version = ">= v1.0.11" +} + +resource "lightstep_metric_dashboard" "aws_cloudfront_dashboard" { + project_name = var.lightstep_project + dashboard_name = "AWS CloudFront" + + chart { + name = "Requests" + rank = "0" + type = "timeseries" + + query { + query_name = "a" + display = "bar" + hidden = false + + metric = "aws.cloudfront.requests_count" + timeseries_operator = "delta" + + + group_by { + aggregation_method = "sum" + keys = ["DistributionId", ] + } + + } + + } + + chart { + name = "4xx Error Rate" + rank = "1" + type = "timeseries" + + query { + query_name = "a" + display = "bar" + hidden = false + + metric = "aws.cloudfront.4_xx_error_rate_count" + timeseries_operator = "delta" + + + group_by { + aggregation_method = "sum" + keys = ["DistributionId", ] + } + + } + + query { + query_name = "b" + display = "bar" + hidden = false + + metric = "aws.cloudfront.5xx_error_rate_count" + timeseries_operator = "delta" + + + group_by { + aggregation_method = "sum" + keys = ["DistributionId", ] + } + + } + + } + + chart { + name = "Bytes Downloaded" + rank = "2" + type = "timeseries" + + query { + query_name = "a" + display = "bar" + hidden = false + + metric = "aws.cloudfront.bytes_downloaded_count" + timeseries_operator = "delta" + + + group_by { + aggregation_method = "sum" + keys = ["DistributionId", ] + } + + } + + query { + query_name = "b" + display = "bar" + hidden = false + + metric = "aws.cloudfront.bytes_uploaded_count" + timeseries_operator = "delta" + + + group_by { + aggregation_method = "sum" + keys = ["DistributionId", ] + } + + } + + } + +} diff --git a/modules/cloudfront-dashboard/outputs.tf b/modules/cloudfront-dashboard/outputs.tf new file mode 100644 index 0000000..69eef36 --- /dev/null +++ b/modules/cloudfront-dashboard/outputs.tf @@ -0,0 +1,4 @@ +output "dashboard_url" { + value = "https://app.lightstep.com/${var.lightstep_project}/dashboard/${lightstep_metric_dashboard.aws_cloudfront_dashboard.id}" + description = "CLOUDFRONT Dashboard URL" +} diff --git a/modules/cloudfront-dashboard/variables.tf b/modules/cloudfront-dashboard/variables.tf new file mode 100644 index 0000000..21ee69f --- /dev/null +++ b/modules/cloudfront-dashboard/variables.tf @@ -0,0 +1,4 @@ +variable "lightstep_project" { + description = "Name of Lightstep project" + type = string +} diff --git a/outputs.tf b/outputs.tf index da1e50b..6b18125 100644 --- a/outputs.tf +++ b/outputs.tf @@ -68,6 +68,10 @@ output "lightstep_aurora_dashboard_url" { description = "Lightstep AWS Aurora Dashboard URL" } +output "lightstep_cloudfront_dashboard_url" { + value = module.lightstep_cloudfront_dashboard.dashboard_url + description = "Lightstep AWS CLOUDFRONT Dashboard URL" + output "lightstep_inspector_dashboard_url" { value = module.lightstep_inspector_dashboard.dashboard_url description = "Lightstep AWS Inspector Dashboard URL"