MON-273 add filter tags module

This commit is contained in:
Quentin Manfroi 2018-08-10 16:57:09 +02:00
parent acd3d43923
commit 35edf30930
5 changed files with 85 additions and 13 deletions

View File

@ -1,8 +1,6 @@
Alerting Message Datadog Generator
==================================
# ALERTING MESSAGE Datadog Generator
How to use this module
----------------------
## How to use this module
```
module "datadog-message-alerting" {
@ -14,8 +12,7 @@ module "datadog-message-alerting" {
}
```
Purpose
-------
## Purpose
Creates a DataDog monitor alert message with the following inputs :
@ -25,8 +22,7 @@ Creates a DataDog monitor alert message with the following inputs :
* Prepend text free string
* Append text free string
Inputs
------
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
@ -36,14 +32,11 @@ Inputs
| message_warning | Define a broadcast channel for warning alerts | string | - | yes |
| prepend_text | Optional free text string to prepend to alert | string | `` | no |
Outputs
-------
## Outputs
| Name | Description |
|------|-------------|
| alerting-message | The generated message string |
Related documentation
---------------------
## Related documentation
DataDog documentation: [https://docs.datadoghq.com/integrations/azure_app_services](https://docs.datadoghq.com/integrations/azure_app_services)

View File

@ -0,0 +1,45 @@
# FILTER TAGS Datadog Generator
## How to use this module
This module usage should be transparent because it should be used inside each monitors set directly.
Here is a simple example but it is advisable to see how are created other existing monitors sets:
```
module "filter-tags" {
source = "../../common/filter-tags"
environment = "${var.environment}"
resource = "my_resource"
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
filter_tags_custom = "${var.filter_tags_custom}"
}
```
## Purpose
Creates all kinds of filters tags patterns depending of the monitor type and directly usable in a monitors set :
* A filter tags pattern for service check
* A filter tags pattern for query alert
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| environment | Architecture Environment | string | - | yes |
| filter_tags_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `*` | no |
| filter_tags_use_defaults | Use default filter tags convention | string | `true` | no |
| resource | The dedicated tag for the resource | string | - | yes |
## Outputs
| Name | Description |
|------|-------------|
| query_alert | The full filtering pattern including parentheses for service check monitor type |
| service_check | The full filtering pattern including braces for query alert monitor type |
## Related documentation
Datadog API type of monitor: [https://docs.datadoghq.com/api/?lang=python#create-a-monitor](https://docs.datadoghq.com/api/?lang=python#create-a-monitor)

View File

@ -0,0 +1,20 @@
variable "environment" {
description = "Architecture Environment"
type = "string"
}
variable "resource" {
description = "The dedicated tag for the resource"
type = "string"
}
variable "filter_tags_use_defaults" {
description = "Use default filter tags convention"
default = "true"
}
variable "filter_tags_custom" {
description = "Tags used for custom filtering when filter_tags_use_defaults is false"
default = "*"
}

View File

@ -0,0 +1,4 @@
locals {
filters = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_%s:enabled,env:%s", var.resource, var.environment) : "${var.filter_tags_custom}"}"
}

View File

@ -0,0 +1,10 @@
output "query_alert" {
description = "The full filtering pattern including parentheses for service check monitor type"
value = "{${local.filters}}"
}
output "service_check" {
description = "The full filtering pattern including braces for query alert monitor type"
value = "(\"${replace(local.filters, ",", "\",\"")}\")"
}