MON-237 - First cosmosdb monitors added
This commit is contained in:
parent
9d42d53494
commit
8f62260c1b
@ -83,6 +83,14 @@ Inputs
|
||||
| appservices_response_time_threshold_warning | Warning threshold for response time in seconds | string | `5` | no |
|
||||
| appservices_response_time_time_aggregator | Monitor aggregator for App Services response time [available values: min, max or avg] | string | `min` | no |
|
||||
| appservices_response_time_timeframe | Monitor timeframe for App Services response time [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no |
|
||||
| cosmos_db_4xx_request_rate_threshold_critical | | string | `80` | no |
|
||||
| cosmos_db_4xx_request_rate_threshold_warning | | string | `50` | no |
|
||||
| cosmos_db_4xx_requests_message | Custom message for Cosmos DB 4xx requests monitor | string | `` | no |
|
||||
| cosmos_db_4xx_requests_silenced | Groups to mute for Cosmos DB 4xx requests monitor | map | `<map>` | no |
|
||||
| cosmos_db_5xx_request_rate_threshold_critical | | string | `80` | no |
|
||||
| cosmos_db_5xx_request_rate_threshold_warning | | string | `50` | no |
|
||||
| cosmos_db_5xx_requests_message | Custom message for Cosmos DB 5xx requests monitor | string | `` | no |
|
||||
| cosmos_db_5xx_requests_silenced | Groups to mute for Cosmos DB 5xx requests monitor | map | `<map>` | no |
|
||||
| delay | Delay in seconds for the metric evaluation | string | `900` | no |
|
||||
| environment | Architecture environment | string | - | yes |
|
||||
| eventhub_errors_rate_message | Custom message for Event Hub errors monitor | string | `` | no |
|
||||
|
||||
49
cloud/azure/cosmosdb/README.md
Normal file
49
cloud/azure/cosmosdb/README.md
Normal file
@ -0,0 +1,49 @@
|
||||
Azure Cosmos DB DataDog monitors
|
||||
================================
|
||||
|
||||
How to use this module
|
||||
----------------------
|
||||
|
||||
```
|
||||
module "datadog-monitors-azure-cosmosdb" {
|
||||
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/cosmosdb?ref={revision}"
|
||||
|
||||
message = "${module.datadog-message-alerting.alerting-message}"
|
||||
environment = "${var.environment}"
|
||||
}
|
||||
```
|
||||
|
||||
Purpose
|
||||
-------
|
||||
Creates a DataDog monitors with the following checks :
|
||||
|
||||
* No request
|
||||
* Too many 4xx requests
|
||||
* Too many 5xx requests
|
||||
|
||||
Inputs
|
||||
------
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|:----:|:-----:|:-----:|
|
||||
| cosmos_db_4xx_request_rate_threshold_critical | | string | `80` | no |
|
||||
| cosmos_db_4xx_request_rate_threshold_warning | | string | `50` | no |
|
||||
| cosmos_db_4xx_requests_message | Custom message for Cosmos DB 4xx requests monitor | string | `` | no |
|
||||
| cosmos_db_4xx_requests_silenced | Groups to mute for Cosmos DB 4xx requests monitor | map | `<map>` | no |
|
||||
| cosmos_db_5xx_request_rate_threshold_critical | | string | `80` | no |
|
||||
| cosmos_db_5xx_request_rate_threshold_warning | | string | `50` | no |
|
||||
| cosmos_db_5xx_requests_message | Custom message for Cosmos DB 5xx requests monitor | string | `` | no |
|
||||
| cosmos_db_5xx_requests_silenced | Groups to mute for Cosmos DB 5xx requests monitor | map | `<map>` | no |
|
||||
| cosmos_db_no_request_message | Custom message for Cosmos DB no request monitor | string | `` | no |
|
||||
| cosmos_db_no_request_silenced | Groups to mute for Cosmos DB no request monitor | map | `<map>` | no |
|
||||
| delay | Delay in seconds for the metric evaluation | string | `900` | no |
|
||||
| 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 |
|
||||
| message | Message sent when a monitor is triggered | string | - | yes |
|
||||
| subscription_id | ID of the subscription | string | - | yes |
|
||||
|
||||
Related documentation
|
||||
---------------------
|
||||
|
||||
To be defined
|
||||
81
cloud/azure/cosmosdb/inputs.tf
Normal file
81
cloud/azure/cosmosdb/inputs.tf
Normal file
@ -0,0 +1,81 @@
|
||||
variable "environment" {
|
||||
description = "Architecture environment"
|
||||
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 = "*"
|
||||
}
|
||||
|
||||
variable "message" {
|
||||
description = "Message sent when a monitor is triggered"
|
||||
}
|
||||
|
||||
variable "delay" {
|
||||
description = "Delay in seconds for the metric evaluation"
|
||||
default = 900
|
||||
}
|
||||
|
||||
variable "subscription_id" {
|
||||
description = "ID of the subscription"
|
||||
type = "string"
|
||||
}
|
||||
|
||||
# Azure CosmosDB specific variables
|
||||
variable "cosmos_db_4xx_requests_message" {
|
||||
description = "Custom message for Cosmos DB 4xx requests monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cosmos_db_4xx_requests_silenced" {
|
||||
description = "Groups to mute for Cosmos DB 4xx requests monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "cosmos_db_4xx_request_rate_threshold_critical" {
|
||||
default = 80
|
||||
}
|
||||
|
||||
variable "cosmos_db_4xx_request_rate_threshold_warning" {
|
||||
default = 50
|
||||
}
|
||||
|
||||
variable "cosmos_db_5xx_requests_message" {
|
||||
description = "Custom message for Cosmos DB 5xx requests monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cosmos_db_5xx_requests_silenced" {
|
||||
description = "Groups to mute for Cosmos DB 5xx requests monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "cosmos_db_5xx_request_rate_threshold_critical" {
|
||||
default = 80
|
||||
}
|
||||
|
||||
variable "cosmos_db_5xx_request_rate_threshold_warning" {
|
||||
default = 50
|
||||
}
|
||||
|
||||
variable "cosmos_db_no_request_message" {
|
||||
description = "Custom message for Cosmos DB no request monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cosmos_db_no_request_silenced" {
|
||||
description = "Groups to mute for Cosmos DB no request monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
115
cloud/azure/cosmosdb/monitors-cosmosdb.tf
Normal file
115
cloud/azure/cosmosdb/monitors-cosmosdb.tf
Normal file
@ -0,0 +1,115 @@
|
||||
data "template_file" "filter" {
|
||||
template = "$${filter}"
|
||||
|
||||
vars {
|
||||
filter = "${var.filter_tags_use_defaults == "true" ? format("subscription_id:%s", var.subscription_id) : "${var.filter_tags_custom}"}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "cosmos_db_4xx_requests" {
|
||||
name = "[${var.environment}] Cosmos DB 4xx requests rate is too low {{#is_alert}}{{comparator}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{comparator}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||
message = "${coalesce(var.cosmos_db_4xx_requests_message, var.message)}"
|
||||
|
||||
query = <<EOF
|
||||
sum(last_5m): (default(
|
||||
( avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered},statuscode:400} by {resource_group,name}.as_count() +
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered},statuscode:403} by {resource_group,name}.as_count() +
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered},statuscode:404} by {resource_group,name}.as_count() +
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered},statuscode:408} by {resource_group,name}.as_count() +
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered},statuscode:409} by {resource_group,name}.as_count() +
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered},statuscode:410} by {resource_group,name}.as_count() +
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered},statuscode:412} by {resource_group,name}.as_count() +
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered},statuscode:413} by {resource_group,name}.as_count() +
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered},statuscode:429} by {resource_group,name}.as_count() +
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered},statuscode:449} by {resource_group,name}.as_count() ) /
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered}} by {resource_group,name}.as_count()
|
||||
* 100, 0)
|
||||
) > ${var.cosmos_db_4xx_request_rate_threshold_critical}
|
||||
EOF
|
||||
|
||||
type = "metric alert"
|
||||
|
||||
thresholds {
|
||||
critical = "${var.cosmos_db_4xx_request_rate_threshold_critical}"
|
||||
warning = "${var.cosmos_db_4xx_request_rate_threshold_warning}"
|
||||
}
|
||||
|
||||
silenced = "${var.cosmos_db_4xx_requests_silenced}"
|
||||
|
||||
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
|
||||
|
||||
tags = ["env:${var.environment}", "resource:cosmos_db", "team:azure", "provider:azure"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "cosmos_db_5xx_requests" {
|
||||
name = "[${var.environment}] Cosmos DB 5xx requests rate is too low {{#is_alert}}{{comparator}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{comparator}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||
message = "${coalesce(var.cosmos_db_5xx_requests_message, var.message)}"
|
||||
|
||||
query = <<EOF
|
||||
sum(last_5m): (default(
|
||||
( avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered},statuscode:500} by {resource_group,name}.as_count() +
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered},statuscode:503} by {resource_group,name}.as_count() ) /
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered}} by {resource_group,name}.as_count()
|
||||
* 100, 0)
|
||||
) > ${var.cosmos_db_5xx_request_rate_threshold_critical}
|
||||
EOF
|
||||
|
||||
type = "metric alert"
|
||||
|
||||
thresholds {
|
||||
critical = "${var.cosmos_db_5xx_request_rate_threshold_critical}"
|
||||
warning = "${var.cosmos_db_5xx_request_rate_threshold_warning}"
|
||||
}
|
||||
|
||||
silenced = "${var.cosmos_db_5xx_requests_silenced}"
|
||||
|
||||
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
|
||||
|
||||
tags = ["env:${var.environment}", "resource:cosmos_db", "team:azure", "provider:azure"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "cosmos_db_success_no_data" {
|
||||
name = "[${var.environment}] Cosmos DB has no request"
|
||||
message = "${coalesce(var.cosmos_db_no_request_message, var.message)}"
|
||||
|
||||
query = <<EOF
|
||||
avg(last_5m): (
|
||||
avg:azure.cosmosdb.total_requests{${data.template_file.filter.rendered}} by {resource_group,name}
|
||||
) < 0
|
||||
EOF
|
||||
|
||||
type = "metric alert"
|
||||
|
||||
silenced = "${var.cosmos_db_no_request_silenced}"
|
||||
|
||||
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:cosmos_db", "team:azure", "provider:azure"]
|
||||
}
|
||||
@ -1517,3 +1517,44 @@ variable "streamanalytics_runtime_errors_threshold_critical" {
|
||||
description = "Runtime errors limit (critical threshold)"
|
||||
default = 10
|
||||
}
|
||||
|
||||
# Azure CosmosDB specific variables
|
||||
variable "cosmos_db_4xx_requests_message" {
|
||||
description = "Custom message for Cosmos DB 4xx requests monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cosmos_db_4xx_requests_silenced" {
|
||||
description = "Groups to mute for Cosmos DB 4xx requests monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "cosmos_db_4xx_request_rate_threshold_critical" {
|
||||
default = 80
|
||||
}
|
||||
|
||||
variable "cosmos_db_4xx_request_rate_threshold_warning" {
|
||||
default = 50
|
||||
}
|
||||
|
||||
variable "cosmos_db_5xx_requests_message" {
|
||||
description = "Custom message for Cosmos DB 5xx requests monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cosmos_db_5xx_requests_silenced" {
|
||||
description = "Groups to mute for Cosmos DB 5xx requests monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "cosmos_db_5xx_request_rate_threshold_critical" {
|
||||
default = 80
|
||||
}
|
||||
|
||||
variable "cosmos_db_5xx_request_rate_threshold_warning" {
|
||||
default = 50
|
||||
}
|
||||
|
||||
@ -369,3 +369,25 @@ module "streamanalytics" {
|
||||
su_utilization_threshold_critical = "${var.streamanalytics_su_utilization_threshold_critical}"
|
||||
su_utilization_threshold_warning = "${var.streamanalytics_su_utilization_threshold_warning}"
|
||||
}
|
||||
|
||||
module "cosmosdb" {
|
||||
source = "./cosmosdb"
|
||||
|
||||
environment = "${var.environment}"
|
||||
subscription_id = ""
|
||||
message = "${var.message}"
|
||||
delay = "${var.delay}"
|
||||
|
||||
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
|
||||
filter_tags_custom = "${var.filter_tags_custom}"
|
||||
|
||||
cosmos_db_4xx_request_rate_threshold_critical = "${var.cosmos_db_4xx_request_rate_threshold_critical}"
|
||||
cosmos_db_4xx_request_rate_threshold_warning = "${var.cosmos_db_4xx_request_rate_threshold_warning}"
|
||||
cosmos_db_4xx_requests_message = "${var.cosmos_db_4xx_requests_message}"
|
||||
cosmos_db_4xx_requests_silenced = "${var.cosmos_db_4xx_requests_silenced}"
|
||||
|
||||
cosmos_db_5xx_request_rate_threshold_critical = "${var.cosmos_db_5xx_request_rate_threshold_critical}"
|
||||
cosmos_db_5xx_request_rate_threshold_warning = "${var.cosmos_db_5xx_request_rate_threshold_warning}"
|
||||
cosmos_db_5xx_requests_message = "${var.cosmos_db_5xx_requests_message}"
|
||||
cosmos_db_5xx_requests_silenced = "${var.cosmos_db_5xx_requests_silenced}"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user