<?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: Rename using wildcard in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197415#M39219</link>
    <description>&lt;P&gt;heh, beat me too it. But I would use this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;rex field=a_tmp "[^:]*:__ack_init":\s(?&amp;lt;acks&amp;gt;\d)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;To avoid picking up the other acks.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jan 2014 17:23:42 GMT</pubDate>
    <dc:creator>alacercogitatus</dc:creator>
    <dc:date>2014-01-07T17:23:42Z</dc:date>
    <item>
      <title>Rename using wildcard</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197411#M39215</link>
      <description>&lt;P&gt;I get some json-formatted logs, that I want to extract a field from. It looks something like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
    "ack-count": {
        "spout:__ack_init": 12,
        "bolt-one:__ack_ack": 6,
        "bolt-two:__ack_ack": 2,
        "bolt-three:__ack_ack": 4,
        "error-bolt:__ack_ack": 12
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to fetch the value of the field &lt;CODE&gt;ack-count.spout:__ack_init&lt;/CODE&gt;, here 12, and use it in some calculation. My problem is that I don't know the exact name a priori. I only know that it ends with &lt;CODE&gt;__ack_init&lt;/CODE&gt;, and lies within the field &lt;CODE&gt;ack-count&lt;/CODE&gt;. That is, it can be matched with &lt;CODE&gt;ack-count*__ack_init&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;So, what I wanted to do was something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rename ack-count*__ack_init AS acks
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But when I try that, I get the error&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'rename' command: Wildcard mismatch: 'ack-count*__ack_init' as 'acks'.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can anyone tell me how that might be?&lt;/P&gt;

&lt;P&gt;By the way, there might be more than one field like that, in which case I would like to sum them, before using them...&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2014 12:21:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197411#M39215</guid>
      <dc:creator>tbo</dc:creator>
      <dc:date>2014-01-07T12:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Rename using wildcard</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197412#M39216</link>
      <description>&lt;P&gt;Try doing it this way:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;your_search | spath path=ack-count output=a_tmp | rex field=a_tmp "[^:]*:__ack_init\":\s(?&amp;lt;acks&amp;gt;\d)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Spath takes your json and makes it a string, with which you can do a rex on.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2014 13:38:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197412#M39216</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2014-01-07T13:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Rename using wildcard</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197413#M39217</link>
      <description>&lt;P&gt;Thanks. But you have that word "spout" as part of your regex. And I can't be sure that will always be present. The field might be called &lt;CODE&gt;foo:__ack_init&lt;/CODE&gt;, in which case I suppose the search will fail?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2014 14:13:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197413#M39217</guid>
      <dc:creator>tbo</dc:creator>
      <dc:date>2014-01-07T14:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Rename using wildcard</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197414#M39218</link>
      <description>&lt;P&gt;try changing rex command above with this.&lt;/P&gt;

&lt;P&gt;| rex field=a_tmp "\"[^a-zA-Z_:]&lt;EM&gt;:\s&lt;/EM&gt;\"?(?&lt;ACKS&gt;\d*)"&lt;/ACKS&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:36:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197414#M39218</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T15:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Rename using wildcard</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197415#M39219</link>
      <description>&lt;P&gt;heh, beat me too it. But I would use this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;rex field=a_tmp "[^:]*:__ack_init":\s(?&amp;lt;acks&amp;gt;\d)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;To avoid picking up the other acks.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2014 17:23:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197415#M39219</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2014-01-07T17:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Rename using wildcard</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197416#M39220</link>
      <description>&lt;P&gt;Thanks man! Could you update your answer? Then I'll accept it.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2014 19:03:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197416#M39220</guid>
      <dc:creator>tbo</dc:creator>
      <dc:date>2014-01-07T19:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: Rename using wildcard</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197417#M39221</link>
      <description>&lt;P&gt;Is there a way to accomplish this same principle in a props file?  I've got JSON data that has a return{} field that has a big list of software that needs to be updated.  But splunk is auto extracting each software name out as part of the field name.  I want to do the same thing the OP did and rename all fields called Return* as something else.  Can this be done in a conf file?  Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 17:10:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Rename-using-wildcard/m-p/197417#M39221</guid>
      <dc:creator>ktwingstrom</dc:creator>
      <dc:date>2018-10-17T17:10:53Z</dc:date>
    </item>
  </channel>
</rss>

