Skip to content

terraform-module/terraform-datadog-monitors

 
 

Repository files navigation

DataDog Monitors pipeline status

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 will need to run the auto update scripts to make sure all is up to date otherwise the CI pipeline will fail.

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.md on each module, explaining how to use it.
  • The alerting-message module 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

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 = "git::ssh://[email protected]/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://[email protected]/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://[email protected]/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://[email protected]/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.

Monitors summary

About

Manage Datadog monitors with terraform dedicated modules

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 100.0%