# DATABASE POSTGRESQL DataDog monitors
## How to use this module
```hcl
module "datadog-monitors-database-postgresql" {
source = "claranet/monitors/datadog//database/postgresql"
version = "{revision}"
environment = var.environment
message = module.datadog-message-alerting.alerting-message
}
```
## Purpose
Creates DataDog monitors with the following checks:
- PostgreSQL Connections
- PostgreSQL server does not respond
- PostgreSQL too many locks
## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 0.12.31 |
| [datadog](#requirement\_datadog) | >= 3.1.0 |
## Providers
| Name | Version |
|------|---------|
| [datadog](#provider\_datadog) | 3.1.2 |
## Modules
| Name | Source | Version |
|------|--------|---------|
| [filter-tags](#module\_filter-tags) | ../../common/filter-tags | n/a |
## Resources
| Name | Type |
|------|------|
| [datadog_monitor.postgresql_availability](https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/monitor) | resource |
| [datadog_monitor.postgresql_connection_too_high](https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/monitor) | resource |
| [datadog_monitor.postgresql_too_many_locks](https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/monitor) | resource |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [environment](#input\_environment) | Environment | `string` | n/a | yes |
| [evaluation\_delay](#input\_evaluation\_delay) | Delay in seconds for the metric evaluation | `number` | `15` | no |
| [filter\_tags\_custom](#input\_filter\_tags\_custom) | Tags used for custom filtering when filter\_tags\_use\_defaults is false | `string` | `"*"` | no |
| [filter\_tags\_custom\_excluded](#input\_filter\_tags\_custom\_excluded) | Tags excluded for custom filtering when filter\_tags\_use\_defaults is false | `string` | `""` | no |
| [filter\_tags\_use\_defaults](#input\_filter\_tags\_use\_defaults) | Use default filter tags convention | `string` | `"true"` | no |
| [message](#input\_message) | Message sent when an alert is triggered | `any` | n/a | yes |
| [new\_host\_delay](#input\_new\_host\_delay) | Delay in seconds for the metric evaluation | `number` | `300` | no |
| [notify\_no\_data](#input\_notify\_no\_data) | Will raise no data alert if set to true | `bool` | `true` | no |
| [postgresql\_availability\_enabled](#input\_postgresql\_availability\_enabled) | Flag to enable PostgreSQL availability monitor | `string` | `"true"` | no |
| [postgresql\_availability\_extra\_tags](#input\_postgresql\_availability\_extra\_tags) | Extra tags for PostgreSQL availability monitor | `list(string)` | `[]` | no |
| [postgresql\_availability\_message](#input\_postgresql\_availability\_message) | Custom message for PostgreSQL availability monitor | `string` | `""` | no |
| [postgresql\_availability\_no\_data\_timeframe](#input\_postgresql\_availability\_no\_data\_timeframe) | PostgreSQL availability monitor no data timeframe | `string` | `10` | no |
| [postgresql\_availability\_threshold\_warning](#input\_postgresql\_availability\_threshold\_warning) | PostgreSQL availability monitor (warning threshold) | `string` | `3` | no |
| [postgresql\_connection\_enabled](#input\_postgresql\_connection\_enabled) | Flag to enable PostgreSQL connection monitor | `string` | `"true"` | no |
| [postgresql\_connection\_extra\_tags](#input\_postgresql\_connection\_extra\_tags) | Extra tags for PostgreSQL connection connects monitor | `list(string)` | `[]` | no |
| [postgresql\_connection\_message](#input\_postgresql\_connection\_message) | Custom message for PostgreSQL connection monitor | `string` | `""` | no |
| [postgresql\_connection\_threshold\_critical](#input\_postgresql\_connection\_threshold\_critical) | Maximum critical acceptable percent of connections | `number` | `80` | no |
| [postgresql\_connection\_threshold\_warning](#input\_postgresql\_connection\_threshold\_warning) | Maximum warning acceptable percent of connections | `number` | `70` | no |
| [postgresql\_connection\_time\_aggregator](#input\_postgresql\_connection\_time\_aggregator) | Monitor time aggregator for PostgreSQL connection monitor [available values: min, max or avg] | `string` | `"avg"` | no |
| [postgresql\_connection\_timeframe](#input\_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](#input\_postgresql\_lock\_enabled) | Flag to enable PostgreSQL lock monitor | `string` | `"true"` | no |
| [postgresql\_lock\_extra\_tags](#input\_postgresql\_lock\_extra\_tags) | Extra tags for PostgreSQL lock connects monitor | `list(string)` | `[]` | no |
| [postgresql\_lock\_message](#input\_postgresql\_lock\_message) | Custom message for PostgreSQL lock monitor | `string` | `""` | no |
| [postgresql\_lock\_threshold\_critical](#input\_postgresql\_lock\_threshold\_critical) | Maximum critical acceptable number of locks | `number` | `99` | no |
| [postgresql\_lock\_threshold\_warning](#input\_postgresql\_lock\_threshold\_warning) | Maximum warning acceptable number of locks | `number` | `70` | no |
| [postgresql\_lock\_time\_aggregator](#input\_postgresql\_lock\_time\_aggregator) | Monitor time aggregator for PostgreSQL lock monitor [available values: min, max or avg] | `string` | `"min"` | no |
| [postgresql\_lock\_timeframe](#input\_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 |
| [prefix\_slug](#input\_prefix\_slug) | Prefix string to prepend between brackets on every monitors names | `string` | `""` | no |
## Outputs
| Name | Description |
|------|-------------|
| [postgresql\_availability\_id](#output\_postgresql\_availability\_id) | id for monitor postgresql\_availability |
| [postgresql\_connection\_too\_high\_id](#output\_postgresql\_connection\_too\_high\_id) | id for monitor postgresql\_connection\_too\_high |
| [postgresql\_too\_many\_locks\_id](#output\_postgresql\_too\_many\_locks\_id) | id for monitor postgresql\_too\_many\_locks |
## Related documentation
DataDog documentation: [https://docs.datadoghq.com/integrations/postgres/](https://docs.datadoghq.com/integrations/postgres/)