<?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: spath field and value pairs in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623525#M216752</link>
    <description>&lt;P&gt;As &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;suggested, it is much easier for others to understand what you mean by using both text and sample data (anonymize as needed; some people just abstract with made-up fields). &amp;nbsp;If I have to read tea leaves, you have a JSON &lt;STRONG&gt;array&lt;/STRONG&gt;, each array element contains two &lt;U&gt;keys&lt;/U&gt;, one named "key" and the other "value", like&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;{"log": [{"key":"&lt;SPAN&gt;originid", "value":"12345"}, {"key":"origintype", "value":"BuiltInRole"}, ... ]}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;You want to pair the &lt;U&gt;values&lt;/U&gt; of "key" and "value", so you have&amp;nbsp;&lt;SPAN&gt;originid=12345,&amp;nbsp;origintype=BuiltInRole, and so on. &amp;nbsp;Is this correct? (It is important to confirm that they are in an array; otherwise the strategy would be different.)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This question gets asked often, in various forms, even recently. &amp;nbsp;But I cannot find that one at this time. &amp;nbsp;So, here we go one method using kv aka &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Extract" target="_blank" rel="noopener"&gt;extract&lt;/A&gt;:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval key_value = mvzip('log{}.key', 'log{}.value', "=") ``` pair values with = ```
