diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml new file mode 100644 index 0000000..c450bfb --- /dev/null +++ b/.github/workflows/documentation.yaml @@ -0,0 +1,29 @@ +name: Generate terraform docs + +on: + push: + # don't run when we push a tag + tags-ignore: + - '*' + # don't run when we merge to main + # the action should have run already + branches-ignore: + - 'main' +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: terraform-linters/setup-tflint@v2 + name: Setup TFLint + with: + tflint_version: v0.38.1 + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + - uses: pre-commit/action@v3.0.0 + # pre-commit fails if it changed files + # we want to go on + continue-on-error: true + - uses: pre-commit/action@v3.0.0 + - uses: EndBug/add-and-commit@v9 + with: + default_author: github_actions diff --git a/.gitignore b/.gitignore index 3fa8c86..bf88522 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .terraform +examples/.terraform.lock.hcl diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d3fb051..2ec62ae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,10 +5,9 @@ repos: - id: terraform-fmt - id: terraform-validate - id: tflint - - repo: git@github.com:kabisa/terraform-datadog-pre-commit-hook.git - rev: "0.1.15" + - repo: https://github.com/kabisa/terraform-datadog-pre-commit-hook + rev: "1.3.6" hooks: - id: terraform-datadog-docs - exclude: ^README.md$ args: - "." \ No newline at end of file diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl index 8bcdcfc..56c8cad 100644 --- a/.terraform.lock.hcl +++ b/.terraform.lock.hcl @@ -2,9 +2,24 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/datadog/datadog" { - version = "3.8.1" - constraints = ">= 2.21.0, ~> 3.4" + version = "3.13.1" + constraints = "~> 3.12" hashes = [ - "h1:iE/+ZYGemTxba6KHRzY93Ac9g46Z3ZJt846SbR5WgMM=", + "h1:J90dvYReKwVQhAMm1zQNlgY5b3jZGi9y4AB5x5eXpVE=", + "h1:SU8D6fk0yfR8Q3yQEV+25Z82+sfEIqQBbMqxOvfHQJk=", + "zh:0aaed8667976f5c9ccd1e76eacdbd9772296904e6bd7d9c5a615f3c936bc4892", + "zh:17b8daaf3d89247e88e304c46491577915a9951e3135ed909fa1b784cb120a9e", + "zh:3fd8a1eb8b3a2998d27966621b7556e62c83bb2035a0039fe122186d1972f216", + "zh:67c4a170002608d9b9f0352836a7e3c35e95a43b9d22a8c8fb89b77e32827a9a", + "zh:73a198c6bfd3aa4c420540018d1b5a26fa575264c72711474c684f1caaa5a3dc", + "zh:78a6169c826b41b9ed71c9e6e2f961ec348bd777adad050d4a0537a25c276c13", + "zh:7b5ffe43cbfdda0d09e012b524ebbb9ace16ed1c2b22affbda8b32027fab3132", + "zh:85889fdb7f51ea1c41d37d19242ac85d3943944f9893ee90d526f51be3b0f8e5", + "zh:873b5daeb60ed11050bfc6aabb93a1b407b3828c20c71b43cc98deca3436741f", + "zh:947a495655fe76f4b11553625b63ce1cbf62e03eb59725ad64598a651373e03d", + "zh:97d10341958214c7434eac729a66fbd0eacbccd4544bffb3242e30379c5b2d53", + "zh:aeb24bd3a40f0b349192a746c1a61f678ccf20ba14c5929d8a43c12ce7ce35ce", + "zh:c4713613f1d12977d390d40e47e185a31cb08919bec09470858b37c52da4148f", + "zh:ea463300f3d1b25c12a000821f770dc71be771cdb56288e74f282afb2317a46a", ] } diff --git a/README.md b/README.md index 3e8cced..852329c 100644 --- a/README.md +++ b/README.md @@ -1,61 +1,83 @@ ![Datadog](https://imgix.datadoghq.com/img/about/presskit/logo-v/dd_vertical_purple.png) -[//]: # (This file is generated. Do not edit) +[//]: # (This file is generated. Do not edit, module description can be added by editing / creating module_description.md) # Terraform module for Datadog Costs -Monitors: -* [Terraform module for Datadog Costs](#terraform-module-for-datadog-costs) - * [Containers](#containers) - * [Apm Hosts](#apm-hosts) - * [Hosts](#hosts) - * [Custom Metrics](#custom-metrics) - * [Apm Spans](#apm-spans) - * [Logs Ingestion 4h](#logs-ingestion-4h) - * [Logs Ingestion](#logs-ingestion) - * [Logs Indexed](#logs-indexed) - * [Module Variables](#module-variables) - -# Getting started -[pre-commit](http://pre-commit.com/) was used to do Terraform linting and validating. +This module will set up alerts to make sure you don't suddenly overspend on you datadog bill. +It will also generate a costs dashboard -Steps: - - Install [pre-commit](http://pre-commit.com/). E.g. `brew install pre-commit`. - - Run `pre-commit install` in this repo. (Every time you cloud a repo with pre-commit enabled you will need to run the pre-commit install command) - - That’s it! Now every time you commit a code change (`.tf` file), the hooks in the `hooks:` config `.pre-commit-config.yaml` will execute. +This module is part of a larger suite of modules that provide alerts in Datadog. +Other modules can be found on the [Terraform Registry](https://registry.terraform.io/search/modules?namespace=kabisa&provider=datadog) -## Containers +We have two base modules we use to standardise development of our Monitor Modules: +- [generic monitor](https://github.com/kabisa/terraform-datadog-generic-monitor) Used in 90% of our alerts +- [service check monitor](https://github.com/kabisa/terraform-datadog-service-check-monitor) + +Modules are generated with this tool: https://github.com/kabisa/datadog-terraform-generator + +# Example Usage -Query: ```terraform -avg(${var.containers_evaluation_period}):sum:datadog.estimated_usage.containers{${local.containers_filter}} > ${var.containers_critical} +module "costs" { + source = "kabisa/costs/datadog" + + notification_channel = "@mail@example.com" + env = "prd" + alert_env = "prd" + + # Example config, please adjust + filter_str = "*" + apm_hosts_critical = 2 + apm_spans_critical = 1000000 + apm_spans_warning = 800000 + containers_critical = 375 + custom_metrics_critical = 10000 + hosts_critical = 20 + logs_indexed_critical = 150000 + logs_ingestion_4h_critical = 208000000 + logs_ingestion_critical = 850000000 + logs_ingestion_warning = 600000000 +} + ``` -| variable | default | required | description | -|------------------------------|----------|----------|----------------------------------| -| containers_enabled | True | No | | -| containers_warning | null | No | | -| containers_critical | | Yes | | -| containers_evaluation_period | last_1h | No | | -| containers_note | "" | No | | -| containers_docs | "" | No | | -| containers_filter_override | "" | No | | -| containers_alerting_enabled | True | No | | -| containers_priority | 4 | No | Number from 1 (high) to 5 (low). | +[Module Variables](#module-variables) + +Monitors: + +| Monitor name | Default enabled | Priority | Query | +|-----------------|------|----|------------------------| +| [Apm Hosts](#apm-hosts) | True | 4 | `avg(last_1h):sum:datadog.estimated_usage.apm_hosts{tag:xxx} > ` | +| [Apm Spans](#apm-spans) | True | 3 | `sum(last_1h):sum:datadog.estimated_usage.apm.indexed_spans{tag:xxx}.as_count() > ` | +| [Containers](#containers) | True | 4 | `avg(last_1h):sum:datadog.estimated_usage.containers{tag:xxx} > ` | +| [Custom Metrics](#custom-metrics) | True | 4 | `avg(last_1h):sum:datadog.estimated_usage.metrics.custom{tag:xxx} > ` | +| [Hosts](#hosts) | True | 4 | `avg(last_1h):sum:datadog.estimated_usage.hosts{tag:xxx} > ` | +| [Logs Indexed](#logs-indexed) | True | 3 | `sum(last_4h):sum:custom_datadog.estimated_usage.logs.ingested_events{tag:xxx}.as_count() > ` | +| [Logs Ingestion 4h](#logs-ingestion-4h) | True | 3 | `sum(last_4h):sum:custom_datadog.estimated_usage.logs.ingested_bytes{tag:xxx}.as_count() > ` | +| [Logs Ingestion](#logs-ingestion) | True | 3 | `sum(last_1d):sum:custom_datadog.estimated_usage.logs.ingested_bytes{tag:xxx}.as_count() > ` | + +# Getting started developing +[pre-commit](http://pre-commit.com/) was used to do Terraform linting and validating. + +Steps: + - Install [pre-commit](http://pre-commit.com/). E.g. `brew install pre-commit`. + - Run `pre-commit install` in this repo. (Every time you clone a repo with pre-commit enabled you will need to run the pre-commit install command) + - That’s it! Now every time you commit a code change (`.tf` file), the hooks in the `hooks:` config `.pre-commit-config.yaml` will execute. ## Apm Hosts Query: ```terraform -avg(${var.apm_hosts_evaluation_period}):sum:datadog.estimated_usage.apm_hosts{${local.apm_hosts_filter}} > ${var.apm_hosts_critical} +avg(last_1h):sum:datadog.estimated_usage.apm_hosts{tag:xxx} > ``` | variable | default | required | description | |-----------------------------|----------|----------|----------------------------------| | apm_hosts_enabled | True | No | | -| apm_hosts_warning | null | No | | +| apm_hosts_warning | None | No | | | apm_hosts_critical | | Yes | | | apm_hosts_evaluation_period | last_1h | No | | | apm_hosts_note | "" | No | | @@ -65,37 +87,57 @@ avg(${var.apm_hosts_evaluation_period}):sum:datadog.estimated_usage.apm_hosts{${ | apm_hosts_priority | 4 | No | Number from 1 (high) to 5 (low). | -## Hosts +## Apm Spans Query: ```terraform -avg(${var.hosts_evaluation_period}):sum:datadog.estimated_usage.hosts{${local.hosts_filter}} > ${var.hosts_critical} +sum(last_1h):sum:datadog.estimated_usage.apm.indexed_spans{tag:xxx}.as_count() > ``` -| variable | default | required | description | -|-------------------------|----------|----------|----------------------------------| -| hosts_enabled | True | No | | -| hosts_warning | null | No | | -| hosts_critical | | Yes | | -| hosts_evaluation_period | last_1h | No | | -| hosts_note | "" | No | | -| hosts_docs | "" | No | | -| hosts_filter_override | "" | No | | -| hosts_alerting_enabled | True | No | | -| hosts_priority | 4 | No | Number from 1 (high) to 5 (low). | +| variable | default | required | description | +|-----------------------------|----------|----------|----------------------------------| +| apm_spans_enabled | True | No | | +| apm_spans_warning | | Yes | | +| apm_spans_critical | | Yes | | +| apm_spans_evaluation_period | last_1h | No | | +| apm_spans_note | "" | No | | +| apm_spans_docs | "" | No | | +| apm_spans_filter_override | "" | No | | +| apm_spans_alerting_enabled | True | No | | +| apm_spans_priority | 3 | No | Number from 1 (high) to 5 (low). | + + +## Containers + +Query: +```terraform +avg(last_1h):sum:datadog.estimated_usage.containers{tag:xxx} > +``` + +| variable | default | required | description | +|------------------------------|----------|----------|----------------------------------| +| containers_enabled | True | No | | +| containers_warning | None | No | | +| containers_critical | | Yes | | +| containers_evaluation_period | last_1h | No | | +| containers_note | "" | No | | +| containers_docs | "" | No | | +| containers_filter_override | "" | No | | +| containers_alerting_enabled | True | No | | +| containers_priority | 4 | No | Number from 1 (high) to 5 (low). | ## Custom Metrics Query: ```terraform -avg(${var.custom_metrics_evaluation_period}):sum:datadog.estimated_usage.metrics.custom{${local.custom_metrics_filter}} > ${var.custom_metrics_critical} +avg(last_1h):sum:datadog.estimated_usage.metrics.custom{tag:xxx} > ``` | variable | default | required | description | |----------------------------------|----------|----------|----------------------------------| | custom_metrics_enabled | True | No | | -| custom_metrics_warning | null | No | | +| custom_metrics_warning | None | No | | | custom_metrics_critical | | Yes | | | custom_metrics_evaluation_period | last_1h | No | | | custom_metrics_note | "" | No | | @@ -105,38 +147,58 @@ avg(${var.custom_metrics_evaluation_period}):sum:datadog.estimated_usage.metrics | custom_metrics_priority | 4 | No | Number from 1 (high) to 5 (low). | -## Apm Spans +## Hosts Query: ```terraform -sum(${var.apm_spans_evaluation_period}):sum:datadog.estimated_usage.apm.indexed_spans{${local.apm_spans_filter}}.as_count() > ${var.apm_spans_critical} +avg(last_1h):sum:datadog.estimated_usage.hosts{tag:xxx} > ``` -| variable | default | required | description | -|-----------------------------|----------|----------|----------------------------------| -| apm_spans_enabled | True | No | | -| apm_spans_warning | | Yes | | -| apm_spans_critical | | Yes | | -| apm_spans_evaluation_period | last_1h | No | | -| apm_spans_note | "" | No | | -| apm_spans_docs | "" | No | | -| apm_spans_filter_override | "" | No | | -| apm_spans_alerting_enabled | True | No | | -| apm_spans_priority | 3 | No | Number from 1 (high) to 5 (low). | +| variable | default | required | description | +|-------------------------|----------|----------|----------------------------------| +| hosts_enabled | True | No | | +| hosts_warning | None | No | | +| hosts_critical | | Yes | | +| hosts_evaluation_period | last_1h | No | | +| hosts_note | "" | No | | +| hosts_docs | "" | No | | +| hosts_filter_override | "" | No | | +| hosts_alerting_enabled | True | No | | +| hosts_priority | 4 | No | Number from 1 (high) to 5 (low). | + + +## Logs Indexed + +Query: +```terraform +sum(last_4h):sum:custom_datadog.estimated_usage.logs.ingested_events{tag:xxx}.as_count() > +``` + +| variable | default | required | description | +|--------------------------------|----------|----------|----------------------------------| +| logs_indexed_enabled | True | No | | +| logs_indexed_warning | None | No | | +| logs_indexed_critical | | Yes | | +| logs_indexed_evaluation_period | last_4h | No | | +| logs_indexed_note | "" | No | | +| logs_indexed_docs | "" | No | | +| logs_indexed_filter_override | "" | No | | +| logs_indexed_alerting_enabled | True | No | | +| logs_indexed_priority | 3 | No | Number from 1 (high) to 5 (low). | ## Logs Ingestion 4h Query: ```terraform -sum(${var.logs_ingestion_4h_evaluation_period}):sum:custom_datadog.estimated_usage.logs.ingested_bytes{${local.logs_ingestion_4h_filter}}.as_count() > ${var.logs_ingestion_4h_critical} +sum(last_4h):sum:custom_datadog.estimated_usage.logs.ingested_bytes{tag:xxx}.as_count() > ``` | variable | default | required | description | |-------------------------------------|----------|----------|----------------------------------| | logs_ingestion_4h_enabled | True | No | | -| logs_ingestion_4h_warning | null | No | | -| logs_ingestion_4h_critical | null | No | | +| logs_ingestion_4h_warning | None | No | | +| logs_ingestion_4h_critical | None | No | | | logs_ingestion_4h_evaluation_period | last_4h | No | | | logs_ingestion_4h_note | "" | No | | | logs_ingestion_4h_docs | "" | No | | @@ -149,7 +211,7 @@ sum(${var.logs_ingestion_4h_evaluation_period}):sum:custom_datadog.estimated_usa Query: ```terraform -sum(${var.logs_ingestion_evaluation_period}):sum:custom_datadog.estimated_usage.logs.ingested_bytes{${local.logs_ingestion_filter}}.as_count() > ${var.logs_ingestion_critical} +sum(last_1d):sum:custom_datadog.estimated_usage.logs.ingested_bytes{tag:xxx}.as_count() > ``` | variable | default | required | description | @@ -165,32 +227,11 @@ sum(${var.logs_ingestion_evaluation_period}):sum:custom_datadog.estimated_usage. | logs_ingestion_priority | 3 | No | Number from 1 (high) to 5 (low). | -## Logs Indexed - -Query: -```terraform -sum(${var.logs_indexed_evaluation_period}):sum:custom_datadog.estimated_usage.logs.ingested_events{${local.logs_indexed_filter}}.as_count() > ${var.logs_indexed_critical} -``` - -| variable | default | required | description | -|--------------------------------|----------|----------|----------------------------------| -| logs_indexed_enabled | True | No | | -| logs_indexed_warning | null | No | | -| logs_indexed_critical | | Yes | | -| logs_indexed_evaluation_period | last_4h | No | | -| logs_indexed_note | "" | No | | -| logs_indexed_docs | "" | No | | -| logs_indexed_filter_override | "" | No | | -| logs_indexed_alerting_enabled | True | No | | -| logs_indexed_priority | 3 | No | Number from 1 (high) to 5 (low). | - - ## Module Variables | variable | default | required | description | |-------------------------------|----------|----------|--------------| | env | | Yes | | -| alert_env | | Yes | | | service | Costs | No | | | notification_channel | | Yes | | | additional_tags | [] | No | | diff --git a/apm-hosts-variables.tf b/apm-hosts-variables.tf index 169c5e0..d542978 100644 --- a/apm-hosts-variables.tf +++ b/apm-hosts-variables.tf @@ -42,4 +42,4 @@ variable "apm_hosts_priority" { type = number default = 4 -} \ No newline at end of file +} diff --git a/apm-hosts.tf b/apm-hosts.tf index 883dd7b..56b304e 100644 --- a/apm-hosts.tf +++ b/apm-hosts.tf @@ -6,7 +6,8 @@ locals { } module "apm_hosts" { - source = "git@github.com:kabisa/terraform-datadog-generic-monitor.git?ref=0.7.0" + source = "kabisa/generic-monitor/datadog" + version = "1.0.0" name = "Estimated APM Hosts Usage" query = "avg(${var.apm_hosts_evaluation_period}):sum:datadog.estimated_usage.apm_hosts{${local.apm_hosts_filter}} > ${var.apm_hosts_critical}" @@ -23,7 +24,7 @@ module "apm_hosts" { note = var.apm_hosts_note # module level vars - env = var.alert_env + env = var.env service = var.service notification_channel = var.notification_channel additional_tags = var.additional_tags diff --git a/apm-spans-variables.tf b/apm-spans-variables.tf index 9b2620b..ae58ad3 100644 --- a/apm-spans-variables.tf +++ b/apm-spans-variables.tf @@ -41,4 +41,4 @@ variable "apm_spans_priority" { type = number default = 3 -} \ No newline at end of file +} diff --git a/apm-spans.tf b/apm-spans.tf index e870583..25e04e3 100644 --- a/apm-spans.tf +++ b/apm-spans.tf @@ -4,7 +4,8 @@ locals { } module "apm_spans" { - source = "git@github.com:kabisa/terraform-datadog-generic-monitor.git?ref=0.7.0" + source = "kabisa/generic-monitor/datadog" + version = "1.0.0" name = "Estimated APM Analyzed Spans Usage" query = "sum(${var.apm_spans_evaluation_period}):sum:datadog.estimated_usage.apm.indexed_spans{${local.apm_spans_filter}}.as_count() > ${var.apm_spans_critical}" @@ -21,7 +22,7 @@ module "apm_spans" { note = var.apm_spans_note # module level vars - env = var.alert_env + env = var.env service = var.service notification_channel = var.notification_channel additional_tags = var.additional_tags diff --git a/containers-variables.tf b/containers-variables.tf index f4dea9f..1f63605 100644 --- a/containers-variables.tf +++ b/containers-variables.tf @@ -42,4 +42,4 @@ variable "containers_priority" { type = number default = 4 -} \ No newline at end of file +} diff --git a/containers.tf b/containers.tf index c68fa31..5189846 100644 --- a/containers.tf +++ b/containers.tf @@ -4,7 +4,8 @@ locals { } module "containers" { - source = "git@github.com:kabisa/terraform-datadog-generic-monitor.git?ref=0.7.0" + source = "kabisa/generic-monitor/datadog" + version = "1.0.0" name = "Estimated Containers Usage" query = "avg(${var.containers_evaluation_period}):sum:datadog.estimated_usage.containers{${local.containers_filter}} > ${var.containers_critical}" @@ -21,7 +22,7 @@ module "containers" { note = var.containers_note # module level vars - env = var.alert_env + env = var.env service = var.service notification_channel = var.notification_channel additional_tags = var.additional_tags diff --git a/custom-metrics-variables.tf b/custom-metrics-variables.tf index 7cb3342..5ec28aa 100644 --- a/custom-metrics-variables.tf +++ b/custom-metrics-variables.tf @@ -42,4 +42,4 @@ variable "custom_metrics_priority" { type = number default = 4 -} \ No newline at end of file +} diff --git a/custom-metrics.tf b/custom-metrics.tf index d4bb24d..265ddbf 100644 --- a/custom-metrics.tf +++ b/custom-metrics.tf @@ -4,7 +4,8 @@ locals { } module "custom_metrics" { - source = "git@github.com:kabisa/terraform-datadog-generic-monitor.git?ref=0.7.0" + source = "kabisa/generic-monitor/datadog" + version = "1.0.0" name = "Estimated Custom Metrics Usage" query = "avg(${var.custom_metrics_evaluation_period}):sum:datadog.estimated_usage.metrics.custom{${local.custom_metrics_filter}} > ${var.custom_metrics_critical}" @@ -21,7 +22,7 @@ module "custom_metrics" { note = var.custom_metrics_note # module level vars - env = var.alert_env + env = var.env service = var.service notification_channel = var.notification_channel additional_tags = var.additional_tags diff --git a/examples/example.tf b/examples/example.tf new file mode 100644 index 0000000..c0e41fa --- /dev/null +++ b/examples/example.tf @@ -0,0 +1,21 @@ +# tflint-ignore: terraform_module_version +module "costs" { + source = "kabisa/costs/datadog" + + notification_channel = "@mail@example.com" + env = "prd" + alert_env = "prd" + + # Example config, please adjust + filter_str = "*" + apm_hosts_critical = 2 + apm_spans_critical = 1000000 + apm_spans_warning = 800000 + containers_critical = 375 + custom_metrics_critical = 10000 + hosts_critical = 20 + logs_indexed_critical = 150000 + logs_ingestion_4h_critical = 208000000 + logs_ingestion_critical = 850000000 + logs_ingestion_warning = 600000000 +} diff --git a/hosts-variables.tf b/hosts-variables.tf index fff57a8..c449cfc 100644 --- a/hosts-variables.tf +++ b/hosts-variables.tf @@ -42,4 +42,4 @@ variable "hosts_priority" { type = number default = 4 -} \ No newline at end of file +} diff --git a/hosts.tf b/hosts.tf index 0b429c1..097774c 100644 --- a/hosts.tf +++ b/hosts.tf @@ -4,7 +4,8 @@ locals { } module "hosts" { - source = "git@github.com:kabisa/terraform-datadog-generic-monitor.git?ref=0.7.0" + source = "kabisa/generic-monitor/datadog" + version = "1.0.0" name = "Estimated Hosts Usage" query = "avg(${var.hosts_evaluation_period}):sum:datadog.estimated_usage.hosts{${local.hosts_filter}} > ${var.hosts_critical}" @@ -21,7 +22,7 @@ module "hosts" { note = var.hosts_note # module level vars - env = var.alert_env + env = var.env service = var.service notification_channel = var.notification_channel additional_tags = var.additional_tags diff --git a/logs-indexed-variables.tf b/logs-indexed-variables.tf index 55b2d8d..3ab0c0a 100644 --- a/logs-indexed-variables.tf +++ b/logs-indexed-variables.tf @@ -42,4 +42,4 @@ variable "logs_indexed_priority" { type = number default = 3 -} \ No newline at end of file +} diff --git a/logs-indexed.tf b/logs-indexed.tf index d6bfef3..2de848b 100644 --- a/logs-indexed.tf +++ b/logs-indexed.tf @@ -4,7 +4,8 @@ locals { } module "logs_indexed" { - source = "git@github.com:kabisa/terraform-datadog-generic-monitor.git?ref=0.7.0" + source = "kabisa/generic-monitor/datadog" + version = "1.0.0" name = "Indexed Logs" query = "sum(${var.logs_indexed_evaluation_period}):sum:custom_datadog.estimated_usage.logs.ingested_events{${local.logs_indexed_filter}}.as_count() > ${var.logs_indexed_critical}" @@ -21,7 +22,7 @@ module "logs_indexed" { note = var.logs_indexed_note # module level vars - env = var.alert_env + env = var.env service = var.service notification_channel = var.notification_channel additional_tags = var.additional_tags diff --git a/logs-ingestion-4h-variables.tf b/logs-ingestion-4h-variables.tf index 18952d0..03f20ae 100644 --- a/logs-ingestion-4h-variables.tf +++ b/logs-ingestion-4h-variables.tf @@ -43,4 +43,4 @@ variable "logs_ingestion_4h_priority" { type = number default = 3 -} \ No newline at end of file +} diff --git a/logs-ingestion-4h.tf b/logs-ingestion-4h.tf index 7cd5549..1dbe469 100644 --- a/logs-ingestion-4h.tf +++ b/logs-ingestion-4h.tf @@ -4,7 +4,8 @@ locals { } module "logs_ingestion_4h" { - source = "git@github.com:kabisa/terraform-datadog-generic-monitor.git?ref=0.7.0" + source = "kabisa/generic-monitor/datadog" + version = "1.0.0" name = "Logs ingestion high" query = "sum(${var.logs_ingestion_4h_evaluation_period}):sum:custom_datadog.estimated_usage.logs.ingested_bytes{${local.logs_ingestion_4h_filter}}.as_count() > ${var.logs_ingestion_4h_critical}" @@ -21,7 +22,7 @@ module "logs_ingestion_4h" { note = var.logs_ingestion_4h_note # module level vars - env = var.alert_env + env = var.env service = var.service notification_channel = var.notification_channel additional_tags = var.additional_tags diff --git a/logs-ingestion-variables.tf b/logs-ingestion-variables.tf index 425626a..39c6f0e 100644 --- a/logs-ingestion-variables.tf +++ b/logs-ingestion-variables.tf @@ -41,4 +41,4 @@ variable "logs_ingestion_priority" { type = number default = 3 -} \ No newline at end of file +} diff --git a/logs-ingestion.tf b/logs-ingestion.tf index a3edcbe..cc8bc38 100644 --- a/logs-ingestion.tf +++ b/logs-ingestion.tf @@ -4,7 +4,8 @@ locals { } module "logs_ingestion" { - source = "git@github.com:kabisa/terraform-datadog-generic-monitor.git?ref=0.7.0" + source = "kabisa/generic-monitor/datadog" + version = "1.0.0" name = "Daily Logs Ingestion" query = "sum(${var.logs_ingestion_evaluation_period}):sum:custom_datadog.estimated_usage.logs.ingested_bytes{${local.logs_ingestion_filter}}.as_count() > ${var.logs_ingestion_critical}" @@ -21,7 +22,7 @@ module "logs_ingestion" { note = var.logs_ingestion_note # module level vars - env = var.alert_env + env = var.env service = var.service notification_channel = var.notification_channel additional_tags = var.additional_tags diff --git a/module_description.md b/module_description.md new file mode 100644 index 0000000..5eb5d9f --- /dev/null +++ b/module_description.md @@ -0,0 +1,2 @@ +This module will set up alerts to make sure you don't suddenly overspend on you datadog bill. +It will also generate a costs dashboard \ No newline at end of file diff --git a/provider.tf b/provider.tf index 347f334..966318e 100644 --- a/provider.tf +++ b/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { datadog = { source = "DataDog/datadog" - version = "~> 3.4" + version = "~> 3.12" } } } \ No newline at end of file diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..39a2b6e --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base" + ] +} diff --git a/variables.tf b/variables.tf index 6fce693..842429f 100644 --- a/variables.tf +++ b/variables.tf @@ -2,10 +2,6 @@ variable "env" { type = string } -variable "alert_env" { - type = string -} - variable "service" { type = string default = "Costs"