Skip to content

Commit c99ab2e

Browse files
committed
allow dynamic logging configuration in prometheus
1 parent 95c06cf commit c99ab2e

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

aws/telemetry/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module "prometheus_workspace" {
2323
alert_resolve_timeout = var.alert_resolve_timeout
2424
alert_subject_template = var.alert_subject_template
2525
alertmanager_config_enabled = var.alertmanager_config_enabled
26+
logging_group_name = var.logging_group_name
2627
name = var.prometheus_workspace_name
2728
tags = var.tags
2829

aws/telemetry/modules/prometheus-workspace/main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
resource "aws_prometheus_workspace" "this" {
22
alias = var.name
33
tags = var.tags
4+
5+
dynamic logging_configuration {
6+
for_each = var.logging_group_name
7+
content {
8+
log_group_arn = data.aws_cloudwatch_log_group.this.arn
9+
}
10+
}
11+
}
12+
13+
data "aws_cloudwatch_log_group" "this" {
14+
count = var.logging_group_name ? 1 : 0
15+
name = var.logging_group_name
416
}
517

618
resource "aws_iam_role" "ingestion" {

aws/telemetry/modules/prometheus-workspace/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ variable "alertmanager_config_enabled" {
2828
default = true
2929
}
3030

31+
variable "logging_group_name" {
32+
description = "Name of Cloudwatch logging group for Prometheus workspace"
33+
type = string
34+
}
35+
3136
variable "name" {
3237
description = "Name for this Prometheus workspace"
3338
type = string

aws/telemetry/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ variable "alertmanager_config_enabled" {
4646
default = true
4747
}
4848

49+
variable "logging_group_name" {
50+
description = "Name of Cloudwatch logging group for Prometheus workspace"
51+
type = string
52+
}
53+
4954
variable "grafana_role_name" {
5055
description = "Name of the IAM role created for Grafana"
5156
type = string

0 commit comments

Comments
 (0)