MON-78 add subscription_id and tags

This commit is contained in:
Quentin Manfroi 2017-11-03 20:21:44 +01:00
parent 0b896d784b
commit c4c64299b8
3 changed files with 41 additions and 13 deletions

View File

@ -9,8 +9,8 @@ module "datadog-monitors-azure-redis" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/stream-analytics?ref={revision}"
message = "${module.datadog-message-alerting.alerting-message}"
environment = "${var.environment}"
subscription_id = "${var.subscription_id}"
}
```
@ -31,6 +31,7 @@ Inputs
| runtime_errors_threshold_warning | | string | `0` | no |
| su_utilization_threshold_critical | | string | `80` | no |
| su_utilization_threshold_warning | Monitor specific | string | `60` | no |
| subscription_id | Azure account id used as filter for monitors | string | - | yes |
| use_filter_tags | Filter the data with service tags if true | string | `true` | no |
Related documentation

View File

@ -8,14 +8,28 @@ variable "message" {
description = "Message sent when a monitor is triggered"
}
# Global DataDog
variable "use_filter_tags" {
description = "Filter the data with service tags if true"
default = "true"
variable "subscription_id" {
description = "Azure account id used as filter for monitors"
type = "string"
}
variable "notify_no_data" {
default = "false"
variable "provider" {
description = "Cloud provider which the monitor and its based metric depend on"
type = "string"
default = "azure"
}
variable "service" {
description = "Service monitored by this set of monitors"
type = "string"
default = "storage"
}
# Global DataDog
variable "message" {
description = "Message sent when a Redis monitor is triggered"
}
variable "delay" {
@ -23,7 +37,12 @@ variable "delay" {
default = 600
}
# Monitor specific
variable "use_filter_tags" {
description = "Filter the data with service tags if true"
default = "true"
}
# Azure Stream Analytics specific
variable "su_utilization_threshold_warning" {
default = 60
}

View File

@ -2,12 +2,12 @@ data "template_file" "filter" {
template = "$${filter}"
vars {
filter = "${var.use_filter_tags == "true" ? format("dd_monitoring:enabled,dd_azure_stream_analytics:enabled,env:%s", var.environment) : "*"}"
filter = "${var.use_filter_tags == "true" ? format("dd_monitoring:enabled,dd_azure_storage:enabled,env:%s", var.environment) : "subscription_id:${var.subscription_id}"}"
}
}
resource "datadog_monitor" "su_utilization" {
name = "[${var.environment}] Streaming Units utilization at more than ${var.su_utilization_threshold_critical}% on {{name}}"
name = "[${var.environment}] Stram Analytics streaming Units utilization at more than ${var.su_utilization_threshold_critical}% on {{name}}"
message = "${var.message}"
query = <<EOF
@ -31,10 +31,12 @@ resource "datadog_monitor" "su_utilization" {
warning = "${var.su_utilization_threshold_warning}"
critical = "${var.su_utilization_threshold_critical}"
}
tags = ["env:${var.environment}","resource:${var.service}","team:${var.provider}"]
}
resource "datadog_monitor" "failed_function_requests" {
name = "[${var.environment}] Stream Analytics : More than ${var.function_requests_threshold_critical} failed function requests on {{name}}"
name = "[${var.environment}] Stream Analytics more than ${var.function_requests_threshold_critical} failed function requests on {{name}}"
message = "${var.message}"
query = <<EOF
@ -58,10 +60,12 @@ resource "datadog_monitor" "failed_function_requests" {
warning = "${var.function_requests_threshold_warning}"
critical = "${var.function_requests_threshold_critical}"
}
tags = ["env:${var.environment}","resource:${var.service}","team:${var.provider}"]
}
resource "datadog_monitor" "conversion_errors" {
name = "[${var.environment}] Stream Analytics : More than ${var.conversion_errors_threshold_critical} conversion errors on {{name}}"
name = "[${var.environment}] Stream Analytics more than ${var.conversion_errors_threshold_critical} conversion errors on {{name}}"
message = "${var.message}"
query = <<EOF
@ -85,10 +89,12 @@ resource "datadog_monitor" "conversion_errors" {
warning = "${var.conversion_errors_threshold_warning}"
critical = "${var.conversion_errors_threshold_critical}"
}
tags = ["env:${var.environment}","resource:${var.service}","team:${var.provider}"]
}
resource "datadog_monitor" "runtime_errors" {
name = "[${var.environment}] Stream Analytics : More than ${var.runtime_errors_threshold_critical} runtime errors on {{name}}"
name = "[${var.environment}] Stream Analytics more than ${var.runtime_errors_threshold_critical} runtime errors on {{name}}"
message = "${var.message}"
query = <<EOF
@ -112,4 +118,6 @@ resource "datadog_monitor" "runtime_errors" {
warning = "${var.runtime_errors_threshold_warning}"
critical = "${var.runtime_errors_threshold_critical}"
}
tags = ["env:${var.environment}","resource:${var.service}","team:${var.provider}"]
}