<?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 Re: Conditional Parsing in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Conditional-Parsing/m-p/281424#M2298</link>
    <description>&lt;P&gt;Hi Mario,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;Option 1: using the parse function with if statement&lt;/DIV&gt;&lt;PRE&gt;data record(content = "This is a string with IP: --"), &lt;BR /&gt;record(content = "This is a string with UUID: --")&lt;BR /&gt; | fieldsAdd res = if(stringLength(content) == 37, parse(content, "LD IP:out"), else: parse(content, "LD UUIDSTRING:out"))&lt;/PRE&gt;&lt;DIV class=""&gt;Option 2: using parsingPrerequisite&lt;/DIV&gt;&lt;PRE&gt;&lt;BR /&gt;data record(content = "This is a string with IP: --"), &lt;BR /&gt;record(content = "This is a string with UUID: --") &lt;BR /&gt;| parse content, "LD IP:out", parsingPrerequisite: stringLength(content) == 37 &lt;BR /&gt;| parse content, "LD UUIDSTRING:out", parsingPrerequisite: stringLength(content) == 64&lt;/PRE&gt;&lt;DIV class=""&gt;Option 3 (worst): just hope that at least one pattern works:&lt;/DIV&gt;&lt;PRE&gt;data record(content = "This is a string with IP: --"), &lt;BR /&gt;record(content = "This is a string with UUID: --") &lt;BR /&gt;| parse content, "LD IP:out", preserveFieldsOnFailure: true &lt;BR /&gt;| parse content, "LD UUIDSTRING:out", preserveFieldsOnFailure: true&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;As of now there is no else if option available.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Credits to:&amp;nbsp;&lt;SPAN&gt;Maxim Pokrovskiy&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 12 Jul 2025 20:03:25 GMT</pubDate>
    <dc:creator>Emm4nuel</dc:creator>
    <dc:date>2025-07-12T20:03:25Z</dc:date>
    <item>
      <title>Conditional Parsing</title>
      <link>https://community.dynatrace.com/t5/DQL/Conditional-Parsing/m-p/246336#M921</link>
      <description>&lt;P&gt;Currently I'm dealing with a logfile which outputs different data depending on the action which has occurred, one parse statement cannot handle all the options so I have multiple parse statements.&lt;/P&gt;
&lt;P&gt;I need to combine it all into one table at the end, but the only option I've found so far is via multiple fetch &amp;amp; appends, which feels very inefficient and clunky. Is there are way to streamline this sort of query?&lt;/P&gt;
&lt;P&gt;As an example:&lt;/P&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;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;fetch logs, from: -3d
|  filter dt.host_group.id == "myTag"
|  filter matchesPhrase(content, "myFirstTextToMatch")
| parse content, "DATA blah blah blah parse out fields here"
| append  [fetch logs, from: -3d
  |  filter dt.host_group.id == "myTag"
  |  filter matchesPhrase(content, "mySecondTextToMatch")
  |  parse content, "DATA blah blah blah parse out second pattern fields here"
    | append  [fetch logs, from: -3d
      |  filter dt.host_group.id == "myTag"
      |  filter matchesPhrase(content, "myThirdTextToMatch")
      |  parse content, "DATA blah blah blah parse out third pattern fields here"
... and so on&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to use a conditional operator here maybe?&lt;/P&gt;
&lt;P&gt;ie, IF matches FirstText then parse using First pattern ELSE IF matches SecondText parse using Second pattern...&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 08:37:12 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Conditional-Parsing/m-p/246336#M921</guid>
      <dc:creator>mario_rwwa</dc:creator>
      <dc:date>2024-05-24T08:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Parsing</title>
      <link>https://community.dynatrace.com/t5/DQL/Conditional-Parsing/m-p/281161#M2269</link>
      <description>&lt;P&gt;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/43618"&gt;@mario_rwwa&lt;/a&gt;&amp;nbsp;- were you able to get a solution for this?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2025 12:42:46 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Conditional-Parsing/m-p/281161#M2269</guid>
      <dc:creator>ChadTurner</dc:creator>
      <dc:date>2025-07-09T12:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Parsing</title>
      <link>https://community.dynatrace.com/t5/DQL/Conditional-Parsing/m-p/281207#M2272</link>
      <description>&lt;P&gt;Rather than the conditional parsing, you might consider parsing at ingest time instead so that the parsing can be removed from the query entirely. This can be advantageous, because you can make the parsing rules conditional to each incoming pattern. Then when you go to query, you just query the pre-parsed fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If that's not feasible, the other approach is to use the &lt;A href="https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-query-language/commands/selection-and-modification-commands#fieldsAdd" target="_blank"&gt;fieldsAdd&lt;/A&gt; command, combined with the &lt;A href="https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-query-language/functions/conditional-functions#if" target="_blank"&gt;if&lt;/A&gt; and &lt;A href="https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-query-language/functions/string-functions#parseAll" target="_self"&gt;parseAll&lt;/A&gt; functions to accomplish additional parsing. You'll have to do some array flattening afterwards as well, since the parseAll function will output its result into a single field as an array.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2025 22:02:18 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Conditional-Parsing/m-p/281207#M2272</guid>
      <dc:creator>marco_irmer</dc:creator>
      <dc:date>2025-07-09T22:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Parsing</title>
      <link>https://community.dynatrace.com/t5/DQL/Conditional-Parsing/m-p/281424#M2298</link>
      <description>&lt;P&gt;Hi Mario,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;Option 1: using the parse function with if statement&lt;/DIV&gt;&lt;PRE&gt;data record(content = "This is a string with IP: --"), &lt;BR /&gt;record(content = "This is a string with UUID: --")&lt;BR /&gt; | fieldsAdd res = if(stringLength(content) == 37, parse(content, "LD IP:out"), else: parse(content, "LD UUIDSTRING:out"))&lt;/PRE&gt;&lt;DIV class=""&gt;Option 2: using parsingPrerequisite&lt;/DIV&gt;&lt;PRE&gt;&lt;BR /&gt;data record(content = "This is a string with IP: --"), &lt;BR /&gt;record(content = "This is a string with UUID: --") &lt;BR /&gt;| parse content, "LD IP:out", parsingPrerequisite: stringLength(content) == 37 &lt;BR /&gt;| parse content, "LD UUIDSTRING:out", parsingPrerequisite: stringLength(content) == 64&lt;/PRE&gt;&lt;DIV class=""&gt;Option 3 (worst): just hope that at least one pattern works:&lt;/DIV&gt;&lt;PRE&gt;data record(content = "This is a string with IP: --"), &lt;BR /&gt;record(content = "This is a string with UUID: --") &lt;BR /&gt;| parse content, "LD IP:out", preserveFieldsOnFailure: true &lt;BR /&gt;| parse content, "LD UUIDSTRING:out", preserveFieldsOnFailure: true&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;As of now there is no else if option available.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Credits to:&amp;nbsp;&lt;SPAN&gt;Maxim Pokrovskiy&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jul 2025 20:03:25 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Conditional-Parsing/m-p/281424#M2298</guid>
      <dc:creator>Emm4nuel</dc:creator>
      <dc:date>2025-07-12T20:03:25Z</dc:date>
    </item>
  </channel>
</rss>

