diff --git a/CN_PREPROD/custom_service/.gitkeep b/CN_PREPROD/custom_service/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/CN_PREPROD/processgroup_naming/.gitkeep b/CN_PREPROD/processgroup_naming/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/CN_PREPROD/service_naming/.gitkeep b/CN_PREPROD/service_naming/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/CN_PROD/custom_service/.gitkeep b/CN_PROD/custom_service/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/CN_PROD/processgroup_naming/.gitkeep b/CN_PROD/processgroup_naming/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/CN_PROD/service_naming/.gitkeep b/CN_PROD/service_naming/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/EMEA_PREPROD/custom_service/.gitkeep b/EMEA_PREPROD/custom_service/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/EMEA_PREPROD/processgroup_naming/.gitkeep b/EMEA_PREPROD/processgroup_naming/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/EMEA_PREPROD/service_naming/.gitkeep b/EMEA_PREPROD/service_naming/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/EMEA_PROD/custom_service/.gitkeep b/EMEA_PROD/custom_service/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/EMEA_PROD/processgroup_naming/.gitkeep b/EMEA_PROD/processgroup_naming/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/EMEA_PROD/service_naming/.gitkeep b/EMEA_PROD/service_naming/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/NA_PREPROD/custom_service/.gitkeep b/NA_PREPROD/custom_service/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/NA_PREPROD/processgroup_naming/.gitkeep b/NA_PREPROD/processgroup_naming/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/NA_PREPROD/service_naming/.gitkeep b/NA_PREPROD/service_naming/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/NA_PROD/custom_service/.gitkeep b/NA_PROD/custom_service/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/NA_PROD/processgroup_naming/.gitkeep b/NA_PROD/processgroup_naming/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/NA_PROD/service_naming/.gitkeep b/NA_PROD/service_naming/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/_templates/_template_custom_service.tf b/_templates/_template_custom_service.tf new file mode 100644 index 00000000..173cb5e6 --- /dev/null +++ b/_templates/_template_custom_service.tf @@ -0,0 +1,25 @@ +resource "dynatrace_custom_service" "" { + name = "" + enabled = true + # queue_entry_point = false + #TO BE FILLED - technology - possible options: java,dotNet + technology = "" + rule { + enabled = true + class { + #TO BE FILLED - classname (FQN) + name = "" + match = "EQUALS" + } + method { + #TO BE FILLED - methodname (FQN) + name = "[methodname]" + #TO BE FILLED - argument type list (FQN) + arguments = [] + #TO BE FILLED - return type (FQN or void) + returns = "" + #TO BE FILLED - visibility (private,public) + visibility = "" + } + } +} diff --git a/_templates/_template_processgroup_naming.tf b/_templates/_template_processgroup_naming.tf new file mode 100644 index 00000000..48a2eea3 --- /dev/null +++ b/_templates/_template_processgroup_naming.tf @@ -0,0 +1,23 @@ +resource "dynatrace_processgroup_naming" "" { + name = "" + enabled = true + format = "{ProcessGroup:DetectedName} - {HostGroup:Name/[^\\_]*$}" + conditions { + condition { + key { + type = "STATIC" + attribute = "PROCESS_GROUP_TAGS" + } + tag { + # negate = false + operator = "EQUALS" + value { + context = "CONTEXTLESS" + key = "Component" + #TO BE FILLED - Component tag value + value = "" + } + } + } + } +} \ No newline at end of file diff --git a/_templates/_template_service_naming.tf b/_templates/_template_service_naming.tf new file mode 100644 index 00000000..c6a99501 --- /dev/null +++ b/_templates/_template_service_naming.tf @@ -0,0 +1,23 @@ +resource "dynatrace_service_naming" "" { + name = "" + enabled = true + format = "{Service:DetectedName} - {HostGroup:Name/[^\\_]*$}" + conditions { + condition { + key { + type = "STATIC" + attribute = "SERVICE_TAGS" + } + tag { + # negate = false + operator = "EQUALS" + value { + context = "CONTEXTLESS" + key = "Component" + #TO BE FILLED - Component tag value + value = "" + } + } + } + } +} diff --git a/onboarding.py b/onboarding.py index 9aeed045..e6d019c1 100644 --- a/onboarding.py +++ b/onboarding.py @@ -2,16 +2,20 @@ import yaml from decouple import config import argparse import os -parser = argparse.ArgumentParser(description="Generate predefined Dynatrace configuration via Terraform", +parser = argparse.ArgumentParser(description="Generate predefined Dynatrace configuration via Terraform. Default features are Management zone, Alerting profile and predefined dashboard. For more see options below", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-A", "--appname", type=str,required=True, help="Your app_name") parser.add_argument('-C', "--compassid", type=str,required=True, help="Your compass_id") +parser.add_argument('-F', "--features", type=str,required=True, help="Comma separated additional features. Possible options are: custom_service, processgroup_naming, service_naming") args = parser.parse_args() #Config options for onboarding. Will be extended with other configuration options in future configoptions = ["management_zone"] envconfigoptions = ["alerting","dashboard"] +if(args.features): + features = args.features.split(",") + configoptions = configoptions + features def main(slo_path): print("Generating tf files...") if args.appname and args.compassid: diff --git a/readme.md b/readme.md index b53d03a7..a23ed5fd 100644 --- a/readme.md +++ b/readme.md @@ -16,9 +16,14 @@ Before executing scripts, python requirements have to be satisfied. To do so, ex 3.Install python dependencies: pip install -r requirements.txt 4.Run onboarding script: - python ./onboarding.py -A CD_ -C + 4.1 Default implementation (Management zone, Alerting profile and predefined dashboard) + python ./onboarding.py -A CD_ -C + 4.2 Additional features (see Usage section): + python ./onboarding.py -A CD_ -C -F 5. Review created files: git status + + 5.1 Adjust additional feature files (if generated with "-F" option). See "Adjusting tf files" section 6. Commit your changes: git add @@ -33,18 +38,26 @@ For more information about adjusting tf files to your need please follow: 1. Management zones: https://registry.terraform.io/providers/dynatrace-oss/dynatrace/latest/docs/resources/management_zone 2. Alerting profiles: https://registry.terraform.io/providers/dynatrace-oss/dynatrace/latest/docs/resources/alerting 3. Dashboards: https://registry.terraform.io/providers/dynatrace-oss/dynatrace/latest/docs/resources/dashboard +4. Custom service: https://registry.terraform.io/providers/dynatrace-oss/dynatrace/latest/docs/resources/custom_service +5. Notification: https://registry.terraform.io/providers/dynatrace-oss/dynatrace/latest/docs/resources/notification +6. Process group naming: https://registry.terraform.io/providers/dynatrace-oss/dynatrace/latest/docs/resources/processgroup_naming +7. Service naming: https://registry.terraform.io/providers/dynatrace-oss/dynatrace/latest/docs/resources/service_naming # Usage - usage: onboarding.py [-h] -A APPNAME -C COMPASSID + usage: onboarding.py [-h] -A APPNAME -C COMPASSID -F FEATURES - Generate predefined Dynatrace configuration via Terraform + Generate predefined Dynatrace configuration via Terraform. Default features are Management zone, Alerting profile and predefined dashboard. For more see + options below options: - -h, --help show this help message and exit - -A APPNAME, --appname APPNAME - Your app_name (default: None) - -C COMPASSID, --compassid COMPASSID - Your compass_id (default: None) + -h, --help show this help message and exit + -A APPNAME, --appname APPNAME + Your app_name (default: None) + -C COMPASSID, --compassid COMPASSID + Your compass_id (default: None) + -F FEATURES, --features FEATURES + Comma separated additional features. Possible options are: custom_service, notification, processgroup_naming, service_naming (default: + None) # Files