<?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 do I move a string cat operation from the search and store it as an extracted field in events? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284110#M85869</link>
    <description>&lt;P&gt;Splunk Extracted Fields work on existing data they do not offer expression evaluations. If you want to move your above string concatenation to Knowledge Objects so that you don't have to write the extraction every time during search you should consider moving this to &lt;STRONG&gt;Settings --&amp;gt; Knowledge --&amp;gt; Calculated fields&lt;/STRONG&gt;, where you can write any valid evaluation expression.&lt;/P&gt;

&lt;P&gt;You would need to provide other details like your Destination Splunk app name, Sourcetype to apply eval expression, name of eval field and the eval expression. In your case&lt;/P&gt;

&lt;P&gt;Name= &lt;STRONG&gt;fields&lt;/STRONG&gt;&lt;BR /&gt;
Eval expression= &lt;STRONG&gt;subrackNo."-".SlotNo."-".boardType&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Once you do the above &lt;STRONG&gt;fields&lt;/STRONG&gt; field should be available under Interesting Fields, when the search is run in Smart or Verbose mode.&lt;/P&gt;

&lt;P&gt;PS: You should also make sure that you push only those eval expressions to Calculated Fields which are universal to your sourcetype, like your data contains &lt;STRONG&gt;bytes&lt;/STRONG&gt; field and all your report/dashboards show &lt;STRONG&gt;kilobyte&lt;/STRONG&gt;, then you would want to move the eval expression to Calculated fields i.e. &lt;STRONG&gt;eval kilobyte=round(bytes/1024,0)&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;In your case, if not all your dashboards use above string concatenation there is no point evaluating the same upfront through Calculated fields, when they are not going to be used in all of your searches. In other words, through Calculated fields, you pipe an additional eval expression to your existing base search. If left unused this will be an overhead in the SPL. So please think it over before creating a Calculated fields knowledge object.&lt;/P&gt;

&lt;P&gt;Also another thing to consider is the precedence of Calculated Fields&lt;/P&gt;

&lt;P&gt;1) search-time field extraction &lt;BR /&gt;
2) field aliasing&lt;BR /&gt;
3) Calculated Fields&lt;BR /&gt;
4) derivation of lookup fields.&lt;/P&gt;

&lt;P&gt;So, what it implies is that, Calculated fields can not be used on your lookup table fields. Refer to Splunk documentation on Calculated Fields: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.1/Knowledge/definecalcfields"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.1/Knowledge/definecalcfields&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Dec 2016 05:00:09 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2016-12-19T05:00:09Z</dc:date>
    <item>
      <title>How do I move a string cat operation from the search and store it as an extracted field in events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284107#M85866</link>
      <description>&lt;P&gt;&lt;STRONG&gt;How do I move a string cat operation from the search and store it in an extracted field option that Splunk offers under events?&lt;/STRONG&gt; This way the string cat won't appear in the search.&lt;/P&gt;

&lt;P&gt;I can use string cat to create my fields the way I want with this format &lt;CODE&gt;subrackNo "-" SlotNo "-" boardType&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | strcat subrackNo "-" SlotNo "-" boardType fields | timechart max(kpi) by fields
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And this give me this format&lt;BR /&gt;
    0-1-SPUb&lt;BR /&gt;&lt;BR /&gt;
    0-11-SPUb&lt;BR /&gt;
    0-16-GOUa&lt;/P&gt;

&lt;P&gt;THis is one of the rows from my data set:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-12-18 23:59:59,DeviceName=Device1,subrackNo=2,boardType=GOUc,SlotNo=23,SubsystemNo=1,CPUoccupancy=3,Throughputoccupancy=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now what I want to be able to do is do this in the extracted field option that splunk offers, so I don't have to do it in the search as I am doing with the string cat above. So this way my search could be like this with the string cat removed.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | timechart max(kpi) by fields&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;EDIT1&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;this might the path to take using regex -  &lt;A href="https://regex101.com/r/nPatfn/1"&gt;https://regex101.com/r/nPatfn/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 02:37:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284107#M85866</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2016-12-19T02:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I move a string cat operation from the search and store it as an extracted field in events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284108#M85867</link>
      <description>&lt;P&gt;Why Splunk has a separate  &lt;CODE&gt;strcat&lt;/CODE&gt; command, is beyond me... using &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/eval"&gt;eval&lt;/A&gt; you can use the concatenation operator and do the same like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval fields = subrackNo . "-" .  SlotNo . "-" . boardType | timechart max(kpi) by fields
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now with an eval expression you can instead define it as a &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.1/Knowledge/definecalcfields"&gt;calculated field&lt;/A&gt;. &lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 03:24:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284108#M85867</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2016-12-19T03:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I move a string cat operation from the search and store it as an extracted field in events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284109#M85868</link>
      <description>&lt;P&gt;tks, but I don't want the command to be in the search, if that makes sense. I want it to be a defined field. I think it can be done under event fields - extracted field. Just not sure. I have added a regex to try and demonstrate this in my question.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 04:10:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284109#M85868</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2016-12-19T04:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I move a string cat operation from the search and store it as an extracted field in events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284110#M85869</link>
      <description>&lt;P&gt;Splunk Extracted Fields work on existing data they do not offer expression evaluations. If you want to move your above string concatenation to Knowledge Objects so that you don't have to write the extraction every time during search you should consider moving this to &lt;STRONG&gt;Settings --&amp;gt; Knowledge --&amp;gt; Calculated fields&lt;/STRONG&gt;, where you can write any valid evaluation expression.&lt;/P&gt;

