Merge branch 'MON-114_kubernetes_from_confluence' into 'master'
MON-114 kubernetes pod monitors Closes MON-114 See merge request claranet/pt-monitoring/projects/datadog/terraform/monitors!40
This commit is contained in:
commit
893de3f400
@ -80,6 +80,7 @@ The `//` is very important, it's a terraform specific syntax used to separate gi
|
|||||||
- [cluster](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/caas/kubernetes/cluster/)
|
- [cluster](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/caas/kubernetes/cluster/)
|
||||||
- [ingress](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/caas/kubernetes/ingress/)
|
- [ingress](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/caas/kubernetes/ingress/)
|
||||||
- [vts](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/caas/kubernetes/ingress/vts/)
|
- [vts](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/caas/kubernetes/ingress/vts/)
|
||||||
|
- [pod](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/caas/kubernetes/pod/)
|
||||||
- [workload](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/caas/kubernetes/workload/)
|
- [workload](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/caas/kubernetes/workload/)
|
||||||
- [cloud](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/)
|
- [cloud](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/)
|
||||||
- [aws](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/)
|
- [aws](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/)
|
||||||
|
|||||||
69
caas/kubernetes/pod/README.md
Normal file
69
caas/kubernetes/pod/README.md
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# CAAS KUBERNETES POD DataDog monitors
|
||||||
|
|
||||||
|
## How to use this module
|
||||||
|
|
||||||
|
```
|
||||||
|
module "datadog-monitors-caas-kubernetes-pod" {
|
||||||
|
source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//caas/kubernetes/pod?ref={revision}"
|
||||||
|
|
||||||
|
environment = "${var.environment}"
|
||||||
|
message = "${module.datadog-message-alerting.alerting-message}"
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Creates DataDog monitors with the following checks:
|
||||||
|
|
||||||
|
- Kubernetes Pod CrashLoopBackOff
|
||||||
|
- Kubernetes Pod errors
|
||||||
|
- Kubernetes Pod phase status failed
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
| Name | Description | Type | Default | Required |
|
||||||
|
|------|-------------|:----:|:-----:|:-----:|
|
||||||
|
| crashloopbackoff\_enabled | Flag to enable Pod crashloopbackoff monitor | string | `"true"` | no |
|
||||||
|
| crashloopbackoff\_extra\_tags | Extra tags for Pod crashloopbackoff monitor | list | `[]` | no |
|
||||||
|
| crashloopbackoff\_message | Custom message for Pod crashloopbackoff monitor | string | `""` | no |
|
||||||
|
| crashloopbackoff\_silenced | Groups to mute for Pod crashloopbackoff monitor | map | `{}` | no |
|
||||||
|
| crashloopbackoff\_threshold\_critical | crashloopbackoff critical threshold | string | `"5"` | no |
|
||||||
|
| crashloopbackoff\_threshold\_warning | crashloopbackoff warning threshold | string | `"4"` | no |
|
||||||
|
| crashloopbackoff\_time\_aggregator | Monitor aggregator for Pod crashloopbackoff [available values: min, max or avg] | string | `"sum"` | no |
|
||||||
|
| crashloopbackoff\_timeframe | Monitor timeframe for Pod crashloopbackoff [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_10m"` | no |
|
||||||
|
| environment | Architecture environment | string | n/a | yes |
|
||||||
|
| error\_enabled | Flag to enable Pod errors monitor | string | `"true"` | no |
|
||||||
|
| error\_extra\_tags | Extra tags for Pod errors monitor | list | `[]` | no |
|
||||||
|
| error\_message | Custom message for Pod errors monitor | string | `""` | no |
|
||||||
|
| error\_silenced | Groups to mute for Pod errors monitor | map | `{}` | no |
|
||||||
|
| error\_threshold\_critical | error critical threshold | string | `"1"` | no |
|
||||||
|
| error\_threshold\_warning | error warning threshold | string | `"0.5"` | no |
|
||||||
|
| error\_time\_aggregator | Monitor aggregator for Pod errors [available values: min, max or avg] | string | `"sum"` | no |
|
||||||
|
| error\_timeframe | Monitor timeframe for Pod errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_15m"` | 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\_custom\_excluded | Tags excluded 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 | n/a | yes |
|
||||||
|
| new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no |
|
||||||
|
| pod\_phase\_status\_enabled | Flag to enable Pod phase status monitor | string | `"true"` | no |
|
||||||
|
| pod\_phase\_status\_extra\_tags | Extra tags for Pod phase status monitor | list | `[]` | no |
|
||||||
|
| pod\_phase\_status\_message | Custom message for Pod phase status monitor | string | `""` | no |
|
||||||
|
| pod\_phase\_status\_silenced | Groups to mute for Pod phase status monitor | map | `{}` | no |
|
||||||
|
| pod\_phase\_status\_time\_aggregator | Monitor aggregator for Pod phase status [available values: min, max or avg] | string | `"max"` | no |
|
||||||
|
| pod\_phase\_status\_timeframe | Monitor timeframe for Pod phase status [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 |
|
||||||
|
|------|-------------|
|
||||||
|
| crashloopbackoff\_id | id for monitor crashloopbackoff |
|
||||||
|
| error\_id | id for monitor error |
|
||||||
|
| pod\_phase\_status\_id | id for monitor pod_phase_status |
|
||||||
|
|
||||||
|
## Related documentation
|
||||||
|
|
||||||
|
* [Datadog metrics](https://docs.datadoghq.com/agent/kubernetes/metrics/)
|
||||||
|
* [Datadog documentation](https://docs.datadoghq.com/integrations/kubernetes/)
|
||||||
|
* [Datadog Blog](https://www.datadoghq.com/blog/monitor-kubernetes-docker/)
|
||||||
164
caas/kubernetes/pod/inputs.tf
Normal file
164
caas/kubernetes/pod/inputs.tf
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
# Datadog global variables
|
||||||
|
|
||||||
|
variable "environment" {
|
||||||
|
description = "Architecture environment"
|
||||||
|
}
|
||||||
|
|
||||||
|
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 "filter_tags_custom_excluded" {
|
||||||
|
description = "Tags excluded for custom filtering when filter_tags_use_defaults is false"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "message" {
|
||||||
|
description = "Message sent when a monitor is triggered"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "evaluation_delay" {
|
||||||
|
description = "Delay in seconds for the metric evaluation"
|
||||||
|
default = 15
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "new_host_delay" {
|
||||||
|
description = "Delay in seconds before monitor new resource"
|
||||||
|
default = 300
|
||||||
|
}
|
||||||
|
|
||||||
|
# Datadog monitors variables
|
||||||
|
|
||||||
|
variable "pod_phase_status_silenced" {
|
||||||
|
description = "Groups to mute for Pod phase status monitor"
|
||||||
|
type = "map"
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "pod_phase_status_enabled" {
|
||||||
|
description = "Flag to enable Pod phase status monitor"
|
||||||
|
type = "string"
|
||||||
|
default = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "pod_phase_status_extra_tags" {
|
||||||
|
description = "Extra tags for Pod phase status monitor"
|
||||||
|
type = "list"
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "pod_phase_status_message" {
|
||||||
|
description = "Custom message for Pod phase status monitor"
|
||||||
|
type = "string"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "pod_phase_status_time_aggregator" {
|
||||||
|
description = "Monitor aggregator for Pod phase status [available values: min, max or avg]"
|
||||||
|
type = "string"
|
||||||
|
default = "max"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "pod_phase_status_timeframe" {
|
||||||
|
description = "Monitor timeframe for Pod phase status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||||
|
type = "string"
|
||||||
|
default = "last_5m"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "error_silenced" {
|
||||||
|
description = "Groups to mute for Pod errors monitor"
|
||||||
|
type = "map"
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "error_enabled" {
|
||||||
|
description = "Flag to enable Pod errors monitor"
|
||||||
|
type = "string"
|
||||||
|
default = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "error_extra_tags" {
|
||||||
|
description = "Extra tags for Pod errors monitor"
|
||||||
|
type = "list"
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "error_message" {
|
||||||
|
description = "Custom message for Pod errors monitor"
|
||||||
|
type = "string"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "error_time_aggregator" {
|
||||||
|
description = "Monitor aggregator for Pod errors [available values: min, max or avg]"
|
||||||
|
type = "string"
|
||||||
|
default = "sum"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "error_timeframe" {
|
||||||
|
description = "Monitor timeframe for Pod errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||||
|
type = "string"
|
||||||
|
default = "last_15m"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "error_threshold_critical" {
|
||||||
|
default = 1
|
||||||
|
description = "error critical threshold"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "error_threshold_warning" {
|
||||||
|
default = 0.5
|
||||||
|
description = "error warning threshold"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "crashloopbackoff_silenced" {
|
||||||
|
description = "Groups to mute for Pod crashloopbackoff monitor"
|
||||||
|
type = "map"
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "crashloopbackoff_enabled" {
|
||||||
|
description = "Flag to enable Pod crashloopbackoff monitor"
|
||||||
|
type = "string"
|
||||||
|
default = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "crashloopbackoff_extra_tags" {
|
||||||
|
description = "Extra tags for Pod crashloopbackoff monitor"
|
||||||
|
type = "list"
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "crashloopbackoff_message" {
|
||||||
|
description = "Custom message for Pod crashloopbackoff monitor"
|
||||||
|
type = "string"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "crashloopbackoff_time_aggregator" {
|
||||||
|
description = "Monitor aggregator for Pod crashloopbackoff [available values: min, max or avg]"
|
||||||
|
type = "string"
|
||||||
|
default = "sum"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "crashloopbackoff_timeframe" {
|
||||||
|
description = "Monitor timeframe for Pod crashloopbackoff [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||||
|
type = "string"
|
||||||
|
default = "last_10m"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "crashloopbackoff_threshold_critical" {
|
||||||
|
default = 5
|
||||||
|
description = "crashloopbackoff critical threshold"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "crashloopbackoff_threshold_warning" {
|
||||||
|
default = 4
|
||||||
|
description = "crashloopbackoff warning threshold"
|
||||||
|
}
|
||||||
42
caas/kubernetes/pod/modules.tf
Normal file
42
caas/kubernetes/pod/modules.tf
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
module "filter-tags" {
|
||||||
|
source = "../../../common/filter-tags"
|
||||||
|
|
||||||
|
environment = "${var.environment}"
|
||||||
|
resource = "kubernetes"
|
||||||
|
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
|
||||||
|
filter_tags_custom = "${var.filter_tags_custom}"
|
||||||
|
filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}"
|
||||||
|
}
|
||||||
|
|
||||||
|
module "filter-tags-phase" {
|
||||||
|
source = "../../../common/filter-tags"
|
||||||
|
|
||||||
|
environment = "${var.environment}"
|
||||||
|
resource = "kubernetes"
|
||||||
|
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
|
||||||
|
filter_tags_custom = "${var.filter_tags_custom}"
|
||||||
|
filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}"
|
||||||
|
extra_tags = ["!phase:pending,!phase:running,!phase:succeeded,!phase:unknown"]
|
||||||
|
}
|
||||||
|
|
||||||
|
module "filter-tags-nocrashloopbackoff" {
|
||||||
|
source = "../../../common/filter-tags"
|
||||||
|
|
||||||
|
environment = "${var.environment}"
|
||||||
|
resource = "kubernetes"
|
||||||
|
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
|
||||||
|
filter_tags_custom = "${var.filter_tags_custom}"
|
||||||
|
filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}"
|
||||||
|
extra_tags = ["!reason:crashloopbackoff"]
|
||||||
|
}
|
||||||
|
|
||||||
|
module "filter-tags-crashloopbackoff" {
|
||||||
|
source = "../../../common/filter-tags"
|
||||||
|
|
||||||
|
environment = "${var.environment}"
|
||||||
|
resource = "kubernetes"
|
||||||
|
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
|
||||||
|
filter_tags_custom = "${var.filter_tags_custom}"
|
||||||
|
filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}"
|
||||||
|
extra_tags = ["reason:crashloopbackoff"]
|
||||||
|
}
|
||||||
93
caas/kubernetes/pod/monitors-k8s-pod.tf
Normal file
93
caas/kubernetes/pod/monitors-k8s-pod.tf
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
resource "datadog_monitor" "pod_phase_status" {
|
||||||
|
count = "${var.pod_phase_status_enabled == "true" ? 1 : 0}"
|
||||||
|
name = "[${var.environment}] Kubernetes Pod phase status failed"
|
||||||
|
type = "metric alert"
|
||||||
|
message = "${coalesce(var.pod_phase_status_message, var.message)}"
|
||||||
|
|
||||||
|
query = <<EOQ
|
||||||
|
${var.pod_phase_status_time_aggregator}(${var.pod_phase_status_timeframe}):
|
||||||
|
sum:kubernetes_state.pod.status_phase${module.filter-tags-phase.query_alert} by {namespace} > 0
|
||||||
|
EOQ
|
||||||
|
|
||||||
|
thresholds {
|
||||||
|
critical = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
evaluation_delay = "${var.evaluation_delay}"
|
||||||
|
new_host_delay = "${var.new_host_delay}"
|
||||||
|
|
||||||
|
notify_no_data = false
|
||||||
|
renotify_interval = 0
|
||||||
|
notify_audit = false
|
||||||
|
timeout_h = 0
|
||||||
|
include_tags = true
|
||||||
|
locked = false
|
||||||
|
require_full_window = true
|
||||||
|
|
||||||
|
silenced = "${var.pod_phase_status_silenced}"
|
||||||
|
tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-pod", "team:claranet", "created-by:terraform", "${var.pod_phase_status_extra_tags}"]
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "datadog_monitor" "error" {
|
||||||
|
count = "${var.error_enabled == "true" ? 1 : 0}"
|
||||||
|
name = "[${var.environment}] Kubernetes Pod errors {{#is_alert}}{{{comparator}}} {{threshold}} times ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} times ({{value}}){{/is_warning}}"
|
||||||
|
type = "metric alert"
|
||||||
|
message = "${coalesce(var.error_message, var.message)}"
|
||||||
|
|
||||||
|
query = <<EOQ
|
||||||
|
${var.error_time_aggregator}(${var.error_timeframe}):
|
||||||
|
sum:kubernetes_state.container.status_report.count.waiting${module.filter-tags-nocrashloopbackoff.query_alert} by {namespace,reason}.as_count()
|
||||||
|
>= ${var.error_threshold_critical}
|
||||||
|
EOQ
|
||||||
|
|
||||||
|
thresholds {
|
||||||
|
critical = "${var.error_threshold_critical}"
|
||||||
|
warning = "${var.error_threshold_warning}"
|
||||||
|
}
|
||||||
|
|
||||||
|
evaluation_delay = "${var.evaluation_delay}"
|
||||||
|
new_host_delay = "${var.new_host_delay}"
|
||||||
|
|
||||||
|
notify_no_data = false
|
||||||
|
renotify_interval = 0
|
||||||
|
notify_audit = false
|
||||||
|
timeout_h = 0
|
||||||
|
include_tags = true
|
||||||
|
locked = false
|
||||||
|
require_full_window = true
|
||||||
|
|
||||||
|
silenced = "${var.error_silenced}"
|
||||||
|
tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-pod", "team:claranet", "created-by:terraform", "${var.error_extra_tags}"]
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "datadog_monitor" "crashloopbackoff" {
|
||||||
|
count = "${var.crashloopbackoff_enabled == "true" ? 1 : 0}"
|
||||||
|
name = "[${var.environment}] Kubernetes Pod CrashLoopBackOff"
|
||||||
|
type = "metric alert"
|
||||||
|
message = "${coalesce(var.crashloopbackoff_message, var.message)}"
|
||||||
|
|
||||||
|
query = <<EOQ
|
||||||
|
change(${var.crashloopbackoff_time_aggregator}(${var.crashloopbackoff_timeframe}),${var.crashloopbackoff_timeframe}):
|
||||||
|
max:kubernetes_state.container.status_report.count.waiting${module.filter-tags-crashloopbackoff.query_alert} by {namespace}.as_count()
|
||||||
|
> ${var.crashloopbackoff_threshold_critical}
|
||||||
|
EOQ
|
||||||
|
|
||||||
|
thresholds {
|
||||||
|
critical = "${var.crashloopbackoff_threshold_critical}"
|
||||||
|
warning = "${var.crashloopbackoff_threshold_warning}"
|
||||||
|
}
|
||||||
|
|
||||||
|
evaluation_delay = "${var.evaluation_delay}"
|
||||||
|
new_host_delay = "${var.new_host_delay}"
|
||||||
|
|
||||||
|
notify_no_data = false
|
||||||
|
renotify_interval = 0
|
||||||
|
notify_audit = false
|
||||||
|
timeout_h = 0
|
||||||
|
include_tags = true
|
||||||
|
locked = false
|
||||||
|
require_full_window = true
|
||||||
|
|
||||||
|
silenced = "${var.crashloopbackoff_silenced}"
|
||||||
|
tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-pod", "team:claranet", "created-by:terraform", "${var.crashloopbackoff_extra_tags}"]
|
||||||
|
}
|
||||||
14
caas/kubernetes/pod/outputs.tf
Normal file
14
caas/kubernetes/pod/outputs.tf
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
output "pod_phase_status_id" {
|
||||||
|
description = "id for monitor pod_phase_status"
|
||||||
|
value = "${datadog_monitor.pod_phase_status.*.id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
output "error_id" {
|
||||||
|
description = "id for monitor error"
|
||||||
|
value = "${datadog_monitor.error.*.id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
output "crashloopbackoff_id" {
|
||||||
|
description = "id for monitor crashloopbackoff"
|
||||||
|
value = "${datadog_monitor.crashloopbackoff.*.id}"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user