<?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: Set a field with a constant value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72353#M180932</link>
    <description>&lt;P&gt;This answer abore modifies the _raw data adding unwanted stuff not originally present.&lt;BR /&gt;
The right solution is in between:&lt;BR /&gt;
the transforms should be just something like&lt;BR /&gt;
transforms.conf:&lt;BR /&gt;
    [metrics]&lt;BR /&gt;
    REGEX = .&lt;BR /&gt;
    FORMAT = abc::xyz&lt;/P&gt;

&lt;P&gt;that's it.&lt;/P&gt;

&lt;P&gt;Marco&lt;/P&gt;</description>
    <pubDate>Wed, 20 Nov 2013 16:09:01 GMT</pubDate>
    <dc:creator>marcoscala</dc:creator>
    <dc:date>2013-11-20T16:09:01Z</dc:date>
    <item>
      <title>Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72348#M180927</link>
      <description>&lt;P&gt;In props.conf, I would like to create a field abc by saying:&lt;/P&gt;

&lt;P&gt;abc = "xyz".&lt;/P&gt;

&lt;P&gt;Is there any way to say this so that Splunk understands?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2011 23:47:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72348#M180927</guid>
      <dc:creator>mmather67</dc:creator>
      <dc:date>2011-09-08T23:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72349#M180928</link>
      <description>&lt;P&gt;Yes, props+transforms!&lt;/P&gt;

&lt;P&gt;cat inputs.conf &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:///Desktop/foobar.log]
disabled = false
followTail = 0
sourcetype=metrics
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cat props.conf &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[metrics]
TRANSFORMS-metrics=metrics
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cat transforms.conf &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[metrics]
DEST_KEY = _meta
REGEX = .
FORMAT =$0 abc::xyz
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will create field abc with value xyz.&lt;/P&gt;

&lt;P&gt;Cheers!&lt;BR /&gt;&lt;BR /&gt;
.gz&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2011 01:26:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72349#M180928</guid>
      <dc:creator>Genti</dc:creator>
      <dc:date>2011-09-09T01:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72350#M180929</link>
      <description>&lt;P&gt;I would not recommend creating an index-time field.  Rather I would recommend doing it at search-time and with a lookup.&lt;/P&gt;

&lt;P&gt;local/props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[metrics]
LOOKUP-metrics = keywords sourcetype OUTPUT abc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;local/transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[keywords]
filename = keywords.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;lookups/keywords.csv:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype,abc
metrics,xyz
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Sep 2011 21:26:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72350#M180929</guid>
      <dc:creator>araitz</dc:creator>
      <dc:date>2011-09-09T21:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72351#M180930</link>
      <description>&lt;P&gt;If you would, please accept one of the below answers or update the question with feedback as to why neither of them worked.  Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2011 20:30:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72351#M180930</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-10-21T20:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72352#M180931</link>
      <description>&lt;P&gt;Well, they may be correct but neither is appealing, so I have lost interest. I can't even remember why I asked in the first place.&lt;/P&gt;

&lt;P&gt;Sorry.&lt;/P&gt;

&lt;P&gt;But thanks anyway to the people who went to the trouble of answering.&lt;/P&gt;

&lt;P&gt;(Does this constitute the feedback you want, or should I have put it somewhere else? It is difficult to be polite in text.)&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2011 21:01:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72352#M180931</guid>
      <dc:creator>mmather67</dc:creator>
      <dc:date>2011-10-21T21:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72353#M180932</link>
      <description>&lt;P&gt;This answer abore modifies the _raw data adding unwanted stuff not originally present.&lt;BR /&gt;
The right solution is in between:&lt;BR /&gt;
the transforms should be just something like&lt;BR /&gt;
transforms.conf:&lt;BR /&gt;
    [metrics]&lt;BR /&gt;
    REGEX = .&lt;BR /&gt;
    FORMAT = abc::xyz&lt;/P&gt;