| rename _raw as temp, key_value as _raw
| kv
| rename temp as _raw&lt;/LI-CODE&gt;&lt;P&gt;This is the test data I use&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;{"log":[{"key":"originid", "value":"12345"}, {"key":"origintype", "value":"BuiltInRole"}, {"key":"template", "value":"85750845e54"}, {"key":"starttime", "value":"2022-12-03T14:00:00:00.5661018Z"}, {"key":"endtime", "value":"2022-12-04T14:00:00:00.5661018Z"}, {"key":"justification", "value":"some reason to satisfy the justification"}]}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(I don't see any reason why you cannot share sample data like this.) &amp;nbsp;This is emulated with&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval _raw = "{\"log\":[{\"key\":\"originid\", \"value\":\"12345\"}, {\"key\":\"origintype\", \"value\":\"BuiltInRole\"}, {\"key\":\"template\", \"value\":\"85750845e54\"}, {\"key\":\"starttime\", \"value\":\"2022-12-03T14:00:00:00.5661018Z\"}, {\"key\":\"endtime\", \"value\":\"2022-12-04T14:00:00:00.5661018Z\"}, {\"key\":\"justification\", \"value\":\"some reason to satisfy the justification\"}]}"
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2022 06:50:03 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2022-12-07T06:50:03Z</dc:date>
    <item>
      <title>How to search spath field and value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623495#M216745</link>
      <description>&lt;P&gt;I have a log file that is coming into splunk in json format.&amp;nbsp; There appear to be two fields of interest, "key" and "value."&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;key:&lt;BR /&gt;originid&lt;BR /&gt;origintype&lt;BR /&gt;template&lt;BR /&gt;starttime&lt;BR /&gt;endtime&lt;BR /&gt;justification&lt;BR /&gt;&lt;BR /&gt;value - (has the values for each of the items in "key."):&lt;BR /&gt;12345 (is not always the same id)&lt;BR /&gt;BuiltInRole (is not always the same)&lt;BR /&gt;85750845e54 (is not always the same)&lt;BR /&gt;2022-12-03T14:00:00:00.5661018Z&lt;BR /&gt;2022-12-04T14:00:00:00.5661018Z&lt;BR /&gt;some reason to satisfy the justification&lt;BR /&gt;&lt;BR /&gt;I want have the following:&lt;BR /&gt;originid =&amp;nbsp;12345&lt;BR /&gt;origintype =&amp;nbsp;BuiltInRole&lt;BR /&gt;template =&amp;nbsp;85750845e54&lt;BR /&gt;starttime =&amp;nbsp;2022-12-03T14:00:00:00.5661018Z&lt;BR /&gt;endtime =&amp;nbsp;2022-12-04T14:00:00:00.5661018Z&lt;BR /&gt;justification =&amp;nbsp;some reason to satisfy the justification&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thanks for the help and guidance.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 08:14:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623495#M216745</guid>
      <dc:creator>bt149</dc:creator>
      <dc:date>2022-12-07T08:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: spath field and value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623497#M216747</link>
      <description>&lt;P&gt;Please share the raw JSON data.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 21:46:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623497#M216747</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-12-06T21:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: spath field and value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623499#M216748</link>
      <description>&lt;P&gt;unfortunately I'm unable to share that data.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 21:48:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623499#M216748</guid>
      <dc:creator>bt149</dc:creator>
      <dc:date>2022-12-06T21:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: spath field and value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623525#M216752</link>
      <description>&lt;P&gt;As &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;suggested, it is much easier for others to understand what you mean by using both text and sample data (anonymize as needed; some people just abstract with made-up fields). &amp;nbsp;If I have to read tea leaves, you have a JSON &lt;STRONG&gt;array&lt;/STRONG&gt;, each array element contains two &lt;U&gt;keys&lt;/U&gt;, one named "key" and the other "value", like&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;{"log": [{"key":"&lt;SPAN&gt;originid", "value":"12345"}, {"key":"origintype", "value":"BuiltInRole"}, ... ]}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;You want to pair the &lt;U&gt;values&lt;/U&gt; of "key" and "value", so you have&amp;nbsp;&lt;SPAN&gt;originid=12345,&amp;nbsp;origintype=BuiltInRole, and so on. &amp;nbsp;Is this correct? (It is important to confirm that they are in an array; otherwise the strategy would be different.)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This question gets asked often, in various forms, even recently. &amp;nbsp;But I cannot find that one at this time. &amp;nbsp;So, here we go one method using kv aka &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Extract" target="_blank" rel="noopener"&gt;extract&lt;/A&gt;:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval key_value = mvzip('log{}.key', 'log{}.value', "=") ``` pair values with = ```
| rename _raw as temp, key_value as _raw
| kv
| rename temp as _raw&lt;/LI-CODE&gt;&lt;P&gt;This is the test data I use&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;{"log":[{"key":"originid", "value":"12345"}, {"key":"origintype", "value":"BuiltInRole"}, {"key":"template", "value":"85750845e54"}, {"key":"starttime", "value":"2022-12-03T14:00:00:00.5661018Z"}, {"key":"endtime", "value":"2022-12-04T14:00:00:00.5661018Z"}, {"key":"justification", "value":"some reason to satisfy the justification"}]}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(I don't see any reason why you cannot share sample data like this.) &amp;nbsp;This is emulated with&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval _raw = "{\"log\":[{\"key\":\"originid\", \"value\":\"12345\"}, {\"key\":\"origintype\", \"value\":\"BuiltInRole\"}, {\"key\":\"template\", \"value\":\"85750845e54\"}, {\"key\":\"starttime\", \"value\":\"2022-12-03T14:00:00:00.5661018Z\"}, {\"key\":\"endtime\", \"value\":\"2022-12-04T14:00:00:00.5661018Z\"}, {\"key\":\"justification\", \"value\":\"some reason to satisfy the justification\"}]}"
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 06:50:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623525#M216752</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-12-07T06:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: spath field and value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623561#M216765</link>
      <description>&lt;P&gt;Here is a sample data for your review.&amp;nbsp; The posted solution did not produce any results.&amp;nbsp; I swapped out the "log" for what is in my logs, which is "additionalDetails."&lt;BR /&gt;&lt;BR /&gt;"additionalDetails": [{"key": "RoleDefinitionOriginId", "value": "65555555-69f5-4237-9190-012177145e10"}, {"key": "RoleDefinitionOriginType", "value": "BuiltInRole"}, {"key": "TemplateId", "value": "65555555-69f5-4237-9190-012177145e10"}, {"key": "StartTime", "value": "2022-12-03T03:38:14.3598981Z"}, {"key": "ExpirationTime", "value": "2022-12-03T11:38:14.3598981Z"}, {"key": "Justification", "value": "BAU activity"}]}}&lt;/P&gt;&lt;P&gt;Thanks for the help, it's very much appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 12:06:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623561#M216765</guid>
      <dc:creator>bt149</dc:creator>
      <dc:date>2022-12-07T12:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: spath field and value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623579#M216770</link>
      <description>&lt;P&gt;The goal is to take the information from the "additionalDetails" array (I think that's the term) and create new fields using the data in "key" and the value of the new fields would be the data in the "value" section of the log.&amp;nbsp; Hope this makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 13:46:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623579#M216770</guid>
      <dc:creator>bt149</dc:creator>
      <dc:date>2022-12-07T13:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to search spath field and value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623586#M216773</link>
      <description>&lt;P&gt;I was able to figure this out using the below spl:&lt;/P&gt;&lt;P&gt;index=myindex sourcetype=my_sourcetype&lt;BR /&gt;| fillnull value=na "properties.additionalDetails{}.key" "properties.additionalDetails{}.value"&lt;BR /&gt;| eval key_value = mvzip('properties.additionalDetails{}.key', 'properties.additionalDetails{}.value', "=")&lt;BR /&gt;| rename _raw as temp, key_value as _raw&lt;BR /&gt;| extract pairdelim="\n" kvdelim="="&lt;BR /&gt;| rename temp as _raw&lt;/P&gt;&lt;P&gt;Thanks to everyone who helped and pointed me in the right direction.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 14:05:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623586#M216773</guid>
      <dc:creator>bt149</dc:creator>
      <dc:date>2022-12-07T14:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to search spath field and value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623615#M216782</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/242392"&gt;@bt149&lt;/a&gt;&amp;nbsp;Glad you find solution to your problem! &amp;nbsp;A curtesy reminder: It is customary to credit the first comment that materially informs a custom SPL as solution, even if there are minor differences such as field names or a small manipulation that is not at the core of the original question.&lt;/P&gt;&lt;P&gt;By the way, when delimiter is equal sign (=), you don't need to explicitly specify kvdelim and pairdelim.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 17:37:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623615#M216782</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-12-07T17:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to search spath field and value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623622#M216783</link>
      <description>&lt;P&gt;Thanks for the information.&amp;nbsp; The spl only worked with the pairdelim and kvdelim in the spl.&amp;nbsp; Thanks again.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 17:56:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-spath-field-and-value-pairs/m-p/623622#M216783</guid>
      <dc:creator>bt149</dc:creator>
      <dc:date>2022-12-07T17:56:46Z</dc:date>
    </item>
  </channel>
</rss>

