Merged in MON-78_Azure_Stream_analytics_monitor (pull request #13)

MON-78: Azure Stream analytics monitor

Approved-by: Quentin Manfroi <quentin.manfroi@yahoo.fr>
Approved-by: Alexandre Gaillet <alexandre.gaillet@fr.clara.net>
Approved-by: Laurent Piroelle <laurent.piroelle@fr.clara.net>
This commit is contained in:
jeremy.nancel@fr.clara.net 2017-11-27 14:20:41 +00:00 committed by Jérôme Respaut
commit cec5e7ef4b
3 changed files with 254 additions and 0 deletions

View File

@ -0,0 +1,41 @@
Azure Stream Analytics DataDog monitors
=======================================
How to use this module
----------------------
```
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}"
}
```
Inputs
------
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| conversion_errors_threshold_critical | Conversion errors limit (critical threshold) | string | `10` | no |
| conversion_errors_threshold_warning | Conversion errors limit (warning threshold) | string | `0` | no |
| delay | Delay in seconds for the metric evaluation | string | `600` | no |
| environment | Architecture environment | string | - | yes |
| function_requests_threshold_critical | Failed Function Request rate limit (critical threshold) | string | `10` | no |
| function_requests_threshold_warning | Failed Function Request rate limit (warning threshold) | string | `0` | no |
| message | Message sent when a monitor is triggered | string | - | yes |
| provider | What is the monitored provider | string | azure | no |
| runtime_errors_threshold_critical | | string | `10` | no |
| runtime_errors_threshold_warning | | string | `0` | no |
| su_utilization_threshold_critical | | string | `80` | no |
| su_utilization_threshold_warning | Monitor specific | string | `60` | no |
| service | What is the monitored service | string | storage | 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
---------------------
DataDog documentation: [https://docs.datadoghq.com/integrations/azure/](https://docs.datadoghq.com/integrations/azure/)

View File

@ -0,0 +1,66 @@
# Global Terraform
variable "environment" {
description = "Architecture environment"
type = "string"
}
# Global DataDog
variable "message" {
description = "Message sent when a Redis monitor is triggered"
}
variable "delay" {
description = "Delay in seconds for the metric evaluation"
default = 600
}
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 = "*"
}
# Azure Stream Analytics specific
variable "su_utilization_threshold_warning" {
description = "Streaming Unit utilization rate limit (warning threshold)"
default = 60
}
variable "su_utilization_threshold_critical" {
description = "Streaming Unit utilization rate limit (critical threshold)"
default = 80
}
variable "function_requests_threshold_warning" {
description = "Failed Function Request rate limit (warning threshold)"
default = 0
}
variable "failed_function_requests_threshold_critical" {
description = "Failed Function Request rate limit (critical threshold)"
default = 10
}
variable "conversion_errors_threshold_warning" {
description = "Conversion errors limit (warning threshold)"
default = 0
}
variable "conversion_errors_threshold_critical" {
description = "Conversion errors limit (critical threshold)"
default = 10
}
variable "runtime_errors_threshold_warning" {
description = "Runtime errors limit (warning threshold)"
default = 0
}
variable "runtime_errors_threshold_critical" {
description = "Runtime errors limit (critical threshold)"
default = 10
}

View File

@ -0,0 +1,147 @@
data "template_file" "filter" {
template = "$${filter}"
vars {
filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_azure_streamanalytics:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}"
}
}
resource "datadog_monitor" "status" {
name = "[${var.environment}] Stream Analytics Status is not ok on {{name}}"
message = "${var.message}"
query = <<EOF
avg(last_5m):avg:azure.streamanalytics_streamingjobs.status{${data.template_file.filter.rendered}} by {name,resource_group} < 1
EOF
type = "metric alert"
notify_no_data = true
evaluation_delay = "${var.delay}"
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = true
new_host_delay = "${var.delay}"
no_data_timeframe = 20
tags = ["env:${var.environment}", "resource:streamanalytics", "team:azure", "provider:azure"]
}
resource "datadog_monitor" "su_utilization" {
name = "[${var.environment}] Stream Analytics streaming Units utilization at more than ${var.su_utilization_threshold_critical}% on {{name}}"
message = "${var.message}"
query = <<EOF
avg(last_5m): (
avg:azure.streamanalytics_streamingjobs.resource_utilization{${data.template_file.filter.rendered}} by {name,resource_group}
) > ${var.su_utilization_threshold_critical}
EOF
type = "metric alert"
notify_no_data = false
evaluation_delay = "${var.delay}"
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = true
new_host_delay = "${var.delay}"
no_data_timeframe = 20
thresholds {
warning = "${var.su_utilization_threshold_warning}"
critical = "${var.su_utilization_threshold_critical}"
}
tags = ["env:${var.environment}", "resource:streamanalytics", "team:azure", "provider:azure"]
}
resource "datadog_monitor" "failed_function_requests" {
name = "[${var.environment}] Stream Analytics more than ${var.failed_function_requests_threshold_critical} failed function requests on {{name}}"
message = "${var.message}"
query = <<EOF
avg(last_5m): (
avg:azure.streamanalytics_streamingjobs.aml_callout_failed_requests{${data.template_file.filter.rendered}} by {name,resource_group}.as_count() /
avg:azure.streamanalytics_streamingjobs.aml_callout_requests{${data.template_file.filter.rendered}} by {name,resource_group}.as_count()
) * 100 > ${var.failed_function_requests_threshold_critical}
EOF
type = "metric alert"
notify_no_data = false
evaluation_delay = "${var.delay}"
renotify_interval = 60
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = true
new_host_delay = "${var.delay}"
no_data_timeframe = 20
thresholds {
warning = "${var.function_requests_threshold_warning}"
critical = "${var.failed_function_requests_threshold_critical}"
}
tags = ["env:${var.environment}", "resource:streamanalytics", "team:azure", "provider:azure"]
}
resource "datadog_monitor" "conversion_errors" {
name = "[${var.environment}] Stream Analytics more than ${var.conversion_errors_threshold_critical} conversion errors on {{name}}"
message = "${var.message}"
query = <<EOF
avg(last_5m): (
avg:azure.streamanalytics_streamingjobs.conversion_errors{${data.template_file.filter.rendered}} by {name,resource_group}
) > ${var.conversion_errors_threshold_critical}
EOF
type = "metric alert"
notify_no_data = false
evaluation_delay = "${var.delay}"
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = true
new_host_delay = "${var.delay}"
no_data_timeframe = 20
thresholds {
warning = "${var.conversion_errors_threshold_warning}"
critical = "${var.conversion_errors_threshold_critical}"
}
tags = ["env:${var.environment}", "resource:streamanalytics", "team:azure", "provider:azure"]
}
resource "datadog_monitor" "runtime_errors" {
name = "[${var.environment}] Stream Analytics more than ${var.runtime_errors_threshold_critical} runtime errors on {{name}}"
message = "${var.message}"
query = <<EOF
avg(last_5m): (
avg:azure.streamanalytics_streamingjobs.errors{${data.template_file.filter.rendered}} by {name,resource_group}
) > ${var.runtime_errors_threshold_critical}
EOF
type = "metric alert"
notify_no_data = false
evaluation_delay = "${var.delay}"
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = true
new_host_delay = "${var.delay}"
no_data_timeframe = 20
thresholds {
warning = "${var.runtime_errors_threshold_warning}"
critical = "${var.runtime_errors_threshold_critical}"
}
tags = ["env:${var.environment}", "resource:streamanalytics", "team:azure", "provider:azure"]
}