<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Extracting and Setting LogLevel based off a Single Character in Dynatrace tips</title>
    <link>https://community.dynatrace.com/t5/Dynatrace-tips/Extracting-and-Setting-LogLevel-based-off-a-Single-Character/m-p/252277#M1680</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Use Case:&lt;/STRONG&gt; Customer has an application log which contains a single character, "E" for example, which denotes what the LogLevel for said Log entry is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[2024-05-21T12:06:40.084-0400] 012345 id=         com.github.example                        E HOST: An unexpected error occured whilst opening the log. Log example Log example Log example Log example Log example Log example Log example&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dynatrace will not automatically extract the single character and set the LogLevel as it is in a non-standard format, but we can perform this work using a Log Processing Rule -&amp;nbsp;&lt;A href="https://docs.dynatrace.com/docs/shortlink/lma-log-processing" target="_blank" rel="noopener"&gt;https://docs.dynatrace.com/docs/shortlink/lma-log-processing&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Log Processor Setup:&amp;nbsp;&lt;/STRONG&gt;Open up the Dynatrace Tenant &amp;gt; Settings &amp;gt; Log Monitoring &amp;gt; Log Processing.&lt;/P&gt;
&lt;P&gt;Click Add rule - Give the rule a friendly but descriptive name.&lt;/P&gt;
&lt;P&gt;In the Matcher field, enter the DQL filters which will focus the log processing rule down to the specific application we are focused on. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;matchesValue(k8s.namespace.name, "App-namespace") AND matchesValue(k8s.deployment.name, "MyApplication")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the processor definition, enter the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;USING(INOUT loglevel, IN content)
|PARSE(content,"LD SPACE LD SPACE LD BLANK LD BLANK ['A-Z']{1}:logstatus SPACE")
| FIELDS_ADD(loglevel:
  IF(logstatus == "W", "WARN",
    IF(logstatus == "E", "ERROR", 
      IF(logstatus == "I", "INFO", 
        IF(logstatus == "C", "CRITICAL",
          IF(logstatus == "D", "DEBUG",
            IF(logstatus == "S", "SEVERE", 
              IF(logstatus == "T", "TRACE", 
                IF(logstatus == "N", "NOTICE",
                  IF(logstatus == "A", "ALERT",
                    IF(logstatus == "F", "FATAL",
                      "NONE"
                    )
                  )
                )
              )
            )
          )
        )
      )
    )
  )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This Log Processing Rule will extract the single character, "E" in the above example, and save that to a logstatus field. Then based off the logstatus field, we update the loglevel to the corresponding value.&lt;/P&gt;
&lt;P&gt;Before transformation vs After Transformation&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bsnurka_0-1722522958844.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/21582i3F698AC41A0381F5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bsnurka_0-1722522958844.png" alt="bsnurka_0-1722522958844.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Save the Rule and Turn it on to start updating the loglevel for any newly ingested logs matching the defined matcher!&lt;/P&gt;</description>
    <pubDate>Tue, 01 Oct 2024 08:30:38 GMT</pubDate>
    <dc:creator>bsnurka</dc:creator>
    <dc:date>2024-10-01T08:30:38Z</dc:date>
    <item>
      <title>Extracting and Setting LogLevel based off a Single Character</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-tips/Extracting-and-Setting-LogLevel-based-off-a-Single-Character/m-p/252277#M1680</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Use Case:&lt;/STRONG&gt; Customer has an application log which contains a single character, "E" for example, which denotes what the LogLevel for said Log entry is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[2024-05-21T12:06:40.084-0400] 012345 id=         com.github.example                        E HOST: An unexpected error occured whilst opening the log. Log example Log example Log example Log example Log example Log example Log example&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dynatrace will not automatically extract the single character and set the LogLevel as it is in a non-standard format, but we can perform this work using a Log Processing Rule -&amp;nbsp;&lt;A href="https://docs.dynatrace.com/docs/shortlink/lma-log-processing" target="_blank" rel="noopener"&gt;https://docs.dynatrace.com/docs/shortlink/lma-log-processing&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Log Processor Setup:&amp;nbsp;&lt;/STRONG&gt;Open up the Dynatrace Tenant &amp;gt; Settings &amp;gt; Log Monitoring &amp;gt; Log Processing.&lt;/P&gt;
&lt;P&gt;Click Add rule - Give the rule a friendly but descriptive name.&lt;/P&gt;
&lt;P&gt;In the Matcher field, enter the DQL filters which will focus the log processing rule down to the specific application we are focused on. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;matchesValue(k8s.namespace.name, "App-namespace") AND matchesValue(k8s.deployment.name, "MyApplication")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the processor definition, enter the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;USING(INOUT loglevel, IN content)
|PARSE(content,"LD SPACE LD SPACE LD BLANK LD BLANK ['A-Z']{1}:logstatus SPACE")
| FIELDS_ADD(loglevel:
  IF(logstatus == "W", "WARN",
    IF(logstatus == "E", "ERROR", 
      IF(logstatus == "I", "INFO", 
        IF(logstatus == "C", "CRITICAL",
          IF(logstatus == "D", "DEBUG",
            IF(logstatus == "S", "SEVERE", 
              IF(logstatus == "T", "TRACE", 
                IF(logstatus == "N", "NOTICE",
                  IF(logstatus == "A", "ALERT",
                    IF(logstatus == "F", "FATAL",
                      "NONE"
                    )
                  )
                )
              )
            )
          )
        )
      )
    )
  )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This Log Processing Rule will extract the single character, "E" in the above example, and save that to a logstatus field. Then based off the logstatus field, we update the loglevel to the corresponding value.&lt;/P&gt;
&lt;P&gt;Before transformation vs After Transformation&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bsnurka_0-1722522958844.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/21582i3F698AC41A0381F5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bsnurka_0-1722522958844.png" alt="bsnurka_0-1722522958844.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Save the Rule and Turn it on to start updating the loglevel for any newly ingested logs matching the defined matcher!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 08:30:38 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-tips/Extracting-and-Setting-LogLevel-based-off-a-Single-Character/m-p/252277#M1680</guid>
      <dc:creator>bsnurka</dc:creator>
      <dc:date>2024-10-01T08:30:38Z</dc:date>
    </item>
  </channel>
</rss>

