<?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: How to extract a field name and add it to a fixed string? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233250#M69239</link>
    <description>&lt;P&gt;I should have included this in my question. Renaming is not an option because I have thousands of steps. The raw data only has one timestamp at the beginning of the file and that's the reason why I didn't divide the file in multiple events. Also I need these fieldnames to be a fix name for all search.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Nov 2015 16:41:07 GMT</pubDate>
    <dc:creator>edrivera3</dc:creator>
    <dc:date>2015-11-12T16:41:07Z</dc:date>
    <item>
      <title>How to extract a field name and add it to a fixed string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233247#M69236</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;How can I extract these fieldnames and values from this event?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Step: 0345
Result: Valid
Step: 3345
Result: Valid
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Field names and values:&lt;BR /&gt;
 1. Field Name: test_0345, Field Value: Valid&lt;BR /&gt;
 2. Field Name: test_3345, Field Value: Valid&lt;/P&gt;

&lt;P&gt;I already know how to extract both the name and value, but I don't know how to add "test_" before all extracted field names. &lt;/P&gt;

&lt;P&gt;Edit (more info):&lt;BR /&gt;
The raw data has only one timestamp and it is located at the beginning of the file. This the reason why I didn't divide the file in multiple events.&lt;BR /&gt;
I have events with thousands fields so renaming is not option.&lt;/P&gt;

&lt;P&gt;At this moment, the fields look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1350=Valid
2342=Valid
2345=Failed
2341=Valid
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm looking for a solution using transforms.conf and props.conf so these fields will be available for all search in this sourcetype.&lt;/P&gt;

&lt;P&gt;My current transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; REGEX=(?ms)^Step:\s*([^\r\n]+)[\r\n]+(.*?)(?=\Z|[\r\n]+Step:)
 CLEAN_KEYS = false
 FORMAT = $1::$2
 MV_ADD = 1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:54:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233247#M69236</guid>
      <dc:creator>edrivera3</dc:creator>
      <dc:date>2020-09-29T07:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field name and add it to a fixed string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233248#M69237</link>
      <description>&lt;P&gt;One quick way would be to re-name  the fields after you have them extracted..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.. | rename 0345 AS test_0345 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This isnt so efficient with large number of fields though. You can also do &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.. | rename 0* AS test_0* | ..
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can wildcard match on field names. However, we cant match on regex patterns that Im aware off. So you would need to iterate through the number patterns of your fields to get this for all fields. Which again, is time consuming if you have a large number of fields..&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 01:59:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233248#M69237</guid>
      <dc:creator>esix_splunk</dc:creator>
      <dc:date>2015-11-12T01:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field name and add it to a fixed string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233249#M69238</link>
      <description>&lt;P&gt;Assuming that you have fields called &lt;CODE&gt;Step&lt;/CODE&gt; and &lt;CODE&gt;Result&lt;/CODE&gt;, this should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Step = "test_" . Step | eval {Step} = Result | fields - Step Result
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Nov 2015 16:36:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233249#M69238</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-12T16:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field name and add it to a fixed string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233250#M69239</link>
      <description>&lt;P&gt;I should have included this in my question. Renaming is not an option because I have thousands of steps. The raw data only has one timestamp at the beginning of the file and that's the reason why I didn't divide the file in multiple events. Also I need these fieldnames to be a fix name for all search.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 16:41:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233250#M69239</guid>
      <dc:creator>edrivera3</dc:creator>
      <dc:date>2015-11-12T16:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field name and add it to a fixed string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233251#M69240</link>
      <description>&lt;P&gt;I updated the question with more information.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 16:55:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233251#M69240</guid>
      <dc:creator>edrivera3</dc:creator>
      <dc:date>2015-11-12T16:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field name and add it to a fixed string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233252#M69241</link>
      <description>&lt;P&gt;Because &lt;CODE&gt;calculated fields&lt;/CODE&gt; happen last, you should be able to put this inside your &lt;CODE&gt;props.conf&lt;/CODE&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EVAL-Step = "test_" . Step | eval {Step} = Result
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Nov 2015 17:16:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233252#M69241</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-12T17:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field name and add it to a fixed string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233253#M69242</link>
      <description>&lt;P&gt;But I don't have a field called result. I only have fields called 1234,1235,1236, etc. I can't divide the capturing in two fields because there is more information that just the "Valid or Failed" status. As you can see in the regex everything between "Step" words is captured. If I divide the fields I might end up with steps with wrong values or with multiple values.&lt;/P&gt;

&lt;P&gt;Right now I am looking at the documentation and I see that there is way to concatenate a fix string using FORMAT.&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1/admin/Transformsconf"&gt;http://docs.splunk.com/Documentation/Splunk/6.1/admin/Transformsconf&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I have tried the following FORMAT but I haven't been successful:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;FORMAT = step_$1::$2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Nov 2015 17:30:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233253#M69242</guid>
      <dc:creator>edrivera3</dc:creator>
      <dc:date>2015-11-12T17:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field name and add it to a fixed string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233254#M69243</link>
      <description>&lt;P&gt;It is not possible to concatenated fields with Format at search time:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;NOTE: You cannot create concatenated fields with FORMAT at search time. That 
      functionality is only available at index time.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Nov 2015 17:38:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233254#M69243</guid>
      <dc:creator>edrivera3</dc:creator>
      <dc:date>2015-11-12T17:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field name and add it to a fixed string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233255#M69244</link>
      <description>&lt;P&gt;Right, change to this and then it should all work (but you will have "extra" fields as a result):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  FORMAT = Step::$1 Result::$2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Nov 2015 17:43:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233255#M69244</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-12T17:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field name and add it to a fixed string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233256#M69245</link>
      <description>&lt;P&gt;I managed to capture the two fields with &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;FORMAT = Step::$1 Result::$2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but when I added:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EVAL-Step = "test_" . Step | eval {Step} = Result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I don't see any fields. If I changed the previous EVAL to REPORT like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Report-step_num = step_num  #step_num is the name of the stanza
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I see both fields, so there is a problem with the EVAL.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 21:05:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233256#M69245</guid>
      <dc:creator>edrivera3</dc:creator>
      <dc:date>2015-11-12T21:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field name and add it to a fixed string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233257#M69246</link>
      <description>&lt;P&gt;The syntax is special and needs the pipe, either one of which may not be supported by &lt;CODE&gt;calculated fields&lt;/CODE&gt; so you will have to experiment.  You may end up having to do the last steps at search-time.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2015 15:17:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-name-and-add-it-to-a-fixed-string/m-p/233257#M69246</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-13T15:17:04Z</dc:date>
    </item>
  </channel>
</rss>

