<?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: Lookup table of key=value limits with a random assignment of key=value fields indicating consumption with different field names in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448151#M126993</link>
    <description>&lt;P&gt;My answer assumes that your lookup file looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;resources_available_queue_a,resources_available_queue_b,resources_available_queue_abtest,...
1000,23,123,...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it does not look like that you need to reformat it so that it does, then it will work.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Aug 2019 16:41:20 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-08-19T16:41:20Z</dc:date>
    <item>
      <title>Lookup table of key=value limits with a random assignment of key=value fields indicating consumption with different field names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448145#M126987</link>
      <description>&lt;P&gt;I have a lookup table that has information such as&lt;/P&gt;

&lt;P&gt;resources_available_queue_a=1000&lt;BR /&gt;
resources_available_queue_b=23&lt;BR /&gt;
resources_available_queue_abtest=123&lt;/P&gt;

&lt;P&gt;and so on, up to about 140 different queues.&lt;/P&gt;

&lt;P&gt;then I have thousands of events coming into an index with the following fields:&lt;/P&gt;

&lt;P&gt;Event1: resources_assigned_queue_a=883&lt;BR /&gt;
Event2: resources_assigned_queue_b=20&lt;/P&gt;

&lt;P&gt;I'm trying to take the lookup table as a capacity value and use resources assigned as a consumption value, but given the names are completely different and each event will only ever have 1 and I can't know ahead of time which one it will have, I'm struggling with the splunk logic to a join or a lookup to associate the fields in a consumed/capacity type output&lt;/P&gt;

&lt;P&gt;End goal is I'd like to have a timechart or even just a stats table showing percentages of resources consumed of the resources assigned for all the queues.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:45:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448145#M126987</guid>
      <dc:creator>mjones414</dc:creator>
      <dc:date>2020-09-30T01:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup table of key=value limits with a random assignment of key=value fields indicating consumption with different field names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448146#M126988</link>
      <description>&lt;P&gt;Can you change the lookup table into comma-separated values?  That's the format Splunk expects.&lt;/P&gt;

&lt;P&gt;Assuming you can do that, you then need to match up the resources names.  That's not so bad.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo 
| foreach resources_assigned_* [ eval resource=resource_available_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; 
  | lookup resources.csv resource output capacity | eval resourceUse = (&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; * 100) / capacity ] 
| table resource capacity resourceUse
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Aug 2019 17:20:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448146#M126988</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-08-15T17:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup table of key=value limits with a random assignment of key=value fields indicating consumption with different field names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448147#M126989</link>
      <description>&lt;P&gt;I think you've put me on the right track, but I haven't quite got it working.  For whatever reason it's saying it cannot match against my lookup table from inside of the subsearch.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;foo  | foreach resource_assigned_*  [ eval JobGroup ="resources_available_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;"  | lookup resource_groups.csv resources_available_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; as JobGroup OUTPUT "resources_available_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;" AS Capacity ] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can verify that there is an exact match of the resource group name in the lookup table and that the JobGroup field is being created with a string that matches whats inside the lookup table.  Its as if lookup is taking MATCHSTR literally instead of using it as a token for foreach.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 19:51:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448147#M126989</guid>
      <dc:creator>mjones414</dc:creator>
      <dc:date>2019-08-16T19:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup table of key=value limits with a random assignment of key=value fields indicating consumption with different field names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448148#M126990</link>
      <description>&lt;P&gt;I have also tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    foreach resources_assigned_*  [ eval resources_available_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; = &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; | lookup resource_groups.csv resources_available_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; OUTPUT resources_available_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; AS Capacity   ] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The lookup table's structure is like this:&lt;/P&gt;

&lt;P&gt;resources_available_Queue_A,resources_available_Queue_B&lt;BR /&gt;
29,100&lt;/P&gt;

&lt;P&gt;Unfortunately not like:&lt;BR /&gt;
Resource_Limits,Value&lt;BR /&gt;
resources_available_Queue_A,29&lt;BR /&gt;
resources_available_Queue_B,100&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:47:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448148#M126990</guid>
      <dc:creator>mjones414</dc:creator>
      <dc:date>2020-09-30T01:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup table of key=value limits with a random assignment of key=value fields indicating consumption with different field names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448149#M126991</link>
      <description>&lt;P&gt;Hold on to your britches!  Put your "table" into a lookup file and then try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Your Search Here&amp;gt;
| stats [|inputlookup &amp;lt;Your Lookup File Here&amp;gt;
| untable foo name value
| eval function = name
| table function name
| format "" "" ")" "" "" ""
| rex field=search mode=sed "s/  function=/max(/g s/name=/AS curr_/g s/\"//g s/ \)/)/g"]
| inputlookup append=t &amp;lt;Your Lookup File Here&amp;gt;
| eval foo="bar"
| selfjoin foo
| fields - foo
| foreach curr_* [ eval pct_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; = 100 * curr_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; / &amp;lt;&amp;lt;MATCSTR&amp;gt;&amp;gt; ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You might swap &lt;CODE&gt;max&lt;/CODE&gt; for &lt;CODE&gt;avg&lt;/CODE&gt; or &lt;CODE&gt;first&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 01:27:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448149#M126991</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-17T01:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup table of key=value limits with a random assignment of key=value fields indicating consumption with different field names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448150#M126992</link>
      <description>&lt;P&gt;Your lookup table is not in the proper format, which is why Splunk is not able to find what it's looking for.  See @woodcock's answer for a workaround or re-format resource_groups.csv.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 12:35:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448150#M126992</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-08-19T12:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup table of key=value limits with a random assignment of key=value fields indicating consumption with different field names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448151#M126993</link>
      <description>&lt;P&gt;My answer assumes that your lookup file looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;resources_available_queue_a,resources_available_queue_b,resources_available_queue_abtest,...
1000,23,123,...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it does not look like that you need to reformat it so that it does, then it will work.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 16:41:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448151#M126993</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-19T16:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup table of key=value limits with a random assignment of key=value fields indicating consumption with different field names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448152#M126994</link>
      <description>&lt;P&gt;@mjones414 Come back and click &lt;CODE&gt;Accept&lt;/CODE&gt;.  You have several answers.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 14:33:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448152#M126994</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-29T14:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup table of key=value limits with a random assignment of key=value fields indicating consumption with different field names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448153#M126995</link>
      <description>&lt;P&gt;Thank you so much!  This did get me the results I needed.  Sorry for the very late acceptance!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2019 22:27:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-table-of-key-value-limits-with-a-random-assignment-of-key/m-p/448153#M126995</guid>
      <dc:creator>mjones414</dc:creator>
      <dc:date>2019-09-09T22:27:05Z</dc:date>
    </item>
  </channel>
</rss>

