Merged in MON-230-gcp-bigquery (pull request #101)

MON-230 Monitors for GCP Big Query

Approved-by: Rafael Romero Carmona <rafael.romero.carmona@fr.clara.net>
Approved-by: Quentin Manfroi <quentin.manfroi@yahoo.fr>
Approved-by: Alexandre Gaillet <alexandre.gaillet@fr.clara.net>
This commit is contained in:
Rafael Romero Carmona 2018-08-30 10:53:57 +00:00 committed by Quentin Manfroi
commit de47df79b3
5 changed files with 868 additions and 0 deletions

View File

@ -92,6 +92,7 @@ The `//` is very important, it's a terraform specific syntax used to separate gi
- [storage](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/storage/)
- [stream-analytics](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/stream-analytics/)
- [gcp](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/gcp/)
- [big-query](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/gcp/big-query/)
- [cloud-sql](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/gcp/cloud-sql/)
- [common](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/gcp/cloud-sql/common/)
- [mysql](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/gcp/cloud-sql/mysql/)

View File

@ -0,0 +1,111 @@
# CLOUD GCP BIG-QUERY DataDog monitors
## How to use this module
```
module "datadog-monitors-cloud-gcp-big-query" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/gcp/big-query?ref={revision}"
environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}"
}
```
## Purpose
Creates DataDog monitors with the following checks:
- GCP Big Query Available Slots
- GCP Big Query Concurrent Queries
- GCP Big Query Execution Time
- GCP Big Query Scanned Bytes Billed
- GCP Big Query Scanned Bytes
- GCP Big Query Stored Bytes
- GCP Big Query Table Count
- GCP Big Query Uploaded Bytes Billed
- GCP Big Query Uploaded Bytes
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| available_slots_extra_tags | Extra tags for GCP Big Query Available Slots monitor | list | `<list>` | no |
| available_slots_message | Custom message for the Available Slots monitor | string | `` | no |
| available_slots_silenced | Groups to mute for GCP Big Query Available Slots monitor. | map | `<map>` | no |
| available_slots_threshold_critical | Available Slots (critical threshold) | string | `200` | no |
| available_slots_threshold_warning | Available Slots (warning threshold) | string | `300` | no |
| available_slots_timeframe | Timeframe for the Available Slots monitor | string | `last_5m` | no |
| concurrent_queries_extra_tags | Extra tags for GCP Big Query Concurrent Queries monitor | list | `<list>` | no |
| concurrent_queries_message | Custom message for the Concurrent Queries monitor | string | `` | no |
| concurrent_queries_silenced | Groups to mute for GCP Big Query Concurrent Queries monitor | map | `<map>` | no |
| concurrent_queries_threshold_critical | Concurrent Queries (critical threshold) (hard limit 50) | string | `45` | no |
| concurrent_queries_threshold_warning | Concurrent Queries (warning threshold) (hard limit 50) | string | `40` | no |
| concurrent_queries_timeframe | Timeframe for the Concurrent Queries monitor | string | `last_5m` | no |
| environment | Architecture environment | string | - | yes |
| evaluation_delay | Delay in seconds for the metric evaluation | string | `900` | no |
| execution_time_extra_tags | Extra tags for GCP Big Query Execution Time monitor | list | `<list>` | no |
| execution_time_message | Custom message for the Execution Time monitor | string | `` | no |
| execution_time_silenced | Groups to mute for GCP Big Query Execution Time monitor. Muted by default. | map | `<map>` | no |
| execution_time_threshold_critical | Average Execution Time in seconds (critical threshold) | string | `150` | no |
| execution_time_threshold_warning | Average Execution Time in seconds (warning threshold) | string | `100` | no |
| execution_time_timeframe | Timeframe for the Execution Time monitor | string | `last_5m` | no |
| filter_tags | Tags used for filtering | string | `*` | no |
| message | Message sent when a monitor is triggered | string | - | yes |
| new_host_delay | Delay in seconds for the new host evaluation | string | `300` | no |
| scanned_bytes_billed_extra_tags | Extra tags for GCP Big Query Scanned Bytes Billed monitor | list | `<list>` | no |
| scanned_bytes_billed_message | Custom message for the Scanned Bytes Billed monitor | string | `` | no |
| scanned_bytes_billed_silenced | Groups to mute for GCP Big Query Scanned Bytes Billed monitor. Muted by default. | map | `<map>` | no |
| scanned_bytes_billed_threshold_critical | Scanned Bytes Billed (critical threshold) | string | `1` | no |
| scanned_bytes_billed_threshold_warning | Scanned Bytes Billed (warning threshold) | string | `0` | no |
| scanned_bytes_billed_timeframe | Timeframe for the Scanned Bytes Billed monitor | string | `last_4h` | no |
| scanned_bytes_extra_tags | Extra tags for GCP Big Query Scanned Bytes monitor | list | `<list>` | no |
| scanned_bytes_message | Custom message for the Scanned Bytes monitor | string | `` | no |
| scanned_bytes_silenced | Groups to mute for GCP Big Query Scanned Bytes monitor. Muted by default. | map | `<map>` | no |
| scanned_bytes_threshold_critical | Scanned Bytes (critical threshold) | string | `1` | no |
| scanned_bytes_threshold_warning | Scanned Bytes (warning threshold) | string | `0` | no |
| scanned_bytes_timeframe | Timeframe for the Scanned Bytes monitor | string | `last_4h` | no |
| stored_bytes_extra_tags | Extra tags for GCP Big Query Stored Bytes monitor | list | `<list>` | no |
| stored_bytes_message | Custom message for the Stored Bytes monitor | string | `` | no |
| stored_bytes_silenced | Groups to mute for GCP Big Query Stored Bytes monitor. Muted by default. | map | `<map>` | no |
| stored_bytes_threshold_critical | Stored Bytes in fraction (critical threshold) | string | `1` | no |
| stored_bytes_threshold_warning | Stored Bytes in fraction (warning threshold) | string | `0` | no |
| stored_bytes_timeframe | Timeframe for the Stored Bytes monitor | string | `last_5m` | no |
| table_count_extra_tags | Extra tags for GCP Big Query Table Count monitor | list | `<list>` | no |
| table_count_message | Custom message for the Table Count monitor | string | `` | no |
| table_count_silenced | Groups to mute for GCP Big Query Table Count monitor. Muted by default. | map | `<map>` | no |
| table_count_threshold_critical | Table Count (critical threshold) | string | `1` | no |
| table_count_threshold_warning | Table Count (warning threshold) | string | `0` | no |
| table_count_timeframe | Timeframe for the Table Count monitor | string | `last_4h` | no |
| uploaded_bytes_billed_extra_tags | Extra tags for GCP Big Query Scanned Bytes monitor | list | `<list>` | no |
| uploaded_bytes_billed_message | Custom message for the Uploaded Bytes Billed monitor | string | `` | no |
| uploaded_bytes_billed_silenced | Groups to mute for GCP Big Query Uploaded Bytes Billed monitor. Muted by default. | map | `<map>` | no |
| uploaded_bytes_billed_threshold_critical | Uploaded Bytes Billed (critical threshold) | string | `1` | no |
| uploaded_bytes_billed_threshold_warning | Uploaded Bytes Billed (warning threshold) | string | `0` | no |
| uploaded_bytes_billed_timeframe | Timeframe for the Uploaded Bytes Billed monitor | string | `last_4h` | no |
| uploaded_bytes_extra_tags | Extra tags for GCP Big Query Uploaded Bytes monitor | list | `<list>` | no |
| uploaded_bytes_message | Custom message for the Uploaded Bytes monitor | string | `` | no |
| uploaded_bytes_silenced | Groups to mute for GCP Big Query Uploaded Bytes monitor. Muted by default. | map | `<map>` | no |
| uploaded_bytes_threshold_critical | Uploaded Bytes (critical threshold) | string | `1` | no |
| uploaded_bytes_threshold_warning | Uploaded Bytes (warning threshold) | string | `0` | no |
| uploaded_bytes_timeframe | Timeframe for the Uploaded Bytes monitor | string | `last_4h` | no |
## Outputs
| Name | Description |
|------|-------------|
| available_slots_id | id for monitor available_slots |
| concurrent_queries_id | id for monitor concurrent_queries |
| execution_time_id | id for monitor execution_time |
| scanned_bytes_billed_id | id for monitor scanned_bytes_billed |
| scanned_bytes_id | id for monitor scanned_bytes |
| stored_bytes_id | id for monitor stored_bytes |
| table_count_id | id for monitor table_count |
| uploaded_bytes_billed_id | id for monitor uploaded_bytes_billed |
| uploaded_bytes_id | id for monitor uploaded_bytes |
## Related documentation
* [GCP Big Query monitoring](https://cloud.google.com/bigquery/docs/monitoring)
* [Datadog Integration for GCP Big Query](https://docs.datadoghq.com/integrations/google_cloud_big_query/)
* [GCP Big Query Quotas and Limits](https://cloud.google.com/bigquery/quotas)

View File

@ -0,0 +1,394 @@
#
# Datadog global variables
#
variable "environment" {
description = "Architecture environment"
type = "string"
}
variable "filter_tags" {
description = "Tags used for filtering"
default = "*"
}
variable "message" {
description = "Message sent when a monitor is triggered"
}
variable "evaluation_delay" {
description = "Delay in seconds for the metric evaluation"
default = 900
}
variable "new_host_delay" {
description = "Delay in seconds for the new host evaluation"
default = 300
}
#
# Concurrent queries
#
variable "concurrent_queries_message" {
description = "Custom message for the Concurrent Queries monitor"
type = "string"
default = ""
}
variable "concurrent_queries_timeframe" {
description = "Timeframe for the Concurrent Queries monitor"
type = "string"
default = "last_5m"
}
variable "concurrent_queries_threshold_warning" {
description = "Concurrent Queries (warning threshold) (hard limit 50)"
type = "string"
default = 40
}
variable "concurrent_queries_threshold_critical" {
description = "Concurrent Queries (critical threshold) (hard limit 50)"
type = "string"
default = 45
}
variable "concurrent_queries_silenced" {
description = "Groups to mute for GCP Big Query Concurrent Queries monitor"
type = "map"
default = {}
}
variable "concurrent_queries_extra_tags" {
description = "Extra tags for GCP Big Query Concurrent Queries monitor"
type = "list"
default = []
}
#
# Execution Time
#
variable "execution_time_message" {
description = "Custom message for the Execution Time monitor"
type = "string"
default = ""
}
variable "execution_time_timeframe" {
description = "Timeframe for the Execution Time monitor"
type = "string"
default = "last_5m"
}
variable "execution_time_threshold_warning" {
description = "Average Execution Time in seconds (warning threshold)"
type = "string"
default = 100
}
variable "execution_time_threshold_critical" {
description = "Average Execution Time in seconds (critical threshold)"
type = "string"
default = 150
}
variable "execution_time_silenced" {
description = "Groups to mute for GCP Big Query Execution Time monitor. Muted by default."
type = "map"
default = {}
}
variable "execution_time_extra_tags" {
description = "Extra tags for GCP Big Query Execution Time monitor"
type = "list"
default = []
}
#
# Scanned Bytes
#
variable "scanned_bytes_message" {
description = "Custom message for the Scanned Bytes monitor"
type = "string"
default = ""
}
variable "scanned_bytes_timeframe" {
description = "Timeframe for the Scanned Bytes monitor"
type = "string"
default = "last_4h"
}
variable "scanned_bytes_threshold_warning" {
description = "Scanned Bytes (warning threshold)"
type = "string"
default = 0
}
variable "scanned_bytes_threshold_critical" {
description = "Scanned Bytes (critical threshold)"
type = "string"
default = 1
}
variable "scanned_bytes_silenced" {
description = "Groups to mute for GCP Big Query Scanned Bytes monitor. Muted by default."
type = "map"
default = {}
}
variable "scanned_bytes_extra_tags" {
description = "Extra tags for GCP Big Query Scanned Bytes monitor"
type = "list"
default = []
}
#
# Scanned Bytes Billed
#
variable "scanned_bytes_billed_message" {
description = "Custom message for the Scanned Bytes Billed monitor"
type = "string"
default = ""
}
variable "scanned_bytes_billed_timeframe" {
description = "Timeframe for the Scanned Bytes Billed monitor"
type = "string"
default = "last_4h"
}
variable "scanned_bytes_billed_threshold_warning" {
description = "Scanned Bytes Billed (warning threshold)"
type = "string"
default = 0
}
variable "scanned_bytes_billed_threshold_critical" {
description = "Scanned Bytes Billed (critical threshold)"
type = "string"
default = 1
}
variable "scanned_bytes_billed_silenced" {
description = "Groups to mute for GCP Big Query Scanned Bytes Billed monitor. Muted by default."
type = "map"
default = {}
}
variable "scanned_bytes_billed_extra_tags" {
description = "Extra tags for GCP Big Query Scanned Bytes Billed monitor"
type = "list"
default = []
}
#
# Available Slots
#
variable "available_slots_message" {
description = "Custom message for the Available Slots monitor"
type = "string"
default = ""
}
variable "available_slots_timeframe" {
description = "Timeframe for the Available Slots monitor"
type = "string"
default = "last_5m"
}
variable "available_slots_threshold_warning" {
description = "Available Slots (warning threshold)"
type = "string"
default = 300
}
variable "available_slots_threshold_critical" {
description = "Available Slots (critical threshold)"
type = "string"
default = 200
}
variable "available_slots_silenced" {
description = "Groups to mute for GCP Big Query Available Slots monitor."
type = "map"
default = {}
}
variable "available_slots_extra_tags" {
description = "Extra tags for GCP Big Query Available Slots monitor"
type = "list"
default = []
}
#
# Stored Bytes
#
variable "stored_bytes_message" {
description = "Custom message for the Stored Bytes monitor"
type = "string"
default = ""
}
variable "stored_bytes_timeframe" {
description = "Timeframe for the Stored Bytes monitor"
type = "string"
default = "last_5m"
}
variable "stored_bytes_threshold_warning" {
description = "Stored Bytes in fraction (warning threshold)"
type = "string"
default = 0
}
variable "stored_bytes_threshold_critical" {
description = "Stored Bytes in fraction (critical threshold)"
type = "string"
default = 1
}
variable "stored_bytes_silenced" {
description = "Groups to mute for GCP Big Query Stored Bytes monitor. Muted by default."
type = "map"
default = {}
}
variable "stored_bytes_extra_tags" {
description = "Extra tags for GCP Big Query Stored Bytes monitor"
type = "list"
default = []
}
#
# Table Count
#
variable "table_count_message" {
description = "Custom message for the Table Count monitor"
type = "string"
default = ""
}
variable "table_count_timeframe" {
description = "Timeframe for the Table Count monitor"
type = "string"
default = "last_4h"
}
variable "table_count_threshold_warning" {
description = "Table Count (warning threshold)"
type = "string"
default = 0
}
variable "table_count_threshold_critical" {
description = "Table Count (critical threshold)"
type = "string"
default = 1
}
variable "table_count_silenced" {
description = "Groups to mute for GCP Big Query Table Count monitor. Muted by default."
type = "map"
default = {}
}
variable "table_count_extra_tags" {
description = "Extra tags for GCP Big Query Table Count monitor"
type = "list"
default = []
}
#
# Uploaded Bytes
#
variable "uploaded_bytes_message" {
description = "Custom message for the Uploaded Bytes monitor"
type = "string"
default = ""
}
variable "uploaded_bytes_timeframe" {
description = "Timeframe for the Uploaded Bytes monitor"
type = "string"
default = "last_4h"
}
variable "uploaded_bytes_threshold_warning" {
description = "Uploaded Bytes (warning threshold)"
type = "string"
default = 0
}
variable "uploaded_bytes_threshold_critical" {
description = "Uploaded Bytes (critical threshold)"
type = "string"
default = 1
}
variable "uploaded_bytes_silenced" {
description = "Groups to mute for GCP Big Query Uploaded Bytes monitor. Muted by default."
type = "map"
default = {}
}
variable "uploaded_bytes_extra_tags" {
description = "Extra tags for GCP Big Query Uploaded Bytes monitor"
type = "list"
default = []
}
#
# Uploaded Bytes Billed
#
variable "uploaded_bytes_billed_message" {
description = "Custom message for the Uploaded Bytes Billed monitor"
type = "string"
default = ""
}
variable "uploaded_bytes_billed_timeframe" {
description = "Timeframe for the Uploaded Bytes Billed monitor"
type = "string"
default = "last_4h"
}
variable "uploaded_bytes_billed_threshold_warning" {
description = "Uploaded Bytes Billed (warning threshold)"
type = "string"
default = 0
}
variable "uploaded_bytes_billed_threshold_critical" {
description = "Uploaded Bytes Billed (critical threshold)"
type = "string"
default = 1
}
variable "uploaded_bytes_billed_silenced" {
description = "Groups to mute for GCP Big Query Uploaded Bytes Billed monitor. Muted by default."
type = "map"
default = {}
}
variable "uploaded_bytes_billed_extra_tags" {
description = "Extra tags for GCP Big Query Scanned Bytes monitor"
type = "list"
default = []
}

View File

@ -0,0 +1,318 @@
#
# Concurrent queries
#
resource "datadog_monitor" "concurrent_queries" {
name = "[${var.environment}] GCP Big Query Concurrent Queries {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}"
message = "${coalesce(var.concurrent_queries_message, var.message)}"
type = "metric alert"
query = <<EOF
avg(${var.concurrent_queries_timeframe}): avg:gcp.bigquery.query.count{${var.filter_tags}}
> ${var.concurrent_queries_threshold_critical}
EOF
thresholds {
warning = "${var.concurrent_queries_threshold_warning}"
critical = "${var.concurrent_queries_threshold_critical}"
}
include_tags = true
notify_no_data = false
require_full_window = false
renotify_interval = 0
notify_audit = false
timeout_h = 0
locked = false
evaluation_delay = "${var.evaluation_delay}"
new_host_delay = "${var.new_host_delay}"
silenced = "${var.concurrent_queries_silenced}"
tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.concurrent_queries_extra_tags}"]
}
#
# Execution Time
#
resource "datadog_monitor" "execution_time" {
name = "[${var.environment}] GCP Big Query Execution Time {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/is_warning}}"
message = "${coalesce(var.execution_time_message, var.message)}"
type = "metric alert"
query = <<EOF
avg(${var.execution_time_timeframe}): avg:gcp.bigquery.query.execution_times.avg{${var.filter_tags}}
> ${var.execution_time_threshold_critical}
EOF
thresholds {
warning = "${var.execution_time_threshold_warning}"
critical = "${var.execution_time_threshold_critical}"
}
include_tags = true
notify_no_data = false
require_full_window = false
renotify_interval = 0
notify_audit = false
timeout_h = 0
locked = false
evaluation_delay = "${var.evaluation_delay}"
new_host_delay = "${var.new_host_delay}"
silenced = "${var.execution_time_silenced}"
tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.execution_time_extra_tags}"]
}
#
# Scanned Bytes
#
resource "datadog_monitor" "scanned_bytes" {
name = "[${var.environment}] GCP Big Query Scanned Bytes {{#is_alert}}{{{comparator}}} {{threshold}}B/mn ({{value}}B/mn){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}B/mn ({{value}}B/mn){{/is_warning}}"
message = "${coalesce(var.scanned_bytes_message, var.message)}"
type = "metric alert"
query = <<EOF
avg(${var.scanned_bytes_timeframe}): avg:gcp.bigquery.query.scanned_bytes{${var.filter_tags}}
> ${var.scanned_bytes_threshold_critical}
EOF
thresholds {
warning = "${var.scanned_bytes_threshold_warning}"
critical = "${var.scanned_bytes_threshold_critical}"
}
include_tags = true
notify_no_data = false
require_full_window = false
renotify_interval = 0
notify_audit = false
timeout_h = 0
locked = false
evaluation_delay = "${var.evaluation_delay}"
new_host_delay = "${var.new_host_delay}"
silenced = "${var.scanned_bytes_silenced}"
tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.scanned_bytes_extra_tags}"]
}
#
# Scanned Bytes Billed
#
resource "datadog_monitor" "scanned_bytes_billed" {
name = "[${var.environment}] GCP Big Query Scanned Bytes Billed {{#is_alert}}{{{comparator}}} {{threshold}}B/mn ({{value}}B/mn){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}B/mn ({{value}}B/mn){{/is_warning}}"
message = "${coalesce(var.scanned_bytes_billed_message, var.message)}"
type = "metric alert"
query = <<EOF
avg(${var.scanned_bytes_billed_timeframe}): avg:gcp.bigquery.query.scanned_bytes_billed{${var.filter_tags}}
> ${var.scanned_bytes_billed_threshold_critical}
EOF
thresholds {
warning = "${var.scanned_bytes_billed_threshold_warning}"
critical = "${var.scanned_bytes_billed_threshold_critical}"
}
include_tags = true
notify_no_data = false
require_full_window = false
renotify_interval = 0
notify_audit = false
timeout_h = 0
locked = false
evaluation_delay = "${var.evaluation_delay}"
new_host_delay = "${var.new_host_delay}"
silenced = "${var.scanned_bytes_billed_silenced}"
tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.scanned_bytes_billed_extra_tags}"]
}
#
# Available Slots
#
resource "datadog_monitor" "available_slots" {
name = "[${var.environment}] GCP Big Query Available Slots {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}"
message = "${coalesce(var.available_slots_message, var.message)}"
type = "metric alert"
query = <<EOF
avg(${var.available_slots_timeframe}): avg:gcp.bigquery.slots.total_available{${var.filter_tags}}
< ${var.available_slots_threshold_critical}
EOF
thresholds {
warning = "${var.available_slots_threshold_warning}"
critical = "${var.available_slots_threshold_critical}"
}
include_tags = true
notify_no_data = false
require_full_window = false
renotify_interval = 0
notify_audit = false
timeout_h = 0
locked = false
evaluation_delay = "${var.evaluation_delay}"
new_host_delay = "${var.new_host_delay}"
silenced = "${var.available_slots_silenced}"
tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.available_slots_extra_tags}"]
}
#
# Stored Bytes
#
resource "datadog_monitor" "stored_bytes" {
name = "[${var.environment}] GCP Big Query Stored Bytes {{#is_alert}}{{{comparator}}} {{threshold}}B ({{value}}B){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}B ({{value}}B){{/is_warning}}"
message = "${coalesce(var.stored_bytes_message, var.message)}"
type = "metric alert"
query = <<EOF
avg(${var.stored_bytes_timeframe}): avg:gcp.bigquery.storage.stored_bytes{${var.filter_tags}}
by {dataset_id,table}
> ${var.stored_bytes_threshold_critical}
EOF
thresholds {
warning = "${var.stored_bytes_threshold_warning}"
critical = "${var.stored_bytes_threshold_critical}"
}
include_tags = true
notify_no_data = false
require_full_window = false
renotify_interval = 0
notify_audit = false
timeout_h = 0
locked = false
evaluation_delay = "${var.evaluation_delay}"
new_host_delay = "${var.new_host_delay}"
silenced = "${var.stored_bytes_silenced}"
tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.stored_bytes_extra_tags}"]
}
#
# Table Count
#
resource "datadog_monitor" "table_count" {
name = "[${var.environment}] GCP Big Query Table Count {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}"
message = "${coalesce(var.table_count_message, var.message)}"
type = "metric alert"
query = <<EOF
avg(${var.table_count_timeframe}): avg:gcp.bigquery.storage.table_count{${var.filter_tags}}
by {dataset_id}
> ${var.table_count_threshold_critical}
EOF
thresholds {
warning = "${var.table_count_threshold_warning}"
critical = "${var.table_count_threshold_critical}"
}
include_tags = true
notify_no_data = false
require_full_window = false
renotify_interval = 0
notify_audit = false
timeout_h = 0
locked = false
evaluation_delay = "${var.evaluation_delay}"
new_host_delay = "${var.new_host_delay}"
silenced = "${var.table_count_silenced}"
tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.table_count_extra_tags}"]
}
#
# Uploaded Bytes
#
resource "datadog_monitor" "uploaded_bytes" {
name = "[${var.environment}] GCP Big Query Uploaded Bytes {{#is_alert}}{{{comparator}}} {{threshold}}B/mn ({{value}}B/mn){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}B/mn ({{value}}B/mn){{/is_warning}}"
message = "${coalesce(var.uploaded_bytes_message, var.message)}"
type = "metric alert"
query = <<EOF
avg(${var.uploaded_bytes_timeframe}): avg:gcp.bigquery.storage.uploaded_bytes{${var.filter_tags}}
by {dataset_id,table}
> ${var.uploaded_bytes_threshold_critical}
EOF
thresholds {
warning = "${var.uploaded_bytes_threshold_warning}"
critical = "${var.uploaded_bytes_threshold_critical}"
}
include_tags = true
notify_no_data = false
require_full_window = false
renotify_interval = 0
notify_audit = false
timeout_h = 0
locked = false
evaluation_delay = "${var.evaluation_delay}"
new_host_delay = "${var.new_host_delay}"
silenced = "${var.uploaded_bytes_silenced}"
tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.uploaded_bytes_extra_tags}"]
}
#
# Uploaded Bytes Billed
#
resource "datadog_monitor" "uploaded_bytes_billed" {
name = "[${var.environment}] GCP Big Query Uploaded Bytes Billed {{#is_alert}}{{{comparator}}} {{threshold}}B/mn ({{value}}B/mn){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}B/mn ({{value}}B/mn){{/is_warning}}"
message = "${coalesce(var.uploaded_bytes_billed_message, var.message)}"
type = "metric alert"
query = <<EOF
avg(${var.uploaded_bytes_billed_timeframe}): avg:gcp.bigquery.storage.uploaded_bytes{${var.filter_tags}}
by {dataset_id,table}
> ${var.uploaded_bytes_billed_threshold_critical}
EOF
thresholds {
warning = "${var.uploaded_bytes_billed_threshold_warning}"
critical = "${var.uploaded_bytes_billed_threshold_critical}"
}
include_tags = true
notify_no_data = false
require_full_window = false
renotify_interval = 0
notify_audit = false
timeout_h = 0
locked = false
evaluation_delay = "${var.evaluation_delay}"
new_host_delay = "${var.new_host_delay}"
silenced = "${var.uploaded_bytes_billed_silenced}"
tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.uploaded_bytes_billed_extra_tags}"]
}

