From 6e323fc0765d05cd01159e7205dfb0f98ef06d62 Mon Sep 17 00:00:00 2001 From: Sjuul Janssen Date: Thu, 3 Feb 2022 10:01:04 +0100 Subject: [PATCH 1/5] docs --- examples/example.tf | 20 ++++++++++++++++++++ module_description.md | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 examples/example.tf create mode 100644 module_description.md diff --git a/examples/example.tf b/examples/example.tf new file mode 100644 index 0000000..8725a51 --- /dev/null +++ b/examples/example.tf @@ -0,0 +1,20 @@ +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 +} \ No newline at end of file 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 From 03fe0a25fce7bdfe6cc3b9b752375156fb306225 Mon Sep 17 00:00:00 2001 From: Sjuul Janssen Date: Thu, 3 Feb 2022 10:03:27 +0100 Subject: [PATCH 2/5] docs --- .pre-commit-config.yaml | 2 +- README.md | 71 +++++++++++++++++++++++++++++++---------- 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d3fb051..c3a2a35 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: terraform-validate - id: tflint - repo: git@github.com:kabisa/terraform-datadog-pre-commit-hook.git - rev: "0.1.15" + rev: "1.2.2" hooks: - id: terraform-datadog-docs exclude: ^README.md$ diff --git a/README.md b/README.md index 3e8cced..55c931d 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,47 @@ ![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 +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 + +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) + +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 + +```terraform +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 +} +``` + Monitors: * [Terraform module for Datadog Costs](#terraform-module-for-datadog-costs) * [Containers](#containers) @@ -17,7 +54,7 @@ Monitors: * [Logs Indexed](#logs-indexed) * [Module Variables](#module-variables) -# Getting started +# Getting started developing [pre-commit](http://pre-commit.com/) was used to do Terraform linting and validating. Steps: @@ -29,13 +66,13 @@ Steps: Query: ```terraform -avg(${var.containers_evaluation_period}):sum:datadog.estimated_usage.containers{${local.containers_filter}} > ${var.containers_critical} +avg(last_1h):sum:datadog.estimated_usage.containers{tag:xxx} > ``` | variable | default | required | description | |------------------------------|----------|----------|----------------------------------| | containers_enabled | True | No | | -| containers_warning | null | No | | +| containers_warning | None | No | | | containers_critical | | Yes | | | containers_evaluation_period | last_1h | No | | | containers_note | "" | No | | @@ -49,13 +86,13 @@ avg(${var.containers_evaluation_period}):sum:datadog.estimated_usage.containers{ 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 | | @@ -69,13 +106,13 @@ avg(${var.apm_hosts_evaluation_period}):sum:datadog.estimated_usage.apm_hosts{${ Query: ```terraform -avg(${var.hosts_evaluation_period}):sum:datadog.estimated_usage.hosts{${local.hosts_filter}} > ${var.hosts_critical} +avg(last_1h):sum:datadog.estimated_usage.hosts{tag:xxx} > ``` | variable | default | required | description | |-------------------------|----------|----------|----------------------------------| | hosts_enabled | True | No | | -| hosts_warning | null | No | | +| hosts_warning | None | No | | | hosts_critical | | Yes | | | hosts_evaluation_period | last_1h | No | | | hosts_note | "" | No | | @@ -89,13 +126,13 @@ avg(${var.hosts_evaluation_period}):sum:datadog.estimated_usage.hosts{${local.ho 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 | | @@ -109,7 +146,7 @@ avg(${var.custom_metrics_evaluation_period}):sum:datadog.estimated_usage.metrics 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} +sum(last_1h):sum:datadog.estimated_usage.apm.indexed_spans{tag:xxx}.as_count() > ``` | variable | default | required | description | @@ -129,14 +166,14 @@ sum(${var.apm_spans_evaluation_period}):sum:datadog.estimated_usage.apm.indexed_ 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 +186,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 | @@ -169,13 +206,13 @@ sum(${var.logs_ingestion_evaluation_period}):sum:custom_datadog.estimated_usage. 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} +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 | null | No | | +| logs_indexed_warning | None | No | | | logs_indexed_critical | | Yes | | | logs_indexed_evaluation_period | last_4h | No | | | logs_indexed_note | "" | No | | From c9afd8850293c75768e9e18dad1961ab9cf4adf8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 22 Jul 2022 13:59:14 +0000 Subject: [PATCH 3/5] Add renovate.json --- renovate.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 renovate.json 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" + ] +} From 47006d659088f02077236f61b345171a17c88cde Mon Sep 17 00:00:00 2001 From: Sjuul Janssen Date: Fri, 22 Jul 2022 16:05:49 +0200 Subject: [PATCH 4/5] updated docs and provider version --- .github/workflows/documentation.yaml | 29 +++++ .gitignore | 1 + .pre-commit-config.yaml | 5 +- .terraform.lock.hcl | 21 +++- README.md | 159 ++++++++++++++------------- apm-hosts-variables.tf | 2 +- apm-hosts.tf | 3 +- apm-spans-variables.tf | 2 +- apm-spans.tf | 3 +- containers-variables.tf | 2 +- containers.tf | 3 +- custom-metrics-variables.tf | 2 +- custom-metrics.tf | 3 +- examples/example.tf | 3 +- hosts-variables.tf | 2 +- hosts.tf | 3 +- logs-indexed-variables.tf | 2 +- logs-indexed.tf | 3 +- logs-ingestion-4h-variables.tf | 2 +- logs-ingestion-4h.tf | 3 +- logs-ingestion-variables.tf | 2 +- logs-ingestion.tf | 3 +- provider.tf | 2 +- 23 files changed, 159 insertions(+), 101 deletions(-) create mode 100644 .github/workflows/documentation.yaml 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 c3a2a35..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: "1.2.2" + - 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 55c931d..e12a14b 100644 --- a/README.md +++ b/README.md @@ -40,48 +40,33 @@ module "costs" { logs_ingestion_critical = 850000000 logs_ingestion_warning = 600000000 } + ``` + +[Module Variables](#module-variables) + 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) + +| 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 cloud a repo with pre-commit enabled you will need to run the pre-commit install command) + - 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. -## 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). | - - ## Apm Hosts Query: @@ -102,24 +87,44 @@ avg(last_1h):sum:datadog.estimated_usage.apm_hosts{tag:xxx} > | apm_hosts_priority | 4 | No | Number from 1 (high) to 5 (low). | -## Hosts +## Apm Spans Query: ```terraform -avg(last_1h):sum:datadog.estimated_usage.hosts{tag:xxx} > +sum(last_1h):sum:datadog.estimated_usage.apm.indexed_spans{tag:xxx}.as_count() > ``` -| 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). | +| 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 @@ -142,24 +147,44 @@ avg(last_1h):sum:datadog.estimated_usage.metrics.custom{tag:xxx} > | custom_metrics_priority | 4 | No | Number from 1 (high) to 5 (low). | -## Apm Spans +## Hosts Query: ```terraform -sum(last_1h):sum:datadog.estimated_usage.apm.indexed_spans{tag:xxx}.as_count() > +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 @@ -202,26 +227,6 @@ sum(last_1d):sum:custom_datadog.estimated_usage.logs.ingested_bytes{tag:xxx}.as_ | logs_ingestion_priority | 3 | 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). | - - ## Module Variables | variable | default | required | description | 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..9f3c44e 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}" 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..9d2b2e2 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}" 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..021b89b 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}" 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..5560b77 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}" diff --git a/examples/example.tf b/examples/example.tf index 8725a51..4d3c110 100644 --- a/examples/example.tf +++ b/examples/example.tf @@ -1,3 +1,4 @@ +# tflint-ignore: terraform_module_version module "costs" { source = "kabisa/costs/datadog" @@ -17,4 +18,4 @@ module "costs" { logs_ingestion_4h_critical = 208000000 logs_ingestion_critical = 850000000 logs_ingestion_warning = 600000000 -} \ No newline at end of file +} 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..28a42e7 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}" 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..41df5ff 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}" 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..d144ecd 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}" 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..0fef556 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}" 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 From c8e1c8e3f8b193c9a7a95ce6c354974cdf5eec6e Mon Sep 17 00:00:00 2001 From: Sjuul Janssen Date: Fri, 22 Jul 2022 16:09:40 +0200 Subject: [PATCH 5/5] remove alert_env --- README.md | 3 +-- apm-hosts.tf | 2 +- apm-spans.tf | 2 +- containers.tf | 2 +- custom-metrics.tf | 2 +- examples/example.tf | 2 +- hosts.tf | 2 +- logs-indexed.tf | 2 +- logs-ingestion-4h.tf | 2 +- logs-ingestion.tf | 2 +- variables.tf | 4 ---- 11 files changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e12a14b..852329c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Modules are generated with this tool: https://github.com/kabisa/datadog-terrafor module "costs" { source = "kabisa/costs/datadog" - notification_channel = "mail@example.com" + notification_channel = "@mail@example.com" env = "prd" alert_env = "prd" @@ -232,7 +232,6 @@ sum(last_1d):sum:custom_datadog.estimated_usage.logs.ingested_bytes{tag:xxx}.as_ | variable | default | required | description | |-------------------------------|----------|----------|--------------| | env | | Yes | | -| alert_env | | Yes | | | service | Costs | No | | | notification_channel | | Yes | | | additional_tags | [] | No | | diff --git a/apm-hosts.tf b/apm-hosts.tf index 9f3c44e..56b304e 100644 --- a/apm-hosts.tf +++ b/apm-hosts.tf @@ -24,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.tf b/apm-spans.tf index 9d2b2e2..25e04e3 100644 --- a/apm-spans.tf +++ b/apm-spans.tf @@ -22,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.tf b/containers.tf index 021b89b..5189846 100644 --- a/containers.tf +++ b/containers.tf @@ -22,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.tf b/custom-metrics.tf index 5560b77..265ddbf 100644 --- a/custom-metrics.tf +++ b/custom-metrics.tf @@ -22,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 index 4d3c110..c0e41fa 100644 --- a/examples/example.tf +++ b/examples/example.tf @@ -2,7 +2,7 @@ module "costs" { source = "kabisa/costs/datadog" - notification_channel = "mail@example.com" + notification_channel = "@mail@example.com" env = "prd" alert_env = "prd" diff --git a/hosts.tf b/hosts.tf index 28a42e7..097774c 100644 --- a/hosts.tf +++ b/hosts.tf @@ -22,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.tf b/logs-indexed.tf index 41df5ff..2de848b 100644 --- a/logs-indexed.tf +++ b/logs-indexed.tf @@ -22,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.tf b/logs-ingestion-4h.tf index d144ecd..1dbe469 100644 --- a/logs-ingestion-4h.tf +++ b/logs-ingestion-4h.tf @@ -22,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.tf b/logs-ingestion.tf index 0fef556..cc8bc38 100644 --- a/logs-ingestion.tf +++ b/logs-ingestion.tf @@ -22,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/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"