<?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: Select the contents of the key-values fields from the string in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376252#M68128</link>
    <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 12 Feb 2019 07:29:01 GMT</pubDate>
    <dc:creator>mbabakov</dc:creator>
    <dc:date>2019-02-12T07:29:01Z</dc:date>
    <item>
      <title>Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376240#M68116</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;There is a log with such records:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Dec 17 10:08:38 10.52.137.1 Apr  3 22:46:57 2012 930-RTR-944 %%10SSH/6/SSH_LOGIN(l): -DevIP=10.52.137.1; STEL user monitor (IP: 192.168.181.94) logged in successfully.
Dec 17 10:08:38 10.52.137.1 Apr  3 22:46:57 2012 930-RTR-944 %%10SC/6/SC_AAA_SUCCESS(l): -DevIP=10.52.137.1-AAAType=ACCOUNT-AAAScheme= local-Service=login-UserName=monitor@system; AAA is successful.
Dec 17 10:08:38 10.52.137.1 Apr  3 22:46:57 2012 930-RTR-944 %%10SC/6/SC_AAA_SUCCESS(l): -DevIP=10.52.137.1-AAAType=AUTHEN-AAAScheme= hwtacacs-scheme tacacs-Service=login-UserName=monitor@system; AAA is successful.
Dec 17 10:08:13 10.98.171.65 Jan 20 00:00:17 2011 MSR954-RTR-LTE-5686 %%10CELLULAR/5/CELLULAR: -DevIP=10.98.171.65;   Controller Cellular1/0: The network connection switched to 3G.
Dec 17 10:08:04 10.199.69.26 May 23 21:50:30 2012 930-RTR-14815 %%10SSH/4/TrapLogoff(t):  1.3.6.1.4.1.25506.2.22.1.3.0.4 SSH user logoff trap information
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It is necessary to parse the fields between the characters "-" and ";". For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;-DevIP = 10.52.137.1;
-DevIP = 10.52.137.1-AAAType = ACCOUNT-AAAScheme = local-Service = login-UserName = monitor@system;
-DevIP = 10.52.137.1-AAAType = AUTHEN-AAAScheme = hwtacacs-scheme tacacs-Service = login-UserName = monitor@system;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The difficulty is that the symbol "-" is used as a separator between key-value pairs, which is also present in the value: "AAAScheme = hwtacacs-scheme tacacs".&lt;/P&gt;

&lt;P&gt;I used EVAL to replace "-" with "|": &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EVAL-cmd_params_src = replace (cmd_params_src, "- (\ p {Lu})", "| \ 1")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I see:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;cmd_params_src = "DevIP = 10.52.137.1 | AAAType = AUTHEN | AAAScheme = hwtacacs-scheme tacacs | Service = login | UserName = monitor @ system"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But fields are not translated to key value.&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[hp_routers]
EVAL-vendor = "HP"
KV_MODE = none

REPORT-fields_general = extract_hp_route_general
REPORT-fields_cmd_parameters = extract_hp_route_cmd_parameters
REPORT-fields_cmd_message = extract_hp_route_cmd_message
EVAL-cmd_params_src = replace(cmd_params_src, "-(\p{Lu})", "|\1")
REPORT-field_params = extracet_field_from_params
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extract_hp_route_general]
REGEX = ^(?P&amp;lt;Date&amp;gt;\w+\s+\d+\s+\d+:\d+:\d+)\s+(?P&amp;lt;device_ip&amp;gt;[^ ]+)\s+(?P&amp;lt;device_time&amp;gt;\w+\s+\d+\s+\d+:\d+:\d+\s+\d+)[^ \n]* (?P&amp;lt;hostname&amp;gt;[^ ]+)[^ \n]* \%\%10(?&amp;lt;cmd_grp&amp;gt;\w+)\/$

[extract_hp_route_cmd_parameters]
REGEX = (?:\s-)(?&amp;lt;cmd_params_src&amp;gt;.+)(?:;)
disabled = 0

[extract_hp_route_cmd_message]
REGEX = (?:;\s+)(?&amp;lt;cmd_msg&amp;gt;.+)$

[extracet_field_from_params]
REGEX = (\w+)=(\s?[.\-\s@\w]+)
FORMAT = $1::$2
SOURCE_KEY = cmd_params_src
#DELIMS = "|", "="
REPEAT_MATCH = True
CLEAN_KEYS = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What am I doing wrong, how to fix the situation?&lt;/P&gt;

