<?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: extract key-value pairs that match or contain value, where keys vary across indices in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548233#M155502</link>
    <description>&lt;P&gt;Thanks, that is close to what is needed, but the fields for the various indexes seem mixed together.&lt;/P&gt;&lt;P&gt;Is it possible to add a column to show the index (and other fields eg sourcetype) next to the field?&lt;/P&gt;</description>
    <pubDate>Fri, 16 Apr 2021 14:55:10 GMT</pubDate>
    <dc:creator>alancalvitti</dc:creator>
    <dc:date>2021-04-16T14:55:10Z</dc:date>
    <item>
      <title>extract key-value pairs that match or contain value, where keys vary across indices</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548083#M155438</link>
      <description>&lt;P&gt;What's a scalable to extract key-value pairs where the value matches via exact or substring match but the field is not known ahead of time, and could be in _raw only?&lt;/P&gt;&lt;P&gt;Eg, search for the string "alan", which may be associated to fields as follows:&lt;/P&gt;&lt;P&gt;index=indexA&amp;nbsp; user=alan&lt;/P&gt;&lt;P&gt;index=indexB username=alan&lt;/P&gt;&lt;P&gt;index=indexC loginId=corp\alan&lt;/P&gt;&lt;P&gt;index=indexD&amp;nbsp; &amp;nbsp;_raw=&amp;lt;unstructured text, alan : user&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 19:49:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548083#M155438</guid>
      <dc:creator>alancalvitti</dc:creator>
      <dc:date>2021-04-15T19:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: extract key-value pairs that match or contain value, where keys vary across indices</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548189#M155484</link>
      <description>&lt;P&gt;Obviously, you could just add the keyword "alan" to your search to get the results you may want....but those may contain results you're not interested in.&lt;/P&gt;&lt;P&gt;i don't know if you would consider it scalable, but typically the approach i think is to normalize the data as you onboard it.&amp;nbsp; That could be with the Common Information Model app or just on your own.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, in the scenario above, for each of the sourcetypes, create a new field called username - either alias existing fields to username or extract/eval/etc username in the case that it's just in the raw data.&amp;nbsp; Once you have a username field across all sourcetypes, then just add username="alan" to your search.&lt;/P&gt;&lt;P&gt;If you find yourself onboarding a new sourcetype that contains a user that you want to search in a similar way, ensure a username field exists or is created.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 11:25:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548189#M155484</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2021-04-16T11:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: extract key-value pairs that match or contain value, where keys vary across indices</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548204#M155493</link>
      <description>&lt;P&gt;My fault for not being specific enough.:&lt;/P&gt;&lt;P&gt;First, We cannot normalize the data before onboarding as it reflects hundreds of sources including 3rd party vendors and other constraints.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second, I'm only looking to extract the&amp;nbsp; fields (keys) that match, no other fields (unless added optionally) - ideally avoiding rex as the index volumes are large and this query needs to be repeated 10k-100k times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 13:19:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548204#M155493</guid>
      <dc:creator>alancalvitti</dc:creator>
      <dc:date>2021-04-16T13:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: extract key-value pairs that match or contain value, where keys vary across indices</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548227#M155501</link>
      <description>&lt;P&gt;Ah ok.&amp;nbsp; I'm not sure how expensive it is, but i'm wondering if fieldsummary might be helpful here?&amp;nbsp; Something like this maybe?&amp;nbsp; I'm sure the match would need to be a bit more complicated....&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index IN (indexA,indexB,indexC) alan
| fieldsummary
| where match(values,"(?i)alan")&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;</description>
      <pubDate>Fri, 16 Apr 2021 14:40:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548227#M155501</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2021-04-16T14:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: extract key-value pairs that match or contain value, where keys vary across indices</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548233#M155502</link>
      <description>&lt;P&gt;Thanks, that is close to what is needed, but the fields for the various indexes seem mixed together.&lt;/P&gt;&lt;P&gt;Is it possible to add a column to show the index (and other fields eg sourcetype) next to the field?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 14:55:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548233#M155502</guid>
      <dc:creator>alancalvitti</dc:creator>
      <dc:date>2021-04-16T14:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: extract key-value pairs that match or contain value, where keys vary across indices</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548237#M155504</link>
      <description>&lt;P&gt;maybe someone else out here will have a better answer, but i can see maybe getting the index by using the map command....but if you don't know the sources/sourcetypes/etc, then that could get trickier.&amp;nbsp; But here is maybe the next step for your path.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This will create an event for each index and then use the map function to the same search over each, adding a field for index to the results.&amp;nbsp; I'm sure there is a way with tstats or eventcount to build the indexes/sourcetype you want and just expanding this.&amp;nbsp; Although, not sure how expensive this becomes either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count