&lt;P&gt;that's it.&lt;/P&gt;

&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2013 16:09:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72353#M180932</guid>
      <dc:creator>marcoscala</dc:creator>
      <dc:date>2013-11-20T16:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72354#M180933</link>
      <description>&lt;P&gt;This is not an optimal solution from a performance or reliability perspective.  Splunk assumes that extracted field values (such as xyz above) exists in the raw data.  You can change this default behavior using fields.conf, but even then performance won't be very good.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2013 16:34:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72354#M180933</guid>
      <dc:creator>araitz</dc:creator>
      <dc:date>2013-11-20T16:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72355#M180934</link>
      <description>&lt;P&gt;Sorry, but why shouldn't be effective from a performance point of view? The REGEX is simple and matches immediately? And this solution was reported also on Splunk doc (&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.6/Admin/Transformsconf"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.6/Admin/Transformsconf&lt;/A&gt;) with this example of search time extraction:&lt;BR /&gt;
FORMAT = first::$1 second::$2 third::other-value&lt;/P&gt;

&lt;P&gt;BUT, to be honest, I was also trying to make it work and I didn't, and had to use a lookup-based solution similar to your suggestion. &lt;/P&gt;

&lt;P&gt;Marco&lt;/P&gt;

&lt;P&gt;PS: BTW, why didn't it work?!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2013 14:13:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72355#M180934</guid>
      <dc:creator>marcoscala</dc:creator>
      <dc:date>2013-11-28T14:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72356#M180935</link>
      <description>&lt;P&gt;If you mean create a field at search time, it's simple , use an eval, or to make it automatic define a calculated field.&lt;/P&gt;

&lt;P&gt;example :&lt;BR /&gt;
&lt;CODE&gt;&amp;lt;mysearch&amp;gt; | eval myfield="myvalue" | table _time myfield host source sourcetype _raw etc....&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;for calculated fields, look at this&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/definecalcfields"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/definecalcfields&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2013 17:08:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72356#M180935</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2013-11-28T17:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72357#M180936</link>
      <description>&lt;P&gt;I've found this transfom in "unix" app that sets a fixed value field based on a specific regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[userdel]
REGEX = .*?((?:remove|delete) (?:user|group|account)) .(\w+).
FORMAT = action::delete name::$1 user::$2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where the value of field "&lt;CODE&gt;action&lt;/CODE&gt;" is set to "&lt;CODE&gt;delete&lt;/CODE&gt;". So, in a similar way also my example should work.&lt;/P&gt;

&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2013 14:15:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72357#M180936</guid>
      <dc:creator>marcoscala</dc:creator>
      <dc:date>2013-12-11T14:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72358#M180937</link>
      <description>&lt;P&gt;Those docs are inaccurate.  As I mentioned, Splunk by default assumes that the value of the given field exists in the raw data.  If you don't change this behavior, Splunk will effectively be searching for a value that doesn't exist.  If you do change this behavior via fields.conf, those searches will be far slower.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2013 15:20:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72358#M180937</guid>
      <dc:creator>araitz</dc:creator>
      <dc:date>2013-12-11T15:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72359#M180938</link>
      <description>&lt;P&gt;Despite the OPs lack of interest in this question I have found your answer very useful.  This is exactly what I needed to do and having it happen at search time is ideal.  Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2015 14:51:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72359#M180938</guid>
      <dc:creator>dflodstrom</dc:creator>
      <dc:date>2015-03-26T14:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Set a field with a constant value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72360#M180939</link>
      <description>&lt;P&gt;This worked for me:&lt;/P&gt;

&lt;P&gt;[mysourcetype]&lt;BR /&gt;
EVAL-abc = "xyz"&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 17:38:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-a-field-with-a-constant-value/m-p/72360#M180939</guid>
      <dc:creator>pappjrcaa</dc:creator>
      <dc:date>2016-07-12T17:38:07Z</dc:date>
    </item>
  </channel>
</rss>

