<?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: similar field names function in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-quot-automate-quot-similar-field-names/m-p/612715#M213023</link>
    <description>&lt;P class="lia-align-left"&gt;I don't think that that is what I need. Stats are not good for my use case in that early stage.&lt;/P&gt;&lt;P class="lia-align-left"&gt;Basically, what I did with 15 evals is building an variable that is comma separated string as then it's makemv and mvexpand.&lt;BR /&gt;&lt;BR /&gt;As I need all this id0,id1,id2... expanded as id.&lt;BR /&gt;basically,&lt;BR /&gt;id0=0000, id1=1111, id2=2222,inN=NNNN,zone0=zone0,zone1=zone1,zone2=zone2,zoneN=zoneN&lt;BR /&gt;&lt;BR /&gt;That one event need's to become/expand to N events&lt;BR /&gt;--id---|--zone--&lt;BR /&gt;0000|zone0&lt;BR /&gt;1111|zone1&lt;BR /&gt;2222|zone2&lt;BR /&gt;NNNN|zoneN&lt;BR /&gt;&lt;BR /&gt;Now I can map and create automatic allowlist rule base on case if logic, logic is not that hard to write. End result is like.&lt;BR /&gt;"Allowlist id=" + id + " zone=" + zone + " URL=" + url ...&lt;/P&gt;</description>
    <pubDate>Mon, 12 Sep 2022 10:15:56 GMT</pubDate>
    <dc:creator>jbanAtSplunk</dc:creator>
    <dc:date>2022-09-12T10:15:56Z</dc:date>
    <item>
      <title>Is there a way to "automate" similar field names function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-quot-automate-quot-similar-field-names/m-p/612653#M213005</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Just curios if this is possible as I have interesting challenge.&lt;/P&gt;
&lt;P&gt;So, I have extracted fields, key=value&lt;/P&gt;
&lt;P&gt;id0=0000, id1=1111, id2=2222,inN=NNNN,zone0=zone0,zone1=zone1,zone2=zone2,zoneN=zoneN&lt;BR /&gt;Now I want to create new field that is like this just number AutoIncrements&lt;BR /&gt;| eval example0 = id0 + " location:" + zone0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My challenge is, how to make that more "automatic" as I don't know the number "N" in event and want to automate this new field so for every exampleN i have the same eval example.&lt;BR /&gt;I mean it'll be a little more complicated as I'll create some case statement in eval but inital challange is how to automate it on simpler just string scenario.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 03:09:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-quot-automate-quot-similar-field-names/m-p/612653#M213005</guid>
      <dc:creator>jbanAtSplunk</dc:creator>
      <dc:date>2022-09-12T03:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: similar field names function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-quot-automate-quot-similar-field-names/m-p/612667#M213011</link>
      <description>&lt;P&gt;Use foreach. This example demonstrates how to do it, you can run it in the search window, but the last line is the one you want.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
``` Create some dummy data with a random number of n ```
| eval n=mvrange(0, random() % 10, 1)
| mvexpand n
| eval id{n}=printf("%04d", random() % 10000), zone{n}=printf("zone%d", n)
``` Join all these values back to a single row ```
| stats values(*) as *
| fields - n
``` Now we have the dummy data, use foreach ```
| foreach id* [ eval "example&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;"='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'." location:".'zone&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;' ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Sep 2022 23:56:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-quot-automate-quot-similar-field-names/m-p/612667#M213011</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-09-11T23:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: similar field names function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-quot-automate-quot-similar-field-names/m-p/612668#M213012</link>
      <description>&lt;P&gt;This is one of the great things you can do, if you use a well defined field naming convention. As you can see in this example, the * in the foreach statement will 'capture' the matching part of the string, so 0, 1, 2 etc from the name of the id field.&lt;/P&gt;&lt;P&gt;This captured value is then substituted when the &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; operator is used.&lt;/P&gt;&lt;P&gt;Note that it is important to use single quotes round the right hand side of the eval statement fields, so it can handle field names containing odd characters - although not critical in your case, but a useful practice.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Sep 2022 23:59:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-quot-automate-quot-similar-field-names/m-p/612668#M213012</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-09-11T23:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: similar field names function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-quot-automate-quot-similar-field-names/m-p/612715#M213023</link>
      <description>&lt;P class="lia-align-left"&gt;I don't think that that is what I need. Stats are not good for my use case in that early stage.&lt;/P&gt;&lt;P class="lia-align-left"&gt;Basically, what I did with 15 evals is building an variable that is comma separated string as then it's makemv and mvexpand.&lt;BR /&gt;&lt;BR /&gt;As I need all this id0,id1,id2... expanded as id.&lt;BR /&gt;basically,&lt;BR /&gt;id0=0000, id1=1111, id2=2222,inN=NNNN,zone0=zone0,zone1=zone1,zone2=zone2,zoneN=zoneN&lt;BR /&gt;&lt;BR /&gt;That one event need's to become/expand to N events&lt;BR /&gt;--id---|--zone--&lt;BR /&gt;0000|zone0&lt;BR /&gt;1111|zone1&lt;BR /&gt;2222|zone2&lt;BR /&gt;NNNN|zoneN&lt;BR /&gt;&lt;BR /&gt;Now I can map and create automatic allowlist rule base on case if logic, logic is not that hard to write. End result is like.&lt;BR /&gt;"Allowlist id=" + id + " zone=" + zone + " URL=" + url ...&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 10:15:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-quot-automate-quot-similar-field-names/m-p/612715#M213023</guid>
      <dc:creator>jbanAtSplunk</dc:creator>
      <dc:date>2022-09-12T10:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: similar field names function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-quot-automate-quot-similar-field-names/m-p/612725#M213027</link>
      <description>&lt;P&gt;Sry, It's working. I needed only this ForEach command.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 10:55:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-quot-automate-quot-similar-field-names/m-p/612725#M213027</guid>
      <dc:creator>jbanAtSplunk</dc:creator>
      <dc:date>2022-09-12T10:55:41Z</dc:date>
    </item>
  </channel>
</rss>