| eval index=split("indexA,indexB,indexC",",")
| mvexpand index
| map search="search index=$index$ | fieldsummary | eval index=\"$index$\""&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 15:14:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548237#M155504</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2021-04-16T15:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: extract key-value pairs that match or contain value, where keys vary across indices</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548252#M155508</link>
      <description>&lt;P&gt;I'm not getting the same results w/ this version of the query.&amp;nbsp; &amp;nbsp;Although the index does show up, now the counts are way higher and many or most values seem not to match the user named before "| stats count"&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 15:48:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548252#M155508</guid>
      <dc:creator>alancalvitti</dc:creator>
      <dc:date>2021-04-16T15:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: extract key-value pairs that match or contain value, where keys vary across indices</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548254#M155509</link>
      <description>&lt;P&gt;well i did forget to the put the "alan" keyword back in the search - did you put it back in there?&amp;nbsp; If not, try adding it in the search in the map function.&amp;nbsp; And also i guess the where clause as well.&amp;nbsp; all of that needs to back into that search.....&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 15:55:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548254#M155509</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2021-04-16T15:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: extract key-value pairs that match or contain value, where keys vary across indices</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548259#M155510</link>
      <description>&lt;P&gt;i did add the user value at the beginning, but can't get it to work when reinserting the where clause. I tried putting it after the fieldsummary and after the last eval, - getting no results.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 16:18:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548259#M155510</guid>
      <dc:creator>alancalvitti</dc:creator>
      <dc:date>2021-04-16T16:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: extract key-value pairs that match or contain value, where keys vary across indices</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548267#M155514</link>
      <description>&lt;P&gt;friday firedrills over here.....can you just toss the where after the map command?&amp;nbsp; or it might helpful if you can share what you tried that failed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 17:27:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548267#M155514</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2021-04-16T17:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: extract key-value pairs that match or contain value, where keys vary across indices</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548313#M155524</link>
      <description>&lt;P&gt;ok...so I guess you didn't get that working then?&amp;nbsp; Here is an example of how maybe you could use tstats to get the index, source and sourcetypes.....just not sure if it will be too much for the map function.&amp;nbsp; But also including the where clause that you need - same as before, just have to escape the quotes.&amp;nbsp; But I'm still not sure what you tried that didn't work.....&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Not sure how many combinations of index/source/sourcetype you have, so you may need to bump up the maxsearches as well.&amp;nbsp; And if it is too much, I think you should know how to go back just using the index.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats count where index IN (indexA,indexB,indexC) by index source, sourcetype
| map maxsearches=100 search="search index=$index$ source=$source$ sourcetype=$sourcetype$ alan | fieldsummary | where match(values,\"(?i)alan\") | eval index=\"$index$\",source=\"$source$\",sourcetype=\"$sourcetype$\""&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Apr 2021 11:35:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548313#M155524</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2021-04-17T11:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: extract key-value pairs that match or contain value, where keys vary across indices</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548502#M155586</link>
      <description>&lt;P&gt;Thanks, - this tstats query seems to return results that contain the desired fields and values, but it also includes "false positive" values that don't include the query account.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, (and I'm having to copy/paste made up values here...) one statistic might say:&lt;/P&gt;&lt;P&gt;field count distinct_count index is_exact max mean min numeric_count sourcetype stdev values&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;event.Account_Name&lt;/TD&gt;&lt;TD&gt;11805&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;ad_index&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;ADindex&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;[{"value":"alan","count":8874},{"value":"bob","count":2931},]&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;There are typically other values (eg bob) other than the input query argument. For example, for the field avent.Account_Name , the "count" of 11805 is the sum of the individual "value" counts (alan 8874, bob 2931) in the "values" column.&amp;nbsp; How to interpret these results? Is it that alan matches 2931 events in which it shows up in a different field than event.Account_Name?&lt;/P&gt;&lt;P&gt;Also, what if the match is on the _raw event but not extracted in a kv field - would _raw be among the fields returned?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 20:57:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-key-value-pairs-that-match-or-contain-value-where-keys/m-p/548502#M155586</guid>
      <dc:creator>alancalvitti</dc:creator>
      <dc:date>2021-04-19T20:57:29Z</dc:date>
    </item>
  </channel>
</rss>

