diff --git a/CHANGELOG.md b/CHANGELOG.md index 01fde7d..095b154 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## v5.0.0 +- BREAKING: Removed Alertmanager app from this module. This module still supports alert managers and it now accepts a list of alert managers endpoints. +- The alertmanager app is now a separate module at [philips-labs/terraform-cloudfoundry-alertmanager](https://github.com/philips-labs/terraform-cloudfoundry-alertmanager) + ## v4.4.1 - Deploy improvements diff --git a/README.md b/README.md index 1e2d488..0964921 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,6 @@ Setup for Prometheus + Thanos on Cloudfoundry. This provides a path towards unli - Deploys a Thanos instance with S3 Bucket as storage - [Variant](https://github.com/philips-software/variant) sidecar for scrape target and rule discovery - Alertmanager support -- Teams notification support - ## Example of Thanos Terraform ``` diff --git a/alertmanager.tf b/alertmanager.tf deleted file mode 100644 index fb85df3..0000000 --- a/alertmanager.tf +++ /dev/null @@ -1,80 +0,0 @@ -locals { - alertmanager_routes = [cloudfoundry_route.alertmanager_internal.id] - - webhook_url = var.teams_incoming_webhook_url != "" ? "http://${cloudfoundry_route.prometheusmsteams_internal[0].endpoint}:2000/alertmanager" : "http://localhost:5001" - - alertmanager_config = local.alertmanager.config_file == "" ? templatefile("${path.module}/templates/alertmanager.yml", { url = local.webhook_url }) : local.alertmanager.config_file -} - -resource "cloudfoundry_app" "prometheusmsteams" { - count = var.teams_incoming_webhook_url != "" ? 1 : 0 - name = "tf-prometheusmsteams-${local.postfix}" - space = var.cf_space_id - docker_image = "quay.io/prometheusmsteams/prometheus-msteams" - memory = 64 - disk_quota = 1024 - environment = { - TEAMS_REQUEST_URI = "alertmanager" - TEAMS_INCOMING_WEBHOOK_URL = var.teams_incoming_webhook_url - } - - routes { - route = cloudfoundry_route.prometheusmsteams_internal[count.index].id - } -} - -resource "cloudfoundry_route" "prometheusmsteams_internal" { - count = var.teams_incoming_webhook_url != "" ? 1 : 0 - domain = data.cloudfoundry_domain.apps_internal_domain.id - space = var.cf_space_id - hostname = "tf-prometheusmsteams-${local.postfix}" -} - -resource "cloudfoundry_app" "alertmanager" { - name = "tf-alertmanager-${local.postfix}" - space = var.cf_space_id - memory = local.alertmanager.memory - disk_quota = 2048 - docker_image = local.alertmanager.docker_image - docker_credentials = { - username = local.alertmanager.docker_username - password = local.alertmanager.docker_password - } - environment = merge({ - ALERTMANAGER_CONFIG_BASE64 = base64encode(local.alertmanager_config) - }, var.environment) - command = "echo $ALERTMANAGER_CONFIG_BASE64 | base64 -d > /etc/alertmanager/alertmanager.yml && /bin/alertmanager --config.file=/etc/alertmanager/alertmanager.yml --storage.path=/alertmanager --web.route-prefix=/alertmanager" - - dynamic "routes" { - for_each = local.alertmanager_routes - content { - route = routes.value - } - } -} - -resource "cloudfoundry_route" "alertmanager_internal" { - domain = data.cloudfoundry_domain.apps_internal_domain.id - space = var.cf_space_id - hostname = "tf-alertmanager-${local.postfix}" -} - -resource "cloudfoundry_network_policy" "prometheusmsteams" { - count = var.teams_incoming_webhook_url != "" ? 1 : 0 - - policy { - source_app = cloudfoundry_app.alertmanager.id - destination_app = cloudfoundry_app.prometheusmsteams[count.index].id - protocol = "tcp" - port = "2000" - } -} - -resource "cloudfoundry_network_policy" "alertmanager" { - policy { - source_app = cloudfoundry_app.thanos.id - destination_app = cloudfoundry_app.alertmanager.id - protocol = "tcp" - port = "9093" - } -} diff --git a/main.tf b/main.tf index ef60ab0..4544ef4 100644 --- a/main.tf +++ b/main.tf @@ -2,7 +2,7 @@ locals { thanos_routes = var.thanos_public_endpoints ? [cloudfoundry_route.thanos.id, cloudfoundry_route.thanos_internal.id] : [cloudfoundry_route.thanos_internal.id] postfix = var.name_postfix != "" ? var.name_postfix : random_id.id.hex prometheus_config = templatefile("${path.module}/templates/prometheus.yml", { - alertmanagers = ["0.tf-alertmanager-${local.postfix}.apps.internal:9093"] + alertmanagers = var.alertmanagers_endpoints }) } diff --git a/outputs.tf b/outputs.tf index 88c5c22..282a2cf 100644 --- a/outputs.tf +++ b/outputs.tf @@ -37,13 +37,3 @@ output "thanos_store_endpoint" { description = "Internal only URL of Thanos store deployment" value = "${cloudfoundry_route.thanos_store_internal.endpoint}:9090" } - -output "alertmanager_app_id" { - description = "App id of Alertmanager" - value = cloudfoundry_app.alertmanager.id -} - -output "alertmanager_internal_endpoint" { - description = "Internal route of alertmanager" - value = "${cloudfoundry_route.alertmanager_internal.endpoint}:9093" -} diff --git a/templates/alertmanager.yml b/templates/alertmanager.yml deleted file mode 100644 index a0a1780..0000000 --- a/templates/alertmanager.yml +++ /dev/null @@ -1,10 +0,0 @@ -route: - group_by: ['alertname'] - group_wait: 30s - group_interval: 5m - repeat_interval: 1h - receiver: 'web.hook' -receivers: - - name: 'web.hook' - webhook_configs: - - url: '${url}' diff --git a/variables.tf b/variables.tf index 2725a9c..e0e98d4 100644 --- a/variables.tf +++ b/variables.tf @@ -142,21 +142,8 @@ variable "cf_paas_exporter_disk_quota" { default = 100 } -variable "alertmanager" { - type = object({ - docker_image = optional(string) - memory = optional(string) - config_file = optional(string) - docker_username = optional(string) - docker_password = optional(string) - }) - default = {} -} - -locals { - alertmanager = defaults(var.alertmanager, { - memory = 128 - docker_image = "prom/alertmanager:v0.23.0" - config_file = "" - }) -} +variable "alertmanagers_endpoints" { + type = list(string) + description = "List of endpoints of the alert managers" + default = [] +} \ No newline at end of file