View File

@ -0,0 +1,44 @@
output "concurrent_queries_id" {
description = "id for monitor concurrent_queries"
value = "${datadog_monitor.concurrent_queries.*.id}"
}
output "execution_time_id" {
description = "id for monitor execution_time"
value = "${datadog_monitor.execution_time.*.id}"
}
output "scanned_bytes_id" {
description = "id for monitor scanned_bytes"
value = "${datadog_monitor.scanned_bytes.*.id}"
}
output "scanned_bytes_billed_id" {
description = "id for monitor scanned_bytes_billed"
value = "${datadog_monitor.scanned_bytes_billed.*.id}"
}
output "available_slots_id" {
description = "id for monitor available_slots"
value = "${datadog_monitor.available_slots.*.id}"
}
output "stored_bytes_id" {
description = "id for monitor stored_bytes"
value = "${datadog_monitor.stored_bytes.*.id}"
}
output "table_count_id" {
description = "id for monitor table_count"
value = "${datadog_monitor.table_count.*.id}"
}
output "uploaded_bytes_id" {
description = "id for monitor uploaded_bytes"
value = "${datadog_monitor.uploaded_bytes.*.id}"
}
output "uploaded_bytes_billed_id" {
description = "id for monitor uploaded_bytes_billed"
value = "${datadog_monitor.uploaded_bytes_billed.*.id}"
}