<?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 Cortex XDR Parsing rule / SQL query in Cortex XDR Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/cortex-xdr-parsing-rule-sql-query/m-p/537398#M4020</link>
    <description>&lt;P&gt;Hi All&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am currently creating some parsing rules and I am using split to seperate the _raw_log field into its individual fields. After my initiail split I have one a field that starts with a comma, or multple commas, depending on the log. Does anyone know if it is possible to trim either:&lt;/P&gt;
&lt;P&gt;A single comma from the start, or&lt;/P&gt;
&lt;P&gt;A single character from the start?&lt;/P&gt;
&lt;P&gt;I have tried using "ltrim" but it removes all the commas at the start of the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Danny&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Apr 2023 07:27:33 GMT</pubDate>
    <dc:creator>DannyMulheran</dc:creator>
    <dc:date>2023-04-03T07:27:33Z</dc:date>
    <item>
      <title>Cortex XDR Parsing rule / SQL query</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/cortex-xdr-parsing-rule-sql-query/m-p/537398#M4020</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am currently creating some parsing rules and I am using split to seperate the _raw_log field into its individual fields. After my initiail split I have one a field that starts with a comma, or multple commas, depending on the log. Does anyone know if it is possible to trim either:&lt;/P&gt;
&lt;P&gt;A single comma from the start, or&lt;/P&gt;
&lt;P&gt;A single character from the start?&lt;/P&gt;
&lt;P&gt;I have tried using "ltrim" but it removes all the commas at the start of the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Danny&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 07:27:33 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/cortex-xdr-parsing-rule-sql-query/m-p/537398#M4020</guid>
      <dc:creator>DannyMulheran</dc:creator>
      <dc:date>2023-04-03T07:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex XDR Parsing rule / SQL query</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/cortex-xdr-parsing-rule-sql-query/m-p/537668#M4050</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/150849"&gt;@DannyMulheran&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for reaching out on LIVEcommunity!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible that you an post what&amp;nbsp; you have so far so I can get a look and get a better understanding of what you're trying to parse?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 22:25:49 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/cortex-xdr-parsing-rule-sql-query/m-p/537668#M4050</guid>
      <dc:creator>anlynch</dc:creator>
      <dc:date>2023-04-04T22:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex XDR Parsing rule / SQL query</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/cortex-xdr-parsing-rule-sql-query/m-p/537677#M4051</link>
      <description>&lt;P&gt;Hi Anlynch&lt;/P&gt;
&lt;P&gt;Thanks for responding. Before you review the info below, I have realised whilst putting this info together that the solution is to simply take the extra field, caused by the extra comma, into account when I refence the index of the value I want. However, I am including the detail of what I am doing as I would still be interested to know if it is possible to just remove a single comma, or a single character (this would be the same in this case) from the start or end of a value.&lt;/P&gt;
&lt;P&gt;It is a NGFW TRAFFIC log I am parsing. I use split to separate the fields using comma as the delimiter, but the 'Application Characteristic' field can have multiple entries that are also comma separated.&lt;/P&gt;
&lt;P&gt;To deal with this I use a filter to identify if there is a " in the log (so far I have only seen " in the app characteristic field, when this field has multiple values). If this is the case I first split the log into 3 separate sections using the " as the delimiter. The second section delivers the app characteristic field perfectly. The first and third set of fields cover all the remaining fields, but it leaves an additional comma at the end of the first and start of the third set of field values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At the start of the third set of fields sometimes it starts with a single comma (example: ,dns,dns-base,no,no,0), and sometimes with multiple commas (example: ,,ssl,no,no,0), depending on whether the field following the app characteristic field has a value or not. I wanted to remove the first comma only, but the ltrim removes all the leading commas. I would like to just remove a single comma, or a single character (this would be the same in this case).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Query example I am playing around with:&lt;/P&gt;
&lt;P&gt;dataset = panw20_ngfw20_raw&lt;/P&gt;
&lt;P&gt;| filter _raw_log contains "TRAFFIC" and _raw_log contains "\""&lt;/P&gt;
&lt;P&gt;| alter temp1 = split(_raw_log, "\"")&lt;/P&gt;
&lt;P&gt;| alter group1 = rtrim(arrayindex(temp1, 0), ",")&lt;/P&gt;
&lt;P&gt;| alter group2 = arrayindex(temp1, 1)&lt;/P&gt;
&lt;P&gt;| alter group3 = arrayindex(temp1, 2) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// I was using ltrim on this line&lt;/P&gt;
&lt;P&gt;| limit&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 01:21:55 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/cortex-xdr-parsing-rule-sql-query/m-p/537677#M4051</guid>
      <dc:creator>DannyMulheran</dc:creator>
      <dc:date>2023-04-05T01:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex XDR Parsing rule / SQL query</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/cortex-xdr-parsing-rule-sql-query/m-p/537793#M4053</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/150849"&gt;@DannyMulheran&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you looked at &lt;A href="https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/arrayindex" target="_self"&gt;arrayindex&lt;/A&gt; and&amp;nbsp;&lt;A href="https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/regextract" target="_self"&gt;regextract&lt;/A&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I reckon that you could use something like,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;EM&gt;dataset = panw20_ngfw20_raw&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;EM&gt;| filter _raw_log contains "TRAFFIC" and _raw_log contains "\""&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;EM&gt;| alter temp1 = split(_raw_log, "\"")&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;EM&gt;| alter group1 = rtrim(arrayindex(temp1, 0), ",")&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;EM&gt;| alter group2 = arrayindex(temp1, 1)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;EM&gt;//| alter group3 = arrayindex(temp1, 2) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// I was using ltrim on this line&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;&lt;EM&gt;| alter group3 = arrayindex(regextract(temp1, "^,|,(\s)"),0)&lt;/EM&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;EM&gt; //I am not 100% sure about the regex itself and if 0 is the correct position in the arrayindex.&amp;nbsp;&lt;/EM&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;EM&gt;| limit 10&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 20:50:50 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/cortex-xdr-parsing-rule-sql-query/m-p/537793#M4053</guid>
      <dc:creator>fmoixsante</dc:creator>
      <dc:date>2023-04-05T20:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex XDR Parsing rule / SQL query</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/cortex-xdr-parsing-rule-sql-query/m-p/537846#M4055</link>
      <description>&lt;P&gt;HI&lt;/P&gt;
&lt;P&gt;I am refreshing myself on regex and happy this will met the requirement. Thanks.&lt;/P&gt;
&lt;P&gt;Danny&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 06:45:56 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/cortex-xdr-parsing-rule-sql-query/m-p/537846#M4055</guid>
      <dc:creator>DannyMulheran</dc:creator>
      <dc:date>2023-04-06T06:45:56Z</dc:date>
    </item>
  </channel>
</rss>