&lt;P&gt;You would need to provide other details like your Destination Splunk app name, Sourcetype to apply eval expression, name of eval field and the eval expression. In your case&lt;/P&gt;

&lt;P&gt;Name= &lt;STRONG&gt;fields&lt;/STRONG&gt;&lt;BR /&gt;
Eval expression= &lt;STRONG&gt;subrackNo."-".SlotNo."-".boardType&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Once you do the above &lt;STRONG&gt;fields&lt;/STRONG&gt; field should be available under Interesting Fields, when the search is run in Smart or Verbose mode.&lt;/P&gt;

&lt;P&gt;PS: You should also make sure that you push only those eval expressions to Calculated Fields which are universal to your sourcetype, like your data contains &lt;STRONG&gt;bytes&lt;/STRONG&gt; field and all your report/dashboards show &lt;STRONG&gt;kilobyte&lt;/STRONG&gt;, then you would want to move the eval expression to Calculated fields i.e. &lt;STRONG&gt;eval kilobyte=round(bytes/1024,0)&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;In your case, if not all your dashboards use above string concatenation there is no point evaluating the same upfront through Calculated fields, when they are not going to be used in all of your searches. In other words, through Calculated fields, you pipe an additional eval expression to your existing base search. If left unused this will be an overhead in the SPL. So please think it over before creating a Calculated fields knowledge object.&lt;/P&gt;

&lt;P&gt;Also another thing to consider is the precedence of Calculated Fields&lt;/P&gt;

&lt;P&gt;1) search-time field extraction &lt;BR /&gt;
2) field aliasing&lt;BR /&gt;
3) Calculated Fields&lt;BR /&gt;
4) derivation of lookup fields.&lt;/P&gt;

&lt;P&gt;So, what it implies is that, Calculated fields can not be used on your lookup table fields. Refer to Splunk documentation on Calculated Fields: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.1/Knowledge/definecalcfields"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.1/Knowledge/definecalcfields&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 05:00:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284110#M85869</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2016-12-19T05:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I move a string cat operation from the search and store it as an extracted field in events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284111#M85870</link>
      <description>&lt;P&gt;That's what I'm saying, you want to define a &lt;EM&gt;calculated&lt;/EM&gt; field, and step one of getting there is determining the eval expression to use. With this you define the calculated field, and then drop the eval expression from your searches, letting Splunk apply it for your sourcetype.&lt;/P&gt;

&lt;P&gt;For search time field extractions, you are not able to concatenate together disparate segments to make a single field ( &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Admin/Transformsconf"&gt;transforms.conf.spec&lt;/A&gt; says as much under the &lt;CODE&gt;FORMAT&lt;/CODE&gt; attribute ).&lt;/P&gt;

&lt;P&gt;If you do not want to use a calculated field, as they are all right next to eachother in your original data, you could extract the entire segment as a single field, but &lt;CODE&gt;subrackNo=2,boardType=GOUc,SlotNo=23&lt;/CODE&gt;is a lot more verbose than your desired format of &lt;CODE&gt;2-23-GOUc&lt;/CODE&gt;. A second option would be to create an index-time extraction for your field, where you could extract all segments and piece them together, but this could cause its own headaches as well.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 05:03:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284111#M85870</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2016-12-19T05:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I move a string cat operation from the search and store it as an extracted field in events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284112#M85871</link>
      <description>&lt;P&gt;tks for me it was settings - fields - calculated fileds. then like you say &lt;BR /&gt;
Name= fields&lt;BR /&gt;
Eval expression= subrackNo."-".SlotNo."-".boardType&lt;/P&gt;

&lt;P&gt;and had to seletect which source type to apply it to.&lt;/P&gt;

&lt;P&gt;This was slightly different than the way I thought I had to do it which was: &lt;BR /&gt;
Under the events tabs - select an event - event actions - extract fields. But this way way there is a regular expression or delimiter option, and that is probably not needed here as the fields are already there, I just want to cat them together.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 21:21:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-move-a-string-cat-operation-from-the-search-and-store/m-p/284112#M85871</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2016-12-19T21:21:03Z</dc:date>
    </item>
  </channel>
</rss>

