MON-105 add service check
This commit is contained in:
parent
b2bcc58b00
commit
c2dfc0ed24
@ -26,7 +26,7 @@ resource "datadog_monitor" "mysql_availability" {
|
|||||||
|
|
||||||
silenced = "${var.mysql_availability_silenced}"
|
silenced = "${var.mysql_availability_silenced}"
|
||||||
|
|
||||||
tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_connection_extra_tags}"]
|
tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_availability_extra_tags}"]
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "datadog_monitor" "mysql_connection" {
|
resource "datadog_monitor" "mysql_connection" {
|
||||||
|
|||||||
@ -17,6 +17,7 @@ module "datadog-monitors-database-postgresql" {
|
|||||||
Creates DataDog monitors with the following checks:
|
Creates DataDog monitors with the following checks:
|
||||||
|
|
||||||
- PostgreSQL Connections
|
- PostgreSQL Connections
|
||||||
|
- PostgreSQL server does not respond
|
||||||
- PostgreSQL too many locks
|
- PostgreSQL too many locks
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
@ -30,6 +31,12 @@ Creates DataDog monitors with the following checks:
|
|||||||
| message | Message sent when an alert is triggered | string | - | yes |
|
| message | Message sent when an alert is triggered | string | - | yes |
|
||||||
| new_host_delay | Delay in seconds for the metric evaluation | string | `300` | no |
|
| new_host_delay | Delay in seconds for the metric evaluation | string | `300` | no |
|
||||||
| posgresql_lock_silenced | Groups to mute for PostgreSQL lock monitor | map | `<map>` | no |
|
| posgresql_lock_silenced | Groups to mute for PostgreSQL lock monitor | map | `<map>` | no |
|
||||||
|
| postgresql_availability_enabled | Flag to enable PostgreSQL availability monitor | string | `true` | no |
|
||||||
|
| postgresql_availability_extra_tags | Extra tags for PostgreSQL availability monitor | list | `<list>` | no |
|
||||||
|
| postgresql_availability_message | Custom message for PostgreSQL availability monitor | string | `` | no |
|
||||||
|
| postgresql_availability_no_data_timeframe | PostgreSQL availability monitor no data timeframe | string | `10` | no |
|
||||||
|
| postgresql_availability_silenced | Groups to mute for PostgreSQL availability monitor | map | `<map>` | no |
|
||||||
|
| postgresql_availability_threshold_warning | PostgreSQL availability monitor (warning threshold) | string | `3` | no |
|
||||||
| postgresql_connection_enabled | Flag to enable PostgreSQL connection monitor | string | `true` | no |
|
| postgresql_connection_enabled | Flag to enable PostgreSQL connection monitor | string | `true` | no |
|
||||||
| postgresql_connection_extra_tags | Extra tags for PostgreSQL connection connects monitor | list | `<list>` | no |
|
| postgresql_connection_extra_tags | Extra tags for PostgreSQL connection connects monitor | list | `<list>` | no |
|
||||||
| postgresql_connection_message | Custom message for PostgreSQL connection monitor | string | `` | no |
|
| postgresql_connection_message | Custom message for PostgreSQL connection monitor | string | `` | no |
|
||||||
@ -50,6 +57,7 @@ Creates DataDog monitors with the following checks:
|
|||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
|------|-------------|
|
|------|-------------|
|
||||||
|
| postgresql_availability_id | id for monitor postgresql_availability |
|
||||||
| postgresql_connection_too_high_id | id for monitor postgresql_connection_too_high |
|
| postgresql_connection_too_high_id | id for monitor postgresql_connection_too_high |
|
||||||
| postgresql_too_many_locks_id | id for monitor postgresql_too_many_locks |
|
| postgresql_too_many_locks_id | id for monitor postgresql_too_many_locks |
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,46 @@ variable "filter_tags_custom" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# PostgreSQL specific
|
# PostgreSQL specific
|
||||||
|
##################################
|
||||||
|
### PostgreSQL availability ###
|
||||||
|
##################################
|
||||||
|
|
||||||
|
variable "postgresql_availability_silenced" {
|
||||||
|
description = "Groups to mute for PostgreSQL availability monitor"
|
||||||
|
type = "map"
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "postgresql_availability_enabled" {
|
||||||
|
description = "Flag to enable PostgreSQL availability monitor"
|
||||||
|
type = "string"
|
||||||
|
default = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "postgresql_availability_extra_tags" {
|
||||||
|
description = "Extra tags for PostgreSQL availability monitor"
|
||||||
|
type = "list"
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "postgresql_availability_message" {
|
||||||
|
description = "Custom message for PostgreSQL availability monitor"
|
||||||
|
type = "string"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "postgresql_availability_threshold_warning" {
|
||||||
|
description = "PostgreSQL availability monitor (warning threshold)"
|
||||||
|
type = "string"
|
||||||
|
default = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "postgresql_availability_no_data_timeframe" {
|
||||||
|
description = "PostgreSQL availability monitor no data timeframe"
|
||||||
|
type = "string"
|
||||||
|
default = 10
|
||||||
|
}
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
### PostgreSQL connections ###
|
### PostgreSQL connections ###
|
||||||
##################################
|
##################################
|
||||||
|
|||||||
@ -1,3 +1,34 @@
|
|||||||
|
resource "datadog_monitor" "postgresql_availability" {
|
||||||
|
count = "${var.postgresql_availability_enabled ? 1 : 0}"
|
||||||
|
name = "[${var.environment}] PostgreSQL server does not respond"
|
||||||
|
message = "${coalesce(var.postgresql_availability_message, var.message)}"
|
||||||
|
|
||||||
|
type = "service check"
|
||||||
|
|
||||||
|
query = <<EOF
|
||||||
|
"postgres.can_connect".over${module.filter-tags.service_check}.by("port","server").last(6).count_by_status()
|
||||||
|
EOF
|
||||||
|
|
||||||
|
thresholds = {
|
||||||
|
warning = "${var.postgresql_availability_threshold_warning}"
|
||||||
|
critical = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
notify_no_data = true
|
||||||
|
no_data_timeframe = "${var.postgresql_availability_no_data_timeframe}"
|
||||||
|
new_host_delay = "${var.new_host_delay}"
|
||||||
|
renotify_interval = 0
|
||||||
|
notify_audit = false
|
||||||
|
timeout_h = 0
|
||||||
|
include_tags = true
|
||||||
|
locked = false
|
||||||
|
require_full_window = true
|
||||||
|
|
||||||
|
silenced = "${var.postgresql_availability_silenced}"
|
||||||
|
|
||||||
|
tags = ["env:${var.environment}", "type:database", "provider:postgres", "resource:postgresql", "team:claranet", "created-by:terraform", "${var.postgresql_availability_extra_tags}"]
|
||||||
|
}
|
||||||
|
|
||||||
resource "datadog_monitor" "postgresql_connection_too_high" {
|
resource "datadog_monitor" "postgresql_connection_too_high" {
|
||||||
count = "${var.postgresql_connection_enabled ? 1 : 0}"
|
count = "${var.postgresql_connection_enabled ? 1 : 0}"
|
||||||
name = "[${var.environment}] PostgreSQL Connections {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
name = "[${var.environment}] PostgreSQL Connections {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||||
|
|||||||
@ -1,3 +1,8 @@
|
|||||||
|
output "postgresql_availability_id" {
|
||||||
|
description = "id for monitor postgresql_availability"
|
||||||
|
value = "${datadog_monitor.postgresql_availability.*.id}"
|
||||||
|
}
|
||||||
|
|
||||||
output "postgresql_connection_too_high_id" {
|
output "postgresql_connection_too_high_id" {
|
||||||
description = "id for monitor postgresql_connection_too_high"
|
description = "id for monitor postgresql_connection_too_high"
|
||||||
value = "${datadog_monitor.postgresql_connection_too_high.*.id}"
|
value = "${datadog_monitor.postgresql_connection_too_high.*.id}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user