Automate App Monitoring with Ansible Platform & Dynatrace

May 13, 2020 by Tony Pope-Cruz

The Dynatrace software intelligence platform automates the monitoring lifecycle.  The OneAgent automatically discovers and instruments your applications, processes, containers, and log files.  Smartscape topology provides real-time dependency mapping without any configuration.  The Davis AI continuously analyzes metrics, traces, logs, dependencies, and more to automatically detect problems and determine the root cause.  This automation helps enable organizations to monitor their IT portfolio more quickly and easily - without the headaches that can occur from manual configuration required by traditional monitoring tools.

Dynatrace is designed to work for any environment, but it’s generic.  How can we automate the personalization of Dynatrace and enable monitoring as a self-service (MaaSS) Red Hat Ansible Automation Platform.  With the power of automation provided by Red Hat Ansible Automation Platform and the Dynatrace API, we can automate the onboarding of applications into Dynatrace in a way that’s tailored for application stakeholders.

Dynatrace automation begins when the OneAgent is deployed on your hosts.  The rollout of the OneAgent can be automated on hosts that are managed by Red Hat Ansible Automation Platform.  A playbook will download and execute the OneAgent installer on your Linux hosts (via SSH) and your Windows hosts (via WinRM).  While not required, installing the OneAgent with a Host Group parameter is best practice as it provides an easy way to group, filter, and manage your monitoring data.

Dynatrace blog 1

Deploying the OneAgent provides monitoring of host, process, services (code), and application.


Once installed, the OneAgent will now automatically discover your applications, processes, and containers. By default, your web applications are monitored and segmented by the domain. We can define applications more accurately by configuring detection rules that match URL patterns.  Yikes, that sounds like manual configuration through the UI is required – right?  Actually, thanks to the Dynatrace API, we can automate this step as well.  We’ll use a playbook that calls the Dynatrace API to create an application and detection rule based on our URL pattern.

dynatrace blog 2

OneAgent automatically monitors the user sessions based on the URL pattern passed as an extra variable in our Ansible playbook.


The application we’re onboarding could be one of hundreds in the Dynatrace environment.  How do we make it easy for users (application stakeholders) to analyze only the relevant details and secure access to the monitoring data?  Management zones in Dynatrace are an information-partitioning mechanism that simultaneously promotes collaboration and the sharing of relevant team-specific data while still helping ensure secure access controls.  Using a playbook that calls the Dynatrace API, we’ll set up a management zone that just includes the monitored entities belonging to this application.

dynatrace blog 3

Dynatrace filters displayed information with a Management Zone based on the rules defined in the Ansible playbook.


Once the Davis AI determines statistically normal behavior for this application, Dynatrace will set out to automatically detect anomalies and report them as problems.  Problems are displayed in the UI, but our application stakeholders will want to be notified when there’s an issue.  Our playbook will call the Dynatrace API to set up an alerting profile and notification rule that filter problems related to the application and send a notification via email, Slack, Microsoft Teams, or integration with a 3rd party IT Service Management solution.

dynatrace blog 4

Dynatrace filters Problem notifications (alerts) based on the Management Zone created by the Ansible playbook.


When it comes to monitoring, everybody wants a dashboard.  Having eyes-on-glass and manually analyzing data points to spot issues is a thing of the past – that’s what artificial intelligence is for!  Still, it’s nice to have a single pane of glass where we can see the health of every application component.  Dynatrace allows us to create (or import) a dashboard that’s functional for any application.  We can use a management zone filter to restrict the data that’s displayed to only include our application we are onboarding.  Using the Dynatrace API, we’ll set up our playbook that clones an existing dashboard (think template) and sets the appropriate management zone filter.

Dynatrace blog 5

Ansible creates a new dashboard in Dynatrace by cloning an existing one and modifying the JSON configuration.


Possibly my favorite part of using Red Hat Ansible Automation Platform is creating workflow templates.  With such an easy to use interface, we can define a workflow that combines  independent playbooks (job templates) into a sequential workflow.  We’ll define a few extra variables and then the entire process of onboarding our application into Dynatrace is automated faster then before!

dynatrace blog 6

Workflow combines our modular playbooks into a seamless and automated process for onboarding applications into the Dynatrace monitoring platform.


In conclusion, Dynatrace helps handle the automation of the pieces that make monitoring a challenge in today’s complex IT environments.  Red Hat Ansible Automation Platform enables the automation of the tasks that are unique to every application and environment.

  • Deploying agents to the inventory of application hosts (Linux and Windows)
  • Defining applications for real user monitoring with session replay
  • Configuring the mechanism to filter access, data, and alerts
  • Setting up alert notifications through email, “ChatOps”, and 3rd party ITSM
  • Building dashboards for monitoring data consumption

I maintain a public repo of playbooks for this use case which can be found on GitHub.

These serve as examples and I recommend reaching out to your Red Hat team or our Dynatrace Services organization for assistance in making sure you have a production ready solution.



Tony Pope-Cruz

Tony Pope-Cruz is a Solutions Engineer at Dynatrace and assists organizations with technical solutions to their business challenges. As an advocate of automation, he’s always looking to make life easier by integrating Ansible and Dynatrace.

rss-icon  RSS Feed