<?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 assign a string value from a subsearch to a eval which should map to all the events? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345462#M102355</link>
    <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval tag = SvcTag | return $tag ]
↓
| eval tag = "\""+SvcTag+"\"" | return $tag ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 14 Dec 2017 11:10:55 GMT</pubDate>
    <dc:creator>HiroshiSatoh</dc:creator>
    <dc:date>2017-12-14T11:10:55Z</dc:date>
    <item>
      <title>How to assign a string value from a subsearch to a eval which should map to all the events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345459#M102352</link>
      <description>&lt;P&gt;I am trying to extract a value and add it to every events of that sourcetype.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="c:\\splunk monitors\\log(2).txt"  | eval ServiceTag = [search source="c:\\splunk monitors\\log(2).txt" | head 1 |  rex field=_raw "^[^\[\n]*\[(?P&amp;lt;SvcTag&amp;gt;[^\]]+)" | eval tag = SvcTag | return $tag ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here $tag returns 5Q4RZH2 which is a string and thus, it is not able to get stored in ServiceTag variable of eval.&lt;BR /&gt;
If the tag would have returned some number such as "123" then it is able to store the same. &lt;BR /&gt;
E.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    source="c:\\splunk monitors\\log(2).txt"  | eval ServiceTag = [search source="c:\\splunk monitors\\log(2).txt" | head 1 |  rex field=_raw "^[^\[\n]*\[(?P&amp;lt;SvcTag&amp;gt;[^\]]+)" | eval tag = "123"| return $tag ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this scenario, &lt;STRONG&gt;ServiceTag&lt;/STRONG&gt; has the value 123 &lt;BR /&gt;
Hence, it is getting difficult to store a string.&lt;/P&gt;

&lt;P&gt;Can someone please solve?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 10:19:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345459#M102352</guid>
      <dc:creator>sudeshna_dash</dc:creator>
      <dc:date>2017-12-14T10:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a string value from a subsearch to a eval which should map to all the events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345460#M102353</link>
      <description>&lt;P&gt;Try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="c:\\splunk monitors\\log(2).txt"  | eval ServiceTag =case( [search source="c:\\splunk monitors\\log(2).txt" | head 1 |  rex field=_raw "^[^\[\n]*\[(?P&amp;lt;SvcTag&amp;gt;[^\]]+)" | eval tag = SvcTag | return 10000 tag ],tag)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 10:31:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345460#M102353</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2017-12-14T10:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a string value from a subsearch to a eval which should map to all the events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345461#M102354</link>
      <description>&lt;P&gt;Thanks @mayurr98 but this doesn't solve the problem&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 10:41:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345461#M102354</guid>
      <dc:creator>sudeshna_dash</dc:creator>
      <dc:date>2017-12-14T10:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a string value from a subsearch to a eval which should map to all the events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345462#M102355</link>
      <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval tag = SvcTag | return $tag ]
↓
| eval tag = "\""+SvcTag+"\"" | return $tag ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Dec 2017 11:10:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345462#M102355</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2017-12-14T11:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a string value from a subsearch to a eval which should map to all the events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345463#M102356</link>
      <description>&lt;P&gt;@sudeshna_dash, are you doing it in a dashboard? Can you add some sample data and post the example above using code button?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 11:24:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345463#M102356</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-12-14T11:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a string value from a subsearch to a eval which should map to all the events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345464#M102357</link>
      <description>&lt;P&gt;Thanks a lot @HiroshiSatoh, this worked. I am grateful to u&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 14:38:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-string-value-from-a-subsearch-to-a-eval-which/m-p/345464#M102357</guid>
      <dc:creator>sudeshna_dash</dc:creator>
      <dc:date>2017-12-15T14:38:29Z</dc:date>
    </item>
  </channel>
</rss>

