Extending onboarding features

CD_ASBC-B2VAUTH
Patryk Gudalewicz 2023-01-09 11:50:07 +01:00
parent 0cfe6ea59d
commit 12c44f185c
29 changed files with 97 additions and 9 deletions

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@ -0,0 +1,25 @@
resource "dynatrace_custom_service" "<APPNAME>" {
name = "<APPNAME>"
enabled = true
# queue_entry_point = false
#TO BE FILLED - technology - possible options: java,dotNet
technology = "<technology>"
rule {
enabled = true
class {
#TO BE FILLED - classname (FQN)
name = "<classname>"
match = "EQUALS"
}
method {
#TO BE FILLED - methodname (FQN)
name = "[methodname]"
#TO BE FILLED - argument type list (FQN)
arguments = [<argumentlist>]
#TO BE FILLED - return type (FQN or void)
returns = "<returntype>"
#TO BE FILLED - visibility (private,public)
visibility = "<visibility>"
}
}
}

View File

@ -0,0 +1,23 @@
resource "dynatrace_processgroup_naming" "<APPNAME>" {
name = "<APPNAME>"
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 = "<componentValue>"
}
}
}
}
}

View File

@ -0,0 +1,23 @@
resource "dynatrace_service_naming" "<APPNAME>" {
name = "<APPNAME>"
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 = "<componentValue>"
}
}
}
}
}

View File

@ -2,16 +2,20 @@ import yaml
from decouple import config from decouple import config
import argparse import argparse
import os 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) formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("-A", "--appname", type=str,required=True, help="Your app_name") 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('-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() args = parser.parse_args()
#Config options for onboarding. Will be extended with other configuration options in future #Config options for onboarding. Will be extended with other configuration options in future
configoptions = ["management_zone"] configoptions = ["management_zone"]
envconfigoptions = ["alerting","dashboard"] envconfigoptions = ["alerting","dashboard"]
if(args.features):
features = args.features.split(",")
configoptions = configoptions + features
def main(slo_path): def main(slo_path):
print("Generating tf files...") print("Generating tf files...")
if args.appname and args.compassid: if args.appname and args.compassid:

View File

@ -16,9 +16,14 @@ Before executing scripts, python requirements have to be satisfied. To do so, ex
3.Install python dependencies: 3.Install python dependencies:
pip install -r requirements.txt pip install -r requirements.txt
4.Run onboarding script: 4.Run onboarding script:
4.1 Default implementation (Management zone, Alerting profile and predefined dashboard)
python ./onboarding.py -A CD_<app_name> -C <compass_id> python ./onboarding.py -A CD_<app_name> -C <compass_id>
4.2 Additional features (see Usage section):
python ./onboarding.py -A CD_<app_name> -C <compass_id> -F <features>
5. Review created files: 5. Review created files:
git status git status
5.1 Adjust additional feature files (if generated with "-F" option). See "Adjusting tf files" section
6. Commit your changes: 6. Commit your changes:
git add <changes> git add <changes>
@ -33,11 +38,16 @@ 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 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 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 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
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: options:
-h, --help show this help message and exit -h, --help show this help message and exit
@ -45,6 +55,9 @@ For more information about adjusting tf files to your need please follow:
Your app_name (default: None) Your app_name (default: None)
-C COMPASSID, --compassid COMPASSID -C COMPASSID, --compassid COMPASSID
Your compass_id (default: None) 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 # Files