<?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 DQL Tips and Tricks - Parsing Log Data Across a Multi-Line Log in Dynatrace tips</title>
    <link>https://community.dynatrace.com/t5/Dynatrace-tips/DQL-Tips-and-Tricks-Parsing-Log-Data-Across-a-Multi-Line-Log/m-p/207088#M778</link>
    <description>&lt;P&gt;If you're like me, you're probably brand new to the DQL world and are quickly trying to learn everything you can when it comes to DQL queries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I recently had a client request a query to pull 2 specific fields out of a log and display them with on the log table within Dynatrace's new Logs and Events (Powered by Grail) tab. After some time, I got a solution that worked exactly how they wanted, and figured others might want the information I discovered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the setup:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The task was to 'grab text from a multi-line log file and report it out (one being a string called ITN and an IP address called client_ip)'&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the DQL query I used:&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;fetch logs
| filter contains(content, "Order modify unsuccessful") and dt.process.name == "tomcat"
| parse content, "DATA 'Order modify unsuccessful' SPACE STRING:ITN"
| parse content, "DATA 'clientIpAddress' LD ':' DQS:client_ip"
| fields timestamp, content, ITN, client_ip
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here's what the output table looks like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="chris_smerek_0-1678922228923.png" style="width: 603px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/10486i6BC3EA6BBC631C6F/image-dimensions/603x98?v=v2" width="603" height="98" role="button" title="chris_smerek_0-1678922228923.png" alt="chris_smerek_0-1678922228923.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The key points to note on this query:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The 'DATA' content type is used to parse multi-line logs
&lt;UL&gt;
&lt;LI&gt;This had me stumped for a while as I was using LD (which only works on a single line of log data)&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;The single quote 'Order modify unsuccessful' sets us up to point to the log data right after this string
&lt;UL&gt;
&lt;LI&gt;SPACE picks up a white space in between the last string and the next set of data we want to parse&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;'STRING:ITN' tells the query to look for a string as the next set of log data, and save that string to a variable called 'ITN&lt;/LI&gt;
&lt;LI&gt;The next parse line is very similar to the previous one, except we want to pull out the IP address that's enclosed between double quotes
&lt;UL&gt;
&lt;LI&gt;'DQS:client_ip' pulls out any data that exists between a set of double quotes, and saves it to the variable called 'client_ip'
&lt;UL&gt;
&lt;LI&gt;Technically I could have used IPADDR here, but DQS made it easier for me to get the exact data&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;The final line of the query just gives us a clean output table which displays the relevant information, namely the timestamp of the log, log content, and our 2 custom variables&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's it! I've posted a mock log file below this as well if folks want to give it a try on their own time:&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;2023/03/15 16:05:48.279 [ERROR] http-ono-8080-heyo-117 (com.test.are.we.OrderES) -&amp;gt; {"testTransactionID":"123-456-789-10101-F90000000009","clientIpAddress":"192.168.12.122"},
ErrorException: [2405] Order modify unsuccessful (AB23JK)
	at com.website.are.bll.order.OrderBLLImpl.modifyOrder(OrderTESTImpl.java:1111)
	at com.website.are.ws.OrderWS.modifyOrder(OrderWS.java:222)
	at java.lang.reflect.Method.invoke(Method.java:333)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:444)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this is helpful to anyone just starting out with DQL queries!&lt;/P&gt;</description>
    <pubDate>Fri, 24 Mar 2023 09:39:45 GMT</pubDate>
    <dc:creator>chris_smerek</dc:creator>
    <dc:date>2023-03-24T09:39:45Z</dc:date>
    <item>
      <title>DQL Tips and Tricks - Parsing Log Data Across a Multi-Line Log</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-tips/DQL-Tips-and-Tricks-Parsing-Log-Data-Across-a-Multi-Line-Log/m-p/207088#M778</link>
      <description>&lt;P&gt;If you're like me, you're probably brand new to the DQL world and are quickly trying to learn everything you can when it comes to DQL queries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I recently had a client request a query to pull 2 specific fields out of a log and display them with on the log table within Dynatrace's new Logs and Events (Powered by Grail) tab. After some time, I got a solution that worked exactly how they wanted, and figured others might want the information I discovered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the setup:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The task was to 'grab text from a multi-line log file and report it out (one being a string called ITN and an IP address called client_ip)'&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the DQL query I used:&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;fetch logs
| filter contains(content, "Order modify unsuccessful") and dt.process.name == "tomcat"
| parse content, "DATA 'Order modify unsuccessful' SPACE STRING:ITN"
| parse content, "DATA 'clientIpAddress' LD ':' DQS:client_ip"
| fields timestamp, content, ITN, client_ip
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here's what the output table looks like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="chris_smerek_0-1678922228923.png" style="width: 603px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/10486i6BC3EA6BBC631C6F/image-dimensions/603x98?v=v2" width="603" height="98" role="button" title="chris_smerek_0-1678922228923.png" alt="chris_smerek_0-1678922228923.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The key points to note on this query:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The 'DATA' content type is used to parse multi-line logs
&lt;UL&gt;
&lt;LI&gt;This had me stumped for a while as I was using LD (which only works on a single line of log data)&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;The single quote 'Order modify unsuccessful' sets us up to point to the log data right after this string
&lt;UL&gt;
&lt;LI&gt;SPACE picks up a white space in between the last string and the next set of data we want to parse&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;'STRING:ITN' tells the query to look for a string as the next set of log data, and save that string to a variable called 'ITN&lt;/LI&gt;
&lt;LI&gt;The next parse line is very similar to the previous one, except we want to pull out the IP address that's enclosed between double quotes
&lt;UL&gt;
&lt;LI&gt;'DQS:client_ip' pulls out any data that exists between a set of double quotes, and saves it to the variable called 'client_ip'
&lt;UL&gt;
&lt;LI&gt;Technically I could have used IPADDR here, but DQS made it easier for me to get the exact data&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;The final line of the query just gives us a clean output table which displays the relevant information, namely the timestamp of the log, log content, and our 2 custom variables&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's it! I've posted a mock log file below this as well if folks want to give it a try on their own time:&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;2023/03/15 16:05:48.279 [ERROR] http-ono-8080-heyo-117 (com.test.are.we.OrderES) -&amp;gt; {"testTransactionID":"123-456-789-10101-F90000000009","clientIpAddress":"192.168.12.122"},
ErrorException: [2405] Order modify unsuccessful (AB23JK)
	at com.website.are.bll.order.OrderBLLImpl.modifyOrder(OrderTESTImpl.java:1111)
	at com.website.are.ws.OrderWS.modifyOrder(OrderWS.java:222)
	at java.lang.reflect.Method.invoke(Method.java:333)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:444)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this is helpful to anyone just starting out with DQL queries!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 09:39:45 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-tips/DQL-Tips-and-Tricks-Parsing-Log-Data-Across-a-Multi-Line-Log/m-p/207088#M778</guid>
      <dc:creator>chris_smerek</dc:creator>
      <dc:date>2023-03-24T09:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: DQL Tips and Tricks - Parsing Log Data Across a Multi-Line Log</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-tips/DQL-Tips-and-Tricks-Parsing-Log-Data-Across-a-Multi-Line-Log/m-p/212144#M838</link>
      <description>&lt;P&gt;Thank you for these tips and tricks&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/51817"&gt;@chris_smerek&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 19:39:48 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-tips/DQL-Tips-and-Tricks-Parsing-Log-Data-Across-a-Multi-Line-Log/m-p/212144#M838</guid>
      <dc:creator>ChadTurner</dc:creator>
      <dc:date>2023-05-12T19:39:48Z</dc:date>
    </item>
  </channel>
</rss>

