13 KiB
13 KiB
DataDog Monitors
This repository aims to provide a base of generic and pre configured monitors for Datadog templated thanks to Terraform and the Datadog Provider.
Important notes
- This repository provide multiple Terraform modules which could be imported, you must choose the one(s) you need.
- Each of these modules contains the most commons monitors, but they probably do not fulfill all your needs.
- You still can create some specific DataDog monitors after importing a module, it's even advisable to complete your needs.
- You will find a complete
README.mdon each module, explaining how to use it and its specificities if there. - The
alerting-messagemodule could be used to easily generate a templating message to re-use and could be used multiple times to suit different use cases. - Some monitors are disabled by default because not generic or "plug and play" enough, if you use them you will need to tweak them or in some cases disabled another one which could "duplicate" the check.
Getting started
Terraform
Here is the minimum version required to use these modules of integrations.
terraform {
required_version = ">= 0.12.7"
}
DataDog provider
Here is the last tester terraform provider version for datadog but next versions should work too.
provider "datadog" {
version = "2.3.0" # last tested working version
api_key = var.datadog_api_key
app_key = var.datadog_app_key
}
Both of the datadog_api_key and datadog_app_key are unique to the each datadog account. You can define them in terraform.tfvars file:
datadog_api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
datadog_app_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Variables
Some variables need to be declared.
variable "environment" {
type = string
default = "dev"
}
variable "datadog_api_key" {
type = string
}
variable "datadog_app_key" {
type = string
}
Modules declaration example
A quick example of alerting message module declaration:
locals {
oncall_24x7 = "@pagerduty-MyPagerService_NBH"
oncall_office_hours = "@pagerduty-MyPagerService_BH"
}
module "datadog-message-alerting" {
source = "claranet/monitors/datadog//common/alerting-message"
version = "{revision}"
message_alert = local.oncall_24x7
message_warning = local.oncall_office_hours
message_nodata = local.oncall_24x7
}
module "datadog-message-alerting-bh-only" {
source = "claranet/monitors/datadog//common/alerting-message"
version = "{revision}"
message_alert = local.oncall_office_hours
message_warning = local.oncall_office_hours
message_nodata = local.oncall_office_hours
}
module "datadog-monitors-system-generic" {
source = "claranet/monitors/datadog//system/generic"
version = "{revision}"
environment = var.environment
message = module.datadog-message-alerting.alerting-message
memory_message = module.datadog-message-alerting-bh-only.alerting-message
# Use variables to customize monitors configuration
}
# Other monitors modules to declare ...
#module "datadog-monitors-my-monitors-set" {
# source = "claranet/monitors/datadog//my/monitors/set"
# version = "{revision}"
#
# environment = var.environment
# message = module.datadog-message-alerting.alerting-message
#}
- Replace
{revision}to the last git tag available on this repository. - The
//is very important, it's a terraform specific syntax used to separate git url and folder path. my/monitors/setrepresents the path to a monitors set sub directory listed below.