&lt;P&gt;regards&lt;BR /&gt;
Michael&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 10:11:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376240#M68116</guid>
      <dc:creator>mbabakov</dc:creator>
      <dc:date>2018-12-17T10:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376241#M68117</link>
      <description>&lt;P&gt;Hi mbabakov,&lt;BR /&gt;
can you use "DevIP" that is after "-"?&lt;BR /&gt;
If yes, you can try (see on regex101.com at &lt;A href="https://regex101.com/r/2cwhUx/1"&gt;https://regex101.com/r/2cwhUx/1&lt;/A&gt; )&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;-(?&amp;lt;my_field&amp;gt;DevIP[^;]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If instead you're not sure about the word "DevIP" but you're sure that there's the equal after the first word, you could use something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;-(?&amp;lt;my_field&amp;gt;[^\=]*\=[^;]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 12:46:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376241#M68117</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2018-12-17T12:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376242#M68118</link>
      <description>&lt;P&gt;Sorry, but I need to work out all possible lines between "-" and ";". For example:&lt;BR /&gt;
 -DevIP = 10.52.137.1;&lt;BR /&gt;
 -DevIP = 10.52.137.1-AAAType = ACCOUNT-AAAScheme = local-Service = login-UserName = monitor@system;&lt;BR /&gt;
 -DevIP = 10.52.137.1-AAAType = AUTHEN-AAAScheme = hwtacacs-scheme tacacs-Service = login-UserName = monitor@system;&lt;/P&gt;

&lt;P&gt;A special case of "-DevIP = 10.52.137.1;", this is very simple. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 12:52:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376242#M68118</guid>
      <dc:creator>mbabakov</dc:creator>
      <dc:date>2018-12-17T12:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376243#M68119</link>
      <description>&lt;P&gt;To clarify, I am interested in the analysis of all possible fields in rows in the log, for example:&lt;BR /&gt;
-DevIP = 10.52.137.1;&lt;BR /&gt;
-DevIP = 10.52.137.1-AAAType = ACCOUNT-AAAScheme = local-Service = login-UserName = monitor@system;&lt;BR /&gt;
-DevIP = 10.52.137.1-AAAType = AUTHEN-AAAScheme = hwtacacs-scheme tacacs-Service = login-UserName = monitor@system;&lt;/P&gt;

&lt;P&gt;Those. for the first line is DevIP. For the second, these are DevIP, AAAType, AAAScheme, Service, UserName, etc.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 13:33:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376243#M68119</guid>
      <dc:creator>mbabakov</dc:creator>
      <dc:date>2018-12-17T13:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376244#M68120</link>
      <description>&lt;P&gt;infact, as you can see at &lt;A href="https://regex101.com/r/2cwhUx/1"&gt;https://regex101.com/r/2cwhUx/1&lt;/A&gt; using this regex, you take all between "-" and the first ";".&lt;BR /&gt;
If you have more ";", you can use a similar regex.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe &lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 13:36:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376244#M68120</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2018-12-17T13:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376245#M68121</link>
      <description>&lt;P&gt;Sorry for an additional information: &lt;BR /&gt;
if you have "-DevIP = 10.52.137.1-AAAType = ACCOUNT-AAAScheme = local-Service = login-UserName = monitor@system;" do you want separately each field?&lt;BR /&gt;
something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DevIP = 10.52.137.1
AAAType = ACCOUNT
AAAScheme = local
Service = login
UserName = monitor@system
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if this is your requirement, see &lt;A href="https://regex101.com/r/2cwhUx/2"&gt;https://regex101.com/r/2cwhUx/2&lt;/A&gt; and try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;-(?&amp;lt;my_field&amp;gt;\w*\=[^;-]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 13:44:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376245#M68121</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2018-12-17T13:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376246#M68122</link>
      <description>&lt;P&gt;Yes, I need to separate each field separately. And I do not know how many of these fields will be in different records and how they will be called.&lt;BR /&gt;
Therefore, I need a construction of the form (? &amp;lt;_ KEY_1&amp;gt; [^ =] [\ p {Lu} \ p {Lt}]. +) = (? &amp;lt;_ VAL_1&amp;gt; [^ |]. +). But, when using the separator "-" between the pairs, the regular expression becomes very complicated, since the "-" symbol can be used in the Value field.&lt;BR /&gt;
I used EVAL to replace "-" with "|", but I don’t know how in this case to force splunk to parse all key-value pairs.&lt;/P&gt;

&lt;P&gt;For example &lt;A href="https://regex101.com/r/tlaRxc/1" target="_blank"&gt;https://regex101.com/r/tlaRxc/1&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:29:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376246#M68122</guid>
      <dc:creator>mbabakov</dc:creator>
      <dc:date>2020-09-29T22:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376247#M68123</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="Dec 17 10:08:38 10.52.137.1 Apr  3 22:46:57 2012 930-RTR-944 %%10SSH/6/SSH_LOGIN(l): -DevIP=10.52.137.1; STEL user monitor (IP: 192.168.181.94) logged in successfully.:::Dec 17 10:08:38 10.52.137.1 Apr  3 22:46:57 2012 930-RTR-944 %%10SC/6/SC_AAA_SUCCESS(l): -DevIP=10.52.137.1-AAAType=ACCOUNT-AAAScheme= local-Service=login-UserName=monitor@system; AAA is successful.:::Dec 17 10:08:38 10.52.137.1 Apr  3 22:46:57 2012 930-RTR-944 %%10SC/6/SC_AAA_SUCCESS(l): -DevIP=10.52.137.1-AAAType=AUTHEN-AAAScheme= hwtacacs-scheme tacacs-Service=login-UserName=monitor@system; AAA is successful.:::Dec 17 10:08:13 10.98.171.65 Jan 20 00:00:17 2011 MSR954-RTR-LTE-5686 %%10CELLULAR/5/CELLULAR: -DevIP=10.98.171.65;   Controller Cellular1/0: The network connection switched to 3G.:::Dec 17 10:08:04 10.199.69.26 May 23 21:50:30 2012 930-RTR-14815 %%10SSH/4/TrapLogoff(t):  1.3.6.1.4.1.25506.2.22.1.3.0.4 SSH user logoff trap information" 
| makemv delim=":::" raw 
| mvexpand raw 
| rename raw AS _raw
| eval _time = strptime(_raw, "%b %d %H:%M:%S")

| rename COMMENT AS "Everything above generates sample events; everything below is your solution"

| rex max_match=0 "(?&amp;lt;key&amp;gt;[^-=]+)=(?&amp;lt;value&amp;gt;[^=]*?)(?=$|-[^-=]+=)"
| eval _raw=mvzip(key, value, "=")
| fields - key value
| kv
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Feb 2019 03:13:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376247#M68123</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-12T03:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376248#M68124</link>
      <description>&lt;P&gt;The key is to do your own KVP decoding and to use the RegEx &lt;CODE&gt;positive lookahead&lt;/CODE&gt; feature to ensure that no keys (only values) can contain hyphens.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 03:14:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376248#M68124</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-12T03:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376249#M68125</link>
      <description>&lt;P&gt;Thanks for your solution!&lt;BR /&gt;
I wanted the analysis to go at the indexing stage. But in the end agreed to parse the search stage. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 07:02:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376249#M68125</guid>
      <dc:creator>mbabakov</dc:creator>
      <dc:date>2019-02-12T07:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376250#M68126</link>
      <description>&lt;P&gt;To set this up to be automatic, like this:&lt;/P&gt;

&lt;P&gt;In props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[hp_routers]
KV_MODE = none
REPORT-HP_KVPs = HP_KVPs
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[HP_KVPs]
REGEX = ([^-=]+)=([^=]*?)(?=$|-[^-=]+=)
FORMAT = $1::$2
REPEAT_MATCH = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The key is to do your own KVP decoding and to use the RegEx positive lookahead feature to ensure that no keys (only values) can contain hyphens.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 07:20:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376250#M68126</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-12T07:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376251#M68127</link>
      <description>&lt;P&gt;Right, I forgot that.  See my other answer.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 07:21:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376251#M68127</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-12T07:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376252#M68128</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 07:29:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376252#M68128</guid>
      <dc:creator>mbabakov</dc:creator>
      <dc:date>2019-02-12T07:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376253#M68129</link>
      <description>&lt;P&gt;I think you clicked &lt;CODE&gt;Accept&lt;/CODE&gt; on the wrong one, right?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 07:41:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376253#M68129</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-12T07:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Select the contents of the key-values fields from the string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376254#M68130</link>
      <description>&lt;P&gt;Sorry, yes. Corrected&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 07:59:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Select-the-contents-of-the-key-values-fields-from-the-string/m-p/376254#M68130</guid>
      <dc:creator>mbabakov</dc:creator>
      <dc:date>2019-02-12T07:59:32Z</dc:date>
    </item>
  </channel>
</rss>

