MON-456 remove as_count() for a gauge and change time aggregator for more tolerant Closes MON-456 See merge request claranet/pt-monitoring/projects/datadog/terraform/monitors!75
DataDog Monitors 
This repository is used to store all our monitors templates ready to use for generic purpose.
How to contribute ?
First, you may refresh your knowledge and look at the terminology.
To contribute you will need to report an issue and create a branch with its Jira ID.
If you would like to resolve an issue or implement new monitors you must follow our best practices.
After any change you should run ./scripts/auto_update.sh ./ command to make sure all is up to date else the CI pipeline will fail on the branch.
Important notes
- This repository represents a terraform feature and each first level directory could be imported as a terraform module, 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 customer 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. - The
alerting-messagemodule could be used to easily generate a templating message to use by default but it could be used also multiple times to generate messages for specific monitors.
Getting started
Terraform
Version >= 0.12 is required to use these modules of monitors.
terraform {
required_version = "~> 0.12"
}
DataDog provider
Here is the last tester terraform provider version for datadog but next versions should work too.
provider "datadog" {
version = "2.0.2" # 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 = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//common/alerting-message?ref={RELEASE}"
message_alert = local.oncall_24x7
message_warning = local.oncall_office_hours
message_nodata = local.oncall_24x7
}
module "datadog-message-alerting-bh-only" {
source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//common/alerting-message?ref={RELEASE}"
message_alert = local.oncall_office_hours
message_warning = local.oncall_office_hours
message_nodata = local.oncall_office_hours
}
module "datadog-monitors-system-generic" {
source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//system/generic?ref={RELEASE}"
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 = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//my/monitors/set?ref={RELEASE}"
#
# 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/set represents the path to a monitors set sub directory listed below.