<?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 add string on a field value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320070#M163497</link>
    <description>&lt;P&gt;Query which I had provided was generating dummy data so you do not require first 4 lines from my query . Now based on query you have provided, you are not capturing regex output in any field, try something like this (But I am bit surprised that in chart command you are not using field &lt;CODE&gt;ROBOT&lt;/CODE&gt; then how can you use &lt;CODE&gt;ROBOT&lt;/CODE&gt; field in rex command after chart command ??&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=ROBOT "(?&amp;lt;extracted_field&amp;gt;(0\d+))" 
| eval extracted_field="Robot"." ".extracted_field 
| chart count(IDEVENT) as ERROR_QTY, values(extracted_field) as extracted_field by ERROR_DESC 
| sort ERROR_QTY DESC LIMIT=10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In above query 001, 002, 003 ... will store into new field called &lt;CODE&gt;extracted_field&lt;/CODE&gt; and after that we are concatenating &lt;CODE&gt;Robot&lt;/CODE&gt; with output value in that field. &lt;/P&gt;

&lt;P&gt;EDIT: Updated query.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jan 2018 04:42:03 GMT</pubDate>
    <dc:creator>harsmarvania57</dc:creator>
    <dc:date>2018-01-19T04:42:03Z</dc:date>
    <item>
      <title>How to add string on a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320067#M163494</link>
      <description>&lt;P&gt;Hi Guys!&lt;/P&gt;

&lt;P&gt;I am creating a table with number of errors per robot. The field values of these robots are "IGH2001", "IGH2002" and "IGH2003".&lt;BR /&gt;
I used a rex command and was able to extract the last 3 digits which are 001, 002 and 003.&lt;/P&gt;

&lt;P&gt;Now, I wanted to add "Robot" in front of the 3 digits to have field values of Robot 001 Robot 002 Robot 003.&lt;BR /&gt;
How can I do that?&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 03:54:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320067#M163494</guid>
      <dc:creator>auaave</dc:creator>
      <dc:date>2018-01-19T03:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to add string on a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320068#M163495</link>
      <description>&lt;P&gt;Hi @auaave,&lt;/P&gt;

&lt;P&gt;Can you please try something like this, first 4 lines used to generate dummy data only.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval field1="001"
| append [ | makeresults | eval field1="002"]
| append [ | makeresults | eval field1="003"]
| eval newfield="Robot"." ".field1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Jan 2018 04:04:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320068#M163495</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2018-01-19T04:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to add string on a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320069#M163496</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/163905"&gt;@harsmarvania57&lt;/a&gt;, thanks for your reply! Based on your input, I have written the code as per below. However, I am having this error "Error in 'makeresults' command: This command must be the first command of a search. "&lt;/P&gt;

&lt;P&gt;| chart count(IDEVENT) as ERROR_QTY by ERROR_DESC &lt;BR /&gt;
| rex field=ROBOT "(?(0\d+))" &lt;BR /&gt;
| makeresults &lt;BR /&gt;
| eval field1="001" &lt;BR /&gt;
| append &lt;BR /&gt;
    [| makeresults &lt;BR /&gt;
    | eval field1="002"] &lt;BR /&gt;
| append &lt;BR /&gt;
    [| makeresults &lt;BR /&gt;
    | eval field1="003"] &lt;BR /&gt;
| eval newfield="Robot"." ".field1 &lt;BR /&gt;
| sort ERROR_QTY DESC LIMIT=10&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:45:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320069#M163496</guid>
      <dc:creator>auaave</dc:creator>
      <dc:date>2020-09-29T17:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to add string on a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320070#M163497</link>
      <description>&lt;P&gt;Query which I had provided was generating dummy data so you do not require first 4 lines from my query . Now based on query you have provided, you are not capturing regex output in any field, try something like this (But I am bit surprised that in chart command you are not using field &lt;CODE&gt;ROBOT&lt;/CODE&gt; then how can you use &lt;CODE&gt;ROBOT&lt;/CODE&gt; field in rex command after chart command ??&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=ROBOT "(?&amp;lt;extracted_field&amp;gt;(0\d+))" 
| eval extracted_field="Robot"." ".extracted_field 
| chart count(IDEVENT) as ERROR_QTY, values(extracted_field) as extracted_field by ERROR_DESC 
| sort ERROR_QTY DESC LIMIT=10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In above query 001, 002, 003 ... will store into new field called &lt;CODE&gt;extracted_field&lt;/CODE&gt; and after that we are concatenating &lt;CODE&gt;Robot&lt;/CODE&gt; with output value in that field. &lt;/P&gt;

&lt;P&gt;EDIT: Updated query.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 04:42:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320070#M163497</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2018-01-19T04:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to add string on a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320071#M163498</link>
      <description>&lt;P&gt;@harsmarvia57, thanks a lot! the last one worked!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 05:13:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320071#M163498</guid>
      <dc:creator>auaave</dc:creator>
      <dc:date>2018-01-19T05:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to add string on a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320072#M163499</link>
      <description>&lt;P&gt;You're welcome.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 05:54:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-string-on-a-field-value/m-p/320072#M163499</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2018-01-19T05:54:36Z</dc:date>
    </item>
  </channel>
</rss>

