In this tutorial, we'll cover how to enable Kubernetes log ingest with OneAgent via the Log module, create log ingest rules, mask sensitive data, and fine-tune the configuration to upload only relevant logs.
Kubernetes owner, practitioner, or Dynatrace admin setting up Kubernetes log monitoring with the OneAgent Log module.
As a Dynatrace admin, you want to track whether there are Kubernetes cluster node issues and set up log observability for running Workloads.
In this tutorial, you'll learn how to:
Before you begin, start monitoring your Kubernetes cluster.
Review supported Kubernetes distributions in Technology support.
The OneAgent Log module automatically discovers logs written to the stdout and stderr streams by containerized applications running in pods. Details and alternatives for logs written to the container filesystem are available under Stream Kubernetes logs with Dynatrace Log Module.
Deploy Dynatrace Operator based on the Kubernetes quickstart guide.
If you already monitor your Kubernetes cluster, you might need to modify the DynaKube custom resource YAML file. Check the configuration and, if necessary, update or add the logMonitoring: {} section. See Kubernetes log monitoring for details.
Start by reviewing the built-in log ingest rules to understand what is already collected for your Kubernetes cluster.
Let's review the log ingest rules that were automatically created during Dynatrace Operator deployment.
These rules define which autodiscovered log sources are ingested and stored in Grail.
As you've completed the Kubernetes quickstart guide, the related log ingest rules are already in place, and your Kubernetes logs are already ingested.
To access these logs, go to
Kubernetes, select the required Kubernetes object, and go to the Logs tab. Alternatively, go to
Logs.
If you've decided to restrict log monitoring to certain resources when deploying Dynatrace Operator based on the Kubernetes quickstart guide (Restrict Log monitoring to certain resources option), follow the steps below.
In the upper-left corner of
Settings, select Go to entity >, and choose the required Kubernetes cluster.
Add an Exclude all log ingest rule and move it to the bottom of the rule list for this Kubernetes cluster. This prevents any inherited rules from being evaluated.
You can also add such an exclusion rule on the Kubernetes cluster scope by using the Settings API.
Congratulations! You can now inspect errors in the
Kubernetes cluster node view.

Moreover, you can analyze logs of your workloads in the
Kubernetes workload view.

You can end this tutorial here. Optionally, you can fine-tune log ingestion with custom rules and sensitive data masking by following the steps in the next sections.
The DynaKube log configuration from the previous steps is immutable and used only during onboarding. You should manage additional log ingest rules via the Dynatrace web UI or Settings API.
To configure a log ingest rule for a specific Kubernetes cluster scope
Alternatively, open the required Kubernetes cluster in
Kubernetes, and select (Actions menu) > Log ingest rules in the cluster details pane.
See Stream Kubernetes logs with Dynatrace Log module for more examples.
If you want all Kubernetes clusters in your environment to be configured the same way, you need to define log ingest rules at the environment scope.
To configure a log ingest rule for the environment configuration scope
Note that any rules on the Kubernetes cluster scope override the rules set on the environment scope when the same Conditions are used.
If you want to manage log ingest rules only on the environment scope, disable the rule created by Dynatrace Operator at the Kubernetes cluster scope. Do not remove rules created by Dynatrace Operator as they can be recreated.
Let's use an email address example from Sensitive data masking in OneAgent.
Follow these instructions to create a custom sensitive data masking rule.
\b[\w\-\._]+?@[\w\-\._]+?\.\w{2,10}?\b in Search expression.After you're created this masking rule, the rule is propagated to all log modules in the selected Kubernetes cluster, and sensitive data is masked before leaving your environment.
The following is a solution to a problem some people have.
Why are logs still missing after enabling Log monitoring?
You've completed the tutorial!
Now that you've turned on Kubernetes log ingestion and set up your log ingest rules, you can track whether there are Kubernetes cluster node issues for effective troubleshooting of your workloads.