<?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: How to maintain format into variables in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-maintain-format-into-variables/m-p/31231#M178092</link>
    <description>&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="xtype" query | rex field=_raw "(?m)):s(?&amp;lt;message&amp;gt;.+)" | table Message
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;(?m)&lt;/CODE&gt; tells the regex to work across line breaks.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Aug 2012 04:40:04 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2012-08-10T04:40:04Z</dc:date>
    <item>
      <title>How to maintain format into variables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-maintain-format-into-variables/m-p/31230#M178091</link>
      <description>&lt;P&gt;I want to extract part of an event that is multi-line and tab formated, the event lokks like this:&lt;/P&gt;

&lt;P&gt;11:19:29.000 PM &lt;BR /&gt;
7.05 0.00 (1343189969 083501): Query a ejecutar: SELECT prop_account, description &lt;BR /&gt;
    FROM tracking.google_analytics_web_properties&lt;BR /&gt;
    WHERE prop_type = 'qa'&lt;BR /&gt;
    AND home = 'es_cl'&lt;BR /&gt;
    AND portal = '*'&lt;/P&gt;

&lt;P&gt;I want to extract from Query I use a regex and I have a variable called Message. But when I displayed it Splunk truncate the message.&lt;/P&gt;

&lt;P&gt;1   Query a ejecutar: SELECT prop_account, description&lt;/P&gt;

&lt;P&gt;I am using this search command:&lt;/P&gt;

&lt;P&gt;sourcetype="xtype" query | rex field=_raw "):\s(?&lt;MESSAGE&gt;.+)" | table Message&lt;/MESSAGE&gt;&lt;/P&gt;

&lt;P&gt;Any idea could be great.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:14:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-maintain-format-into-variables/m-p/31230#M178091</guid>
      <dc:creator>gerardo_maya</dc:creator>
      <dc:date>2020-09-28T12:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to maintain format into variables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-maintain-format-into-variables/m-p/31231#M178092</link>
      <description>&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="xtype" query | rex field=_raw "(?m)):s(?&amp;lt;message&amp;gt;.+)" | table Message
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;(?m)&lt;/CODE&gt; tells the regex to work across line breaks.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2012 04:40:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-maintain-format-into-variables/m-p/31231#M178092</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-08-10T04:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to maintain format into variables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-maintain-format-into-variables/m-p/31232#M178093</link>
      <description>&lt;P&gt;Thank you, that works to capture all data into the variable but it does not maintain the line breaking inside the Message Variable&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2012 15:23:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-maintain-format-into-variables/m-p/31232#M178093</guid>
      <dc:creator>gerardo_maya</dc:creator>
      <dc:date>2012-08-10T15:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to maintain format into variables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-maintain-format-into-variables/m-p/31233#M178094</link>
      <description>&lt;P&gt;Professional services recommend me to do the following:&lt;BR /&gt;
sourcetype="xtype" query | eval long_str=replace(_raw, "\n", "###") | rex field=long_str "):\s(?&lt;MESSAGE&gt;.+)" | makemv delim="###" Message | table _time Message&lt;/MESSAGE&gt;&lt;/P&gt;

&lt;P&gt;The second part of the search replaces the new lines for a know pattern (on this case ###).&lt;BR /&gt;
Then you use REGEX to capture the field from the long_str&lt;BR /&gt;
Using makemv you break the lines when it found the pattern "###"&lt;BR /&gt;
Lastly you present the data into a table, this is the result.&lt;/P&gt;

&lt;P&gt;Query a ejecutar: SELECT prop_account, description FROM tracking.google_analytics_web_properties &lt;BR /&gt;
WHERE prop_type = 'qa' AND &lt;BR /&gt;
      home = 'es_cl' AND portal = '*'&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:14:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-maintain-format-into-variables/m-p/31233#M178094</guid>
      <dc:creator>gerardo_maya</dc:creator>
      <dc:date>2020-09-28T12:14:40Z</dc:date>
    </item>
  </channel>
</rss>

