Skip to content

Commit 4af170c

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

6 files changed

Lines changed: 22 additions & 0 deletions

File tree

aws/telemetry/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ module "telemetry" {
6363
| <a name="input_grafana_role_name"></a> [grafana\_role\_name](#input\_grafana\_role\_name) | Name of the IAM role created for Grafana | `string` | `"grafana"` | no |
6464
| <a name="input_grafana_workspace_name"></a> [grafana\_workspace\_name](#input\_grafana\_workspace\_name) | Name of the Grafana workspace which will use telemetry resources | `string` | `"Grafana"` | no |
6565
| <a name="input_kms_alias_name"></a> [kms\_alias\_name](#input\_kms\_alias\_name) | KMS alias name for SNS topics | `string` | `"alias/sns-alarm-topics"` | no |
66+
| <a name="input_log_group_arn"></a> [log\_group\_arn](#input\_log\_group\_arn) | ARN for the CW log group | `list(string)` | `[]` | no |
6667
| <a name="input_monitoring_account_ids"></a> [monitoring\_account\_ids](#input\_monitoring\_account\_ids) | AWS account IDs in which Grafana will run | `list(string)` | `null` | no |
6768
| <a name="input_prometheus_workspace_name"></a> [prometheus\_workspace\_name](#input\_prometheus\_workspace\_name) | Name of the AWS Managed Prometheus workspace | `string` | n/a | yes |
6869
| <a name="input_sns_topic_name_suffix"></a> [sns\_topic\_name\_suffix](#input\_sns\_topic\_name\_suffix) | Suffix for SNS topic names | `string` | `""` | no |

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+
log_group_arn = var.log_group_arn
2627
name = var.prometheus_workspace_name
2728
tags = var.tags
2829

aws/telemetry/modules/prometheus-workspace/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ write to the workspace.
4242
| <a name="input_alert_resolve_timeout"></a> [alert\_resolve\_timeout](#input\_alert\_resolve\_timeout) | Time after which alerts without an end time after resolved | `string` | `null` | no |
4343
| <a name="input_alert_subject_template"></a> [alert\_subject\_template](#input\_alert\_subject\_template) | Template used for AlertManager alert subjects | `string` | `null` | no |
4444
| <a name="input_alertmanager_config_enabled"></a> [alertmanager\_config\_enabled](#input\_alertmanager\_config\_enabled) | Enable alertmanager configs for the Prometheus workspace | `bool` | `true` | no |
45+
| <a name="input_log_group_arn"></a> [log\_group\_arn](#input\_log\_group\_arn) | ARN for the CW log group | `list(string)` | `[]` | no |
4546
| <a name="input_name"></a> [name](#input\_name) | Name for this Prometheus workspace | `string` | n/a | yes |
4647
| <a name="input_sns_receivers"></a> [sns\_receivers](#input\_sns\_receivers) | Map of alert priorities to SNS topics for AlertManager | `map(string)` | n/a | yes |
4748
| <a name="input_tags"></a> [tags](#input\_tags) | Tags to be applied to created resources | `map(string)` | `{}` | no |

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
resource "aws_prometheus_workspace" "this" {
22
alias = var.name
33
tags = var.tags
4+
5+
dynamic logging_configuration {
6+
for_each = var.log_group_arn
7+
content {
8+
log_group_arn = logging_configuration.value
9+
}
10+
}
411
}
512

613
resource "aws_iam_role" "ingestion" {

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

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

31+
variable "log_group_arn" {
32+
description = "ARN for the CW log group"
33+
type = list(string)
34+
default = []
35+
}
36+
3137
variable "name" {
3238
description = "Name for this Prometheus workspace"
3339
type = string

aws/telemetry/variables.tf

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

49+
variable "log_group_arn" {
50+
description = "ARN for the CW log group"
51+
type = list(string)
52+
default = []
53+
}
54+
4955
variable "grafana_role_name" {
5056
description = "Name of the IAM role created for Grafana"
5157
type = string

0 commit comments

Comments
 (0)