diff --git a/README.md b/README.md index ef5bd6f..ed6b246 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ The `//` is very important, it's a terraform specific syntax used to separate gi - [elasticsearch](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/elasticsearch/) - [mongodb](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/mongodb/) - [mysql](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/mysql/) + - [postgresql](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/postgresql/) - [redis](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/redis/) - [middleware](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/) - [apache](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/apache/) diff --git a/database/postgresql/README.md b/database/postgresql/README.md index d5228e0..63278b0 100644 --- a/database/postgresql/README.md +++ b/database/postgresql/README.md @@ -1,43 +1,57 @@ -PostgreSQL DataDog monitors -====================== +# DATABASE POSTGRESQL DataDog monitors -How to use this module ----------------------- +## How to use this module ``` -module "datadog-monitors-postgresql" { - source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//databases/postgresql?ref={revision}" +module "datadog-monitors-database-postgresql" { + source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//database/postgresql?ref={revision}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` -Purpose -------- -Creates DataDog monitors with the following checks : -* PostgreSQL not enough available connections -* PostgreSQL too many locks +## Purpose -Inputs ------- +Creates DataDog monitors with the following checks: + +- PostgreSQL Connections +- PostgreSQL too many locks + +## Inputs | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| delay | Delay in seconds for the metric evaluation | string | `15` | no | | environment | Environment | string | - | yes | -| filter_tags_use_defaults | Use default filter tags convention | string | `true` | no | +| evaluation_delay | Delay in seconds for the metric evaluation | string | `15` | no | | 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 an alert is triggered | string | - | yes | +| new_host_delay | Delay in seconds for the metric evaluation | string | `300` | no | +| posgresql_lock_silenced | Groups to mute for PostgreSQL lock monitor | map | `` | 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 | `` | no | +| postgresql_connection_message | Custom message for PostgreSQL connection monitor | string | `` | no | +| postgresql_connection_silenced | Groups to mute for PostgreSQL connection monitor | map | `` | no | | postgresql_connection_threshold_critical | Maximum critical acceptable percent of connections | string | `80` | no | | postgresql_connection_threshold_warning | Maximum warning acceptable percent of connections | string | `70` | no | -| postgresql_connection_silenced | Groups to mute for PostgreSQL connection monitor | map | `` | no | -| postgresql_connection_message | Custom message for PostgreSQL connection monitor | string | `` | no | -| postgresql_thread_threshold_critical | Maximum critical acceptable number of threads | string | `500` | no | -| postgresql_thread_threshold_warning | Maximum warning acceptable number of threads | string | `400` | no | -| postgresql_thread_silenced | Groups to mute for PostgreSQL threads monitor | map | `` | no | -| postgresql_thread_message | Custom message for PostgreSQL thread monitor | string | `` | no | -| message | Message sent when a monitor is triggered | string | - | yes | +| postgresql_connection_time_aggregator | Monitor time aggregator for PostgreSQL connection monitor [available values: min, max or avg] | string | `avg` | no | +| postgresql_connection_timeframe | Monitor timeframe for PostgreSQL connection monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no | +| postgresql_lock_enabled | Flag to enable PostgreSQL lock monitor | string | `true` | no | +| postgresql_lock_extra_tags | Extra tags for PostgreSQL lock connects monitor | list | `` | no | +| postgresql_lock_message | Custom message for PostgreSQL lock monitor | string | `` | no | +| postgresql_lock_threshold_critical | Maximum critical acceptable number of locks | string | `99` | no | +| postgresql_lock_threshold_warning | Maximum warning acceptable number of locks | string | `70` | no | +| postgresql_lock_time_aggregator | Monitor time aggregator for PostgreSQL lock monitor [available values: min, max or avg] | string | `min` | no | +| postgresql_lock_timeframe | Monitor timeframe for PostgreSQL lock monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| postgresql_connection_too_high_id | id for monitor postgresql_connection_too_high | +| postgresql_too_many_locks_id | id for monitor postgresql_too_many_locks | Related documentation --------------------- diff --git a/database/postgresql/inputs.tf b/database/postgresql/inputs.tf index a875f3d..ca0dde6 100644 --- a/database/postgresql/inputs.tf +++ b/database/postgresql/inputs.tf @@ -79,7 +79,6 @@ variable "postgresql_connection_timeframe" { default = "last_15m" } - ############################ ### PostgreSQL locks ### ############################ @@ -129,5 +128,3 @@ variable "postgresql_lock_timeframe" { type = "string" default = "last_5m" } - - diff --git a/database/postgresql/outputs.tf b/database/postgresql/outputs.tf new file mode 100644 index 0000000..79532c6 --- /dev/null +++ b/database/postgresql/outputs.tf @@ -0,0 +1,9 @@ +output "postgresql_connection_too_high_id" { + description = "id for monitor postgresql_connection_too_high" + value = "${datadog_monitor.postgresql_connection_too_high.*.id}" +} + +output "postgresql_too_many_locks_id" { + description = "id for monitor postgresql_too_many_locks" + value = "${datadog_monitor.postgresql_too_many_locks.*.id}" +}