This tutorial explains how configure an event notification with the latest Dynatrace. The notification consists of
Terraform CLI with the Dynatrace provider installed and available under PATH. For more information, see Install Terraform.
OAuth client or platform token with the following permissions. For more information, see Create API access token.
settings:objects:read
)settings:objects:write
)automation:workflows:read
)automation:workflows:write
)The Terraform user needs to have all required permissions to run the run automated configurations such as davis anomaly detectors or workflows. Missing or wrong permission can lead to an unexpected behavior.
You'll learn how to configure an anomaly detector and a workflow with an email action.
To build a configuration for raising an event and a simple workflow for sending an email in case of a raised event
main.tf
file with the content for selected resources.This file contains the Terraform configuration—a set of resource blocks that define the configuration.
If you want to try other resources, consider using the export utility to export existing configurations from your selected environment.
Open a terminal and set the environment variables for your environment URL and authentication credentials. The environment variable identifies which tenant you'll be pushing configurations to. For more information, see Terraform API support and access permission handling.
In your working directory, run the terraform plan
to generate an execution plan that provides a preview of the changes Terraform intends to make.
After verifying the plan, execute terraform apply
to implement the proposed changes.
dynatrace_automation_workflow.Authentication_Service_Email_Notification: Creating...dynatrace_davis_anomaly_detectors.Authentication_Service_High_Response_Time: Creating...dynatrace_davis_anomaly_detectors.Authentication_Service_High_Response_Time: Creation complete after 2s [id=************]dynatrace_automation_workflow.Authentication_Service_Email_Notification: Creation complete after 5s [id=************]Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
A Terraform terraform.tfstate
state file is automatically generated. It keeps track of the resources that Terraform manages.
It's crucial for subsequent Terraform operations.
To modify the Terraform configuration
Execute the terraform plan, which should indicate that no changes are needed.
dynatrace_automation_workflow.Authentication_Service_Email_Notification: Refreshing state... [id=************]dynatrace_davis_anomaly_detectors.Authentication_Service_High_Response_Time: Refreshing state... [id=************]No changes. Your infrastructure matches the configuration.Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
To make a change, edit the main.tf file
. For instance, you can modify the email notification recipient by modifying the to
attribute in the dynatrace_davis_anomaly_detectors
resource.
To remove a configuration, run terraform plan
to confirm no pending changes.
dynatrace_automation_workflow.Authentication_Service_Email_Notification: Refreshing state... [id=************]dynatrace_davis_anomaly_detectors.Authentication_Service_High_Response_Time: Refreshing state... [id=************]No changes. Your infrastructure matches the configuration.Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
To permanently delete the selected configuration, execute terraform destroy
.
dynatrace_davis_anomaly_detectors.Authentication_Service_High_Response_Time: Destroying... [id= ************]dynatrace_automation_workflow.Authentication_Service_Email_Notification: Destroying... [id= ************]dynatrace_davis_anomaly_detectors.Authentication_Service_High_Response_Time: Destruction complete after 0sdynatrace_automation_workflow.Authentication_Service_Email_Notification: Destruction complete after 1sDestroy complete! Resources: 2 destroyed.
The previously created configurations in the Dynatrace environment have been destroyed. Confirm that your Terraform state terraform.tfstate
file is empty.