diff --git a/cloud/aws/alb/README.md b/cloud/aws/alb/README.md index af6a727..8c7eca9 100644 --- a/cloud/aws/alb/README.md +++ b/cloud/aws/alb/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - ALB no healthy instances - ALB latency diff --git a/cloud/aws/apigateway/README.md b/cloud/aws/apigateway/README.md index 93507b0..a8b462d 100644 --- a/cloud/aws/apigateway/README.md +++ b/cloud/aws/apigateway/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - API Gateway latency - API Gateway HTTP 5xx errors diff --git a/cloud/aws/elasticsearch/README.md b/cloud/aws/elasticsearch/README.md index 8e0dfff..50e6370 100644 --- a/cloud/aws/elasticsearch/README.md +++ b/cloud/aws/elasticsearch/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - ElasticSearch cluster status is not green - ElasticSearch cluster free storage space diff --git a/cloud/aws/elb/README.md b/cloud/aws/elb/README.md index 10f156c..67957de 100644 --- a/cloud/aws/elb/README.md +++ b/cloud/aws/elb/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - ELB no healthy instances - ELB 4xx errors too high diff --git a/cloud/aws/kinesis-firehose/README.md b/cloud/aws/kinesis-firehose/README.md index 9b89992..c7ac54b 100644 --- a/cloud/aws/kinesis-firehose/README.md +++ b/cloud/aws/kinesis-firehose/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - Kinesis Firehose No incoming records diff --git a/cloud/aws/rds/README.md b/cloud/aws/rds/README.md index 4c26f91..f784bcd 100644 --- a/cloud/aws/rds/README.md +++ b/cloud/aws/rds/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - RDS instance CPU high - RDS instance free space diff --git a/cloud/aws/vpn/README.md b/cloud/aws/vpn/README.md index 8148ce1..d2b78a4 100644 --- a/cloud/aws/vpn/README.md +++ b/cloud/aws/vpn/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - VPN Down diff --git a/cloud/azure/apimanagement/README.md b/cloud/azure/apimanagement/README.md index 24c3589..f0b51a9 100644 --- a/cloud/azure/apimanagement/README.md +++ b/cloud/azure/apimanagement/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - API Management is down - API Management too many failed requests diff --git a/cloud/azure/app-services/README.md b/cloud/azure/app-services/README.md index eb89206..2e97976 100644 --- a/cloud/azure/app-services/README.md +++ b/cloud/azure/app-services/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - App Services response time too high - App Services memory usage diff --git a/cloud/azure/eventhub/README.md b/cloud/azure/eventhub/README.md index 9f95d31..247b298 100644 --- a/cloud/azure/eventhub/README.md +++ b/cloud/azure/eventhub/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - Event Hub is down - Event Hub too many failed requests diff --git a/cloud/azure/iothubs/README.md b/cloud/azure/iothubs/README.md index fff2739..c1edbae 100644 --- a/cloud/azure/iothubs/README.md +++ b/cloud/azure/iothubs/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## 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 list_jobs failure diff --git a/cloud/azure/redis/README.md b/cloud/azure/redis/README.md index 55cab45..491c6cc 100644 --- a/cloud/azure/redis/README.md +++ b/cloud/azure/redis/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - Redis {{name}} is down - Redis too many evictedkeys diff --git a/cloud/azure/servicebus/README.md b/cloud/azure/servicebus/README.md index 2bbeb5d..c3aa103 100644 --- a/cloud/azure/servicebus/README.md +++ b/cloud/azure/servicebus/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - Service Bus is down diff --git a/cloud/azure/sql-database/README.md b/cloud/azure/sql-database/README.md index 914e4d1..b64baf4 100644 --- a/cloud/azure/sql-database/README.md +++ b/cloud/azure/sql-database/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - SQL Database CPU too high - SQL Database low free space diff --git a/cloud/azure/storage/README.md b/cloud/azure/storage/README.md index 56d245c..46c0510 100644 --- a/cloud/azure/storage/README.md +++ b/cloud/azure/storage/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - Azure Storage is down - Azure Storage too few successful requests diff --git a/cloud/azure/stream-analytics/README.md b/cloud/azure/stream-analytics/README.md index e1a4ae0..90f1d9c 100644 --- a/cloud/azure/stream-analytics/README.md +++ b/cloud/azure/stream-analytics/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - Stream Analytics is down - Stream Analytics streaming units utilization too high diff --git a/databases/mongodb/README.md b/databases/mongodb/README.md index cc85575..193de0e 100644 --- a/databases/mongodb/README.md +++ b/databases/mongodb/README.md @@ -7,14 +7,14 @@ module "datadog-monitors-databases-mongodb" { source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//databases/mongodb?ref={revision}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - Member down in the replica set diff --git a/middleware/apache/README.md b/middleware/apache/README.md index 73b3691..b41fe1f 100644 --- a/middleware/apache/README.md +++ b/middleware/apache/README.md @@ -7,14 +7,14 @@ module "datadog-monitors-middleware-apache" { source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//middleware/apache?ref={revision}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - Can't connect to apache vhost status diff --git a/middleware/nginx/README.md b/middleware/nginx/README.md index 161bb2f..551ea03 100644 --- a/middleware/nginx/README.md +++ b/middleware/nginx/README.md @@ -7,14 +7,14 @@ module "datadog-monitors-middleware-nginx" { source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//middleware/nginx?ref={revision}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - Can't connect to nginx vhost status diff --git a/middleware/php-fpm/README.md b/middleware/php-fpm/README.md index 55a625d..09bdf1a 100644 --- a/middleware/php-fpm/README.md +++ b/middleware/php-fpm/README.md @@ -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}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - php_fpm busy worker - Can't connect to php-fpm diff --git a/scripts/01_update_output.sh b/scripts/01_update_output.sh index ccef054..4a6ad0c 100755 --- a/scripts/01_update_output.sh +++ b/scripts/01_update_output.sh @@ -4,12 +4,12 @@ set -xueo pipefail source "$(dirname $0)/utils.sh" 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) > outputs.tf for monitor in $(grep 'resource "datadog_monitor"' $(basename $path) | awk '{print $3}' | tr -d '"' ); do echo $monitor - cat <> outputs.tf + cat >> outputs.tf <> /dev/null done -terraform fmt +terraform fmt "$(get_scope $1)" diff --git a/scripts/02_update_readme.sh b/scripts/02_update_readme.sh index 4d7da1b..1c88a3b 100755 --- a/scripts/02_update_readme.sh +++ b/scripts/02_update_readme.sh @@ -20,7 +20,7 @@ done 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) EXIST=0 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}" environment = "\${var.environment}" - message = "\${module.datadog-message-alerting.alerting-message}" + message = "\${module.datadog-message-alerting.alerting-message}" } \`\`\` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: EOF SAVEIFS=$IFS diff --git a/scripts/auto_update.sh b/scripts/auto_update.sh index cb911e1..b584166 100755 --- a/scripts/auto_update.sh +++ b/scripts/auto_update.sh @@ -1,7 +1,10 @@ #!/bin/bash set -xueo pipefail +source "$(dirname $0)/utils.sh" + cd $(dirname $0) + for script in [0-9][0-9]_*.sh; do - ./${script} + ./${script} "$(get_scope $1)" done diff --git a/scripts/utils.sh b/scripts/utils.sh index 503ea86..b4b23ca 100755 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -9,13 +9,21 @@ function goto_root { fi } +function get_scope { + TO_PARSE="." + if [ ! -z ${1+x} ]; then + TO_PARSE="$1" + fi + echo $TO_PARSE +} + function list_dirs { echo ${1} | awk -F '/' '{$1=""; print $0}' | cut -c 2- } function get_name { regex='^[[:space:]]+name[[:space:]]+=[[:space:]]+"\[.*\][[:space:]]+(.*)"$' - if [[ "${1}" =~ ${regex} ]]; then + if [[ "${1}" =~ ${regex} ]]; then name="${BASH_REMATCH[1]}" else echo "Error: impossible to parse monitor name" diff --git a/system/generic/README.md b/system/generic/README.md index 5366eab..1174ef4 100644 --- a/system/generic/README.md +++ b/system/generic/README.md @@ -7,14 +7,14 @@ module "datadog-monitors-system-generic" { source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//system/generic?ref={revision}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` ## Purpose -Creates DataDog monitors with the following checks : +Creates DataDog monitors with the following checks: - CPU usage - CPU load 5