Merged in MON-259_improve_scripts (pull request #110)

MON-259: Improve auto_update scripts

Approved-by: Jérôme Respaut <shr3ps@gmail.com>
Approved-by: Alexandre Gaillet <alexandre.gaillet@fr.clara.net>
Approved-by: Quentin Manfroi <quentin.manfroi@yahoo.fr>
This commit is contained in:
Jérôme Respaut 2018-07-23 13:38:40 +00:00 committed by Quentin Manfroi
commit e450587fbb
25 changed files with 61 additions and 50 deletions

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-aws-alb" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/alb?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/alb?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- ALB no healthy instances - ALB no healthy instances
- ALB latency - ALB latency

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-aws-apigateway" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/apigateway?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/apigateway?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- API Gateway latency - API Gateway latency
- API Gateway HTTP 5xx errors - API Gateway HTTP 5xx errors

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-aws-elasticsearch" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/elasticsearch?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/elasticsearch?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- ElasticSearch cluster status is not green - ElasticSearch cluster status is not green
- ElasticSearch cluster free storage space - ElasticSearch cluster free storage space

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-aws-elb" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/elb?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/elb?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- ELB no healthy instances - ELB no healthy instances
- ELB 4xx errors too high - ELB 4xx errors too high

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-aws-kinesis-firehose" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/kinesis-firehose?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/kinesis-firehose?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- Kinesis Firehose No incoming records - Kinesis Firehose No incoming records

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-aws-rds" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/rds?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/rds?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- RDS instance CPU high - RDS instance CPU high
- RDS instance free space - RDS instance free space

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-aws-vpn" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/vpn?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/vpn?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- VPN Down - VPN Down

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-azure-apimanagement" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/apimanagement?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/apimanagement?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- API Management is down - API Management is down
- API Management too many failed requests - API Management too many failed requests

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-azure-app-services" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/app-services?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/app-services?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- App Services response time too high - App Services response time too high
- App Services memory usage - App Services memory usage

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-azure-eventhub" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/eventhub?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/eventhub?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- Event Hub is down - Event Hub is down
- Event Hub too many failed requests - Event Hub too many failed requests

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-azure-iothubs" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/iothubs?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/iothubs?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- IOT Hub Too many jobs failed - IOT Hub Too many jobs failed
- IOT Hub Too many list_jobs failure - IOT Hub Too many list_jobs failure

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-azure-redis" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/redis?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/redis?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- Redis {{name}} is down - Redis {{name}} is down
- Redis too many evictedkeys - Redis too many evictedkeys

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-azure-servicebus" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/servicebus?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/servicebus?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- Service Bus is down - Service Bus is down

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-azure-sql-database" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/sql-database?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/sql-database?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- SQL Database CPU too high - SQL Database CPU too high
- SQL Database low free space - SQL Database low free space

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-azure-storage" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/storage?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/storage?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- Azure Storage is down - Azure Storage is down
- Azure Storage too few successful requests - Azure Storage too few successful requests

View File

@ -7,14 +7,14 @@ module "datadog-monitors-cloud-azure-stream-analytics" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/stream-analytics?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/stream-analytics?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- Stream Analytics is down - Stream Analytics is down
- Stream Analytics streaming units utilization too high - Stream Analytics streaming units utilization too high

View File

@ -7,14 +7,14 @@ module "datadog-monitors-databases-mongodb" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//databases/mongodb?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//databases/mongodb?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- Member down in the replica set - Member down in the replica set

View File

@ -7,14 +7,14 @@ module "datadog-monitors-middleware-apache" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//middleware/apache?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//middleware/apache?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- Can't connect to apache vhost status - Can't connect to apache vhost status

View File

@ -7,14 +7,14 @@ module "datadog-monitors-middleware-nginx" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//middleware/nginx?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//middleware/nginx?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- Can't connect to nginx vhost status - Can't connect to nginx vhost status

View File

@ -7,14 +7,14 @@ module "datadog-monitors-middleware-php-fpm" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//middleware/php-fpm?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//middleware/php-fpm?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- php_fpm busy worker - php_fpm busy worker
- Can't connect to php-fpm - Can't connect to php-fpm

View File

@ -4,12 +4,12 @@ set -xueo pipefail
source "$(dirname $0)/utils.sh" source "$(dirname $0)/utils.sh"
goto_root goto_root
for path in $(find . -path ./incubator -prune -o -name 'monitors-*.tf' -print); do for path in $(find "$(get_scope $1)" -path ./incubator -prune -o -name 'monitors-*.tf' -print); do
cd $(dirname $path) cd $(dirname $path)
> outputs.tf > outputs.tf
for monitor in $(grep 'resource "datadog_monitor"' $(basename $path) | awk '{print $3}' | tr -d '"' ); do for monitor in $(grep 'resource "datadog_monitor"' $(basename $path) | awk '{print $3}' | tr -d '"' ); do
echo $monitor echo $monitor
cat <<EOF >> outputs.tf cat >> outputs.tf <<EOF
output "${monitor}_id" { output "${monitor}_id" {
description = "id for monitor $monitor" description = "id for monitor $monitor"
value = "\${datadog_monitor.${monitor}.id}" value = "\${datadog_monitor.${monitor}.id}"
@ -19,4 +19,4 @@ EOF
done done
cd - >> /dev/null cd - >> /dev/null
done done
terraform fmt terraform fmt "$(get_scope $1)"

View File

@ -20,7 +20,7 @@ done
PATTERN_DOC="Related documentation" PATTERN_DOC="Related documentation"
for path in $(find . -path ./incubator -prune -o -name 'monitors-*.tf' -print); do for path in $(find "$(get_scope $1)" -path ./incubator -prune -o -name 'monitors-*.tf' -print); do
cd $(dirname $path) cd $(dirname $path)
EXIST=0 EXIST=0
if [ -f README.md ]; then if [ -f README.md ]; then
@ -41,14 +41,14 @@ module "datadog-monitors-${module_dash}" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//${module_slash}?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//${module_slash}?ref={revision}"
environment = "\${var.environment}" environment = "\${var.environment}"
message = "\${module.datadog-message-alerting.alerting-message}" message = "\${module.datadog-message-alerting.alerting-message}"
} }
\`\`\` \`\`\`
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
EOF EOF
SAVEIFS=$IFS SAVEIFS=$IFS

View File

@ -1,7 +1,10 @@
#!/bin/bash #!/bin/bash
set -xueo pipefail set -xueo pipefail
source "$(dirname $0)/utils.sh"
cd $(dirname $0) cd $(dirname $0)
for script in [0-9][0-9]_*.sh; do for script in [0-9][0-9]_*.sh; do
./${script} ./${script} "$(get_scope $1)"
done done

View File

@ -9,13 +9,21 @@ function goto_root {
fi fi
} }
function get_scope {
TO_PARSE="."
if [ ! -z ${1+x} ]; then
TO_PARSE="$1"
fi
echo $TO_PARSE
}
function list_dirs { function list_dirs {
echo ${1} | awk -F '/' '{$1=""; print $0}' | cut -c 2- echo ${1} | awk -F '/' '{$1=""; print $0}' | cut -c 2-
} }
function get_name { function get_name {
regex='^[[:space:]]+name[[:space:]]+=[[:space:]]+"\[.*\][[:space:]]+(.*)"$' regex='^[[:space:]]+name[[:space:]]+=[[:space:]]+"\[.*\][[:space:]]+(.*)"$'
if [[ "${1}" =~ ${regex} ]]; then if [[ "${1}" =~ ${regex} ]]; then
name="${BASH_REMATCH[1]}" name="${BASH_REMATCH[1]}"
else else
echo "Error: impossible to parse monitor name" echo "Error: impossible to parse monitor name"

View File

@ -7,14 +7,14 @@ module "datadog-monitors-system-generic" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//system/generic?ref={revision}" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//system/generic?ref={revision}"
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
} }
``` ```
## Purpose ## Purpose
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
- CPU usage - CPU usage
- CPU load 5 - CPU load 5