NashTech Blog

Effortless Log Integration with Dynatrace

Table of Contents
photo of man holding a book

“Unlocking Dynatrace: A Step-by-Step Guide to Extracting Scala App Logs, Setting Up Error Alerts, and Enabling Email Notifications”

Hello Readers! In this blog, I’ll guide you through the process of extracting logs from your Scala App, setting up an Alerting Profile for Errors, and enabling Email Notifications. To begin, let’s first understand what Dynatrace is and then proceed with its setup.

What is Dynatrace?

Dynatrace stands as a robust software intelligence platform, purpose-built for comprehensive monitoring, automation, and intelligence across contemporary cloud-based and hybrid application environments. It delivers real-time insights into the performance of applications, infrastructure, and user experiences. Dynatrace serves as a crucial tool for monitoring and effectively managing the performance and availability of applications, enabling organizations to swiftly identify and address issues. This versatile platform accommodates a broad spectrum of technologies, offering key features like root cause analysis, anomaly detection, and automation to enhance and optimize application performance. In the realm of application performance management and observability, Dynatrace is a widely adopted solution.
Embark on your journey with Dynatrace by taking advantage of a free 15-day trial – a seamless process that requires no Credit/Debit card information. Immerse yourself in hassle-free exploration and discover the power of Dynatrace’s insights.

Deploying One Agent.

The One Agent, an intelligent monitoring agent, is strategically installed on servers, containers, and virtual machines. Its primary function is to provide in-depth insights into application performance, availability, health, and conduct root cause analysis—an indispensable key to understanding and optimizing your system’s performance.
To initiate the deployment of the OneAgent, effortlessly navigate to the Apps section of Dynatrace and initiate a search for “Deploy OneAgent.” This simple step sets the stage for a seamless deployment process. Once you’ve made your selection, you’ll seamlessly transition to a platform selection page. In my case, I’m choosing Linux, tailoring the deployment process to my specific platform.

Selecting Linux seamlessly leads to the next step—a page where you generate a PaaS Token. Simply click on “Create Token” to proceed. This token is a key element for the deployment process.

Copy and paste the provided commands into the terminal one by one. Afterward, click on the “Show Deployment Status” button.
Note: If you encounter a permission denied error during the last command, simply add “sudo” at the beginning to grant root user access.

Congratulations! Your OneAgent has been successfully deployed on your localhost. You’re now set to benefit from enhanced monitoring and insights.

Create a basic Akka-based Scala application.

Let’s make a simple Scala app that uses SLF4J logs sent to Dynatrace.

This code produces info and error logs. The info log appears once, while the error log repeats 100 times, each with a 10-second interval.
Note: To run this application using Docker, set up the Dockerfile and execute it within the container. You can find the necessary details in this GitHub Repository:
https://github.com/tushar-dhiman/DynatraceBlogExample.git

Configure a log source on Dynatrace.

To enable Dynatrace to fetch logs from your host, follow these steps:
-Navigate to “Settings.”
-Under “Log Monitoring,” choose “Log ingest rules.”
-Here enable your system logs, in my case “Linux system logs”
-Click “Save changes” to finalize the setup.

While your application is running inside a Docker container, you can ensure that your application logs are reaching Dynatrace by checking the “Logs and Events” section. This step confirms that the logs are successfully transmitted and accessible within Dynatrace.

Configure an alerting profile and set up problem notifications.

Now that our logs are reaching Dynatrace, a crucial question arises: How do we stay informed about any issues in our application? We need a system that notifies us when errors occur.
To address this concern, we’ll create a custom filter and configure an alerting profile to send email notifications when an error log is detected in our application. Let’s dive into the steps for setting up the alerting profile and ensuring problem notifications reach our email inbox.

Configure metric extraction for our application.

To set up metric extraction for error logs, follow these steps:

– Navigate to “Metrics extraction” under “Log Monitoring.”
– Create a metric key name of your preference.
– In the matcher, specify the column name and the corresponding value to match with the logs from your application.
Save the changes.

For instance, in the image below, “Error Message Log” is set as the value for the “content” column.
This ensures accurate metric extraction for your error logs.

Configure a metric event for our application.

To establish a metric event for automatic anomaly detection, follow these steps:

  1. Begin by providing a summary for the event; it can be any name or a descriptive sentence.
  2. In the “Type” section, under Query Definition, select “Metric Selector” and input the name of the metric key created in the metric extraction step.
  3. Set the threshold limit based on your requirements. This threshold will identify anomalies for the specified duration.
  4. Assign an event title and select the event type as a custom alert.
  5. Save the changes.

By completing these steps, you’ve configured a metric event to automatically detect anomalies in your application.

Creating the Alerting Profile

To create the Alerting Profile, follow these steps:

  1. Navigate to the “Alerting” section and find “Problem alerting profiles.”
  2. Click on the “Add alerting profile” button to create a custom profile.
  3. Expand the Custom alert and set the Problem send delay in minutes which will send the notification if problem remains open for that time.

This sets the stage for configuring a personalized alerting profile tailored to your specific requirements.

To enhance the alerting profile, follow these steps:

  1. Add an Event filter by choosing “Custom” from the drop-down menu.
  2. Include a Description filter and specify the value of the log message to filter. In this case, the value is “Error Message Log.”

This fine-tunes the alerting profile to focus on the specific log messages you want to capture.

Creating Problem Notification.

For the last step:

  1. Navigate to “Problem notification” under the Integration section.
  2. Choose the notification type, e.g., Email, if you wish to receive problem notifications via email. Alternatively, select from the available notification types.
  3. Specify the name of the Alerting Profile created in the previous step.
  4. Save the changes.

Completing these actions ensures that problem notifications will be delivered according to your specified preferences, completing the setup for effective alerting.

Congratulations! With everything configured successfully, you’ll now receive email notifications in your inbox whenever Dynatrace detects a problem while your Docker image is running. This comprehensive setup ensures you stay informed and can promptly address any issues detected by Dynatrace.

Conclusion

Thank you for following along till the end of the blog! We’ve covered the process of sending application logs to Dynatrace, extracting metrics from the logs, and establishing an alerting profile to receive problem notifications via email. If you have any further questions or need additional assistance, feel free to reach out. Happy monitoring!

Picture of Tushar Dhiman

Tushar Dhiman

Leave a Comment

Your email address will not be published. Required fields are marked *

Suggested Article

Scroll to Top