Made a lot of modifications to standardize it for general usage
This commit is contained in:
commit
9e755e45ca
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
*.tfstate
|
||||
*.tfstate.backup
|
||||
.terraform
|
||||
provider.tf
|
||||
*.tfvars
|
||||
**/*.tfvars
|
||||
provider.tf
|
||||
.github
|
||||
.circleci
|
||||
23
.terraform.lock.hcl
generated
Normal file
23
.terraform.lock.hcl
generated
Normal file
@ -0,0 +1,23 @@
|
||||
# This file is maintained automatically by "terraform init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.terraform.io/datadog/datadog" {
|
||||
version = "3.2.0"
|
||||
constraints = "3.2.0"
|
||||
hashes = [
|
||||
"h1:nfbkvIrUHhsI0cx7IfYDdwdn+C7nBaDvqp3lsZ2BcQw=",
|
||||
"zh:0973526974954263941cc4bc4a4bbd5a56726c09ebd118a513b0106d2164863d",
|
||||
"zh:0e89a0254f65951da832f73822592c46758e168a1ea3f7fa7eb6c79fe1e13a5d",
|
||||
"zh:35145207a6b585e51775079eb6c114d7d555c4f8a928361915374cb28b2cbe46",
|
||||
"zh:3fdf4e1d184fbad0aed31e851cd8465d9be9e7481fcfcd1b5c0da7a1eb582048",
|
||||
"zh:42dfbf4ecd8779346fa4764ce9db99b993fe3c8aefb6eea32d293f9a0bc5cab0",
|
||||
"zh:4e172436bdcbfb2e41fa43a58bc89a1d1e47178e7011d99ff87885c65ef3966c",
|
||||
"zh:72d77a750399ec7ff51c38894d54e54c178f16aab726b36caf0094501124f918",
|
||||
"zh:72e112c8d008418f40677533e855a8b79061892fb42b8296ea69e8246d6205f9",
|
||||
"zh:753d154fb6fb32f064469d3a2e2c657b7d8d19c674189480dae2d2f3b93d524b",
|
||||
"zh:b8dfdcc4402856c043a08e4befe39b042203d616ffb370b54c64a7b3def6ca55",
|
||||
"zh:be523a10cb95220cb52375ac71e03d8f0f48b0d8f3534075aa22d37b5d335d86",
|
||||
"zh:eb9f11a30d9303b422eea27b5d11a716a290c81b8c09e5457292fb378386f66c",
|
||||
"zh:fce91b84c90ce97b7acc6e4ec2cb6f9f4518ae070e00d7ca8973edd585d0ea14",
|
||||
]
|
||||
}
|
||||
12
README.md
Normal file
12
README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Terraform Datadog Application Dashboard
|
||||
|
||||
This Terraform module configures a dashboard for your Kubernetes application.
|
||||
|
||||
How-to set it up to work with your application is described below
|
||||
|
||||
# Setup
|
||||
|
||||
First you need to copy the contents of the example directory to a directory
|
||||
|
||||
module "your_application_name"
|
||||
source = git://
|
||||
0
example/main.tf
Normal file
0
example/main.tf
Normal file
104
main.tf
Normal file
104
main.tf
Normal file
@ -0,0 +1,104 @@
|
||||
resource "datadog_dashboard" "beacon" {
|
||||
title = var.app_name
|
||||
description = "A Datadog Dashboard for the ${kubernetes_deployment.beacon.metadata[0].name} deployment"
|
||||
layout_type = "ordered"
|
||||
is_read_only = true
|
||||
|
||||
|
||||
widget {
|
||||
hostmap_definition {
|
||||
no_group_hosts = true
|
||||
no_metric_hosts = true
|
||||
node_type = "container"
|
||||
title = "Kubernetes Pods"
|
||||
|
||||
request {
|
||||
fill {
|
||||
q = "avg:process.stat.container.cpu.total_pct{image_name:${var.image_name}} by {host}"
|
||||
}
|
||||
}
|
||||
|
||||
style {
|
||||
palette = "hostmap_blues"
|
||||
palette_flip = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
widget {
|
||||
timeseries_definition {
|
||||
show_legend = false
|
||||
title = "CPU Utilization"
|
||||
|
||||
request {
|
||||
display_type = "line"
|
||||
q = "top(avg:docker.cpu.usage{image_name:${var.image_name}} by {docker_image,container_id}, 10, 'mean', 'desc')"
|
||||
|
||||
style {
|
||||
line_type = "solid"
|
||||
line_width = "normal"
|
||||
palette = "dog_classic"
|
||||
}
|
||||
}
|
||||
|
||||
yaxis {
|
||||
include_zero = true
|
||||
max = "auto"
|
||||
min = "auto"
|
||||
scale = "linear"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
widget {
|
||||
alert_graph_definition {
|
||||
alert_id = datadog_monitor.beacon.id
|
||||
title = "Kubernetes Node CPU"
|
||||
viz_type = "timeseries"
|
||||
}
|
||||
}
|
||||
|
||||
widget {
|
||||
hostmap_definition {
|
||||
no_group_hosts = true
|
||||
no_metric_hosts = true
|
||||
node_type = "host"
|
||||
title = "Kubernetes Nodes"
|
||||
|
||||
request {
|
||||
fill {
|
||||
q = "avg:system.cpu.user{*} by {host}"
|
||||
}
|
||||
}
|
||||
|
||||
style {
|
||||
palette = "hostmap_blues"
|
||||
palette_flip = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
widget {
|
||||
timeseries_definition {
|
||||
show_legend = false
|
||||
title = "Memory Utilization"
|
||||
request {
|
||||
display_type = "line"
|
||||
q = "top(avg:docker.mem.in_use{image_name:${var.image_name}} by {container_name}, 10, 'mean', 'desc')"
|
||||
|
||||
style {
|
||||
line_type = "solid"
|
||||
line_width = "normal"
|
||||
palette = "dog_classic"
|
||||
}
|
||||
}
|
||||
yaxis {
|
||||
include_zero = true
|
||||
max = "auto"
|
||||
min = "auto"
|
||||
scale = "linear"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
monitors.tf
Normal file
19
monitors.tf
Normal file
@ -0,0 +1,19 @@
|
||||
resource "datadog_monitor" "app_monitor" {
|
||||
name = "Kubernetes Pod Health"
|
||||
type = "metric alert"
|
||||
message = "Kubernetes Pods are not in an optimal health state. Notify: @operator"
|
||||
escalation_message = "Please investigate the Kubernetes Pods, @operator"
|
||||
|
||||
query = "max(last_1m):sum:docker.containers.running{short_image:${var.app_name} <= 1"
|
||||
|
||||
monitor_thresholds {
|
||||
ok = 3
|
||||
warning = 2
|
||||
critical = 1
|
||||
}
|
||||
|
||||
notify_no_data = true
|
||||
|
||||
tags = ["cfa:${var.cfa_name}", "team:${var.team_name}" "app:${var.app_name}", "env:${var.stage}"]
|
||||
}
|
||||
|
||||
0
outputs.tf
Normal file
0
outputs.tf
Normal file
8
provider.tf
Normal file
8
provider.tf
Normal file
@ -0,0 +1,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
datadog = {
|
||||
source = "datadog/datadog"
|
||||
version = "3.2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
28
synthetics.tf
Normal file
28
synthetics.tf
Normal file
@ -0,0 +1,28 @@
|
||||
resource "datadog_synthetics_test" "app_sythetics" {
|
||||
type = "api"
|
||||
subtype = "http"
|
||||
|
||||
request_definition {
|
||||
method = "GET"
|
||||
url = var.url
|
||||
}
|
||||
|
||||
assertion {
|
||||
type = "statusCode"
|
||||
operator = "is"
|
||||
target = "200"
|
||||
}
|
||||
|
||||
locations = ["aws:${var.region}"]
|
||||
options_list {
|
||||
tick_every = 900
|
||||
min_location_failed = 1
|
||||
}
|
||||
|
||||
name = "${var.app_name} API check"
|
||||
message = "Oh no! there seems to be a problem with ${var.app_name} please investigate"
|
||||
tags = ["cfa:${var.cfa_name}", "team:${var.team_name}" "app:${var.app_name}", "env:${var.stage}"]
|
||||
|
||||
status = "live"
|
||||
}
|
||||
|
||||
11
terraform.tfvars
Normal file
11
terraform.tfvars
Normal file
@ -0,0 +1,11 @@
|
||||
app_namespace = "plaap"
|
||||
app_name = "blah"
|
||||
image_name = "name/image"
|
||||
region = "eu-west-1"
|
||||
api_key = "2fcc093ed06e4dbe0935433495898cad"
|
||||
app_key = "aaf4a9654b82cfa8b23b2d65801901a4ad9d35ed"
|
||||
datadog_site = "https://api.datadoghq.eu/"
|
||||
aws_profile = "ws-playground-applicatiebeheer"
|
||||
environment = "test"
|
||||
prefix_slug = "sanoma"
|
||||
team = "ws-playground-applicatiebeheer"
|
||||
29
variables.tf
Normal file
29
variables.tf
Normal file
@ -0,0 +1,29 @@
|
||||
variable "app_namespace" {
|
||||
description = "Namespace that the application runs in"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "app_name" {
|
||||
description = "Name of the application"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "image_name" {
|
||||
description = "Name of the Docker imagei to use"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
description = "Defines the AWS region where the resources are located"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "environment" {
|
||||
description = "Specifies the URL for datadog to monitor"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "url" {
|
||||
description = "Specifies the URL for datadog to monitor"
|
||||
type = string
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user