<?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 How do I pass a single value query output to a field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-pass-a-single-value-query-output-to-a-field/m-p/385155#M112467</link>
    <description>&lt;P&gt;I have a requirement to print the source count from how many hosts we are collecting.&lt;/P&gt;

&lt;P&gt;Expected output: &lt;STRONG&gt;source_count/host_count&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main | eval host_count=[ search index=main sourcetype=log1 | dedup host | stats dc(host) as Host_Count | return $Host_Count | eval source_count=[ search index=main sourcetype=log1 | dedup source | stats dc(source) as Source_Count | return Source_Count] | eval count=source_count + "/" + host_count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 21:59:25 GMT</pubDate>
    <dc:creator>twh1</dc:creator>
    <dc:date>2020-09-29T21:59:25Z</dc:date>
    <item>
      <title>How do I pass a single value query output to a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-pass-a-single-value-query-output-to-a-field/m-p/385155#M112467</link>
      <description>&lt;P&gt;I have a requirement to print the source count from how many hosts we are collecting.&lt;/P&gt;

&lt;P&gt;Expected output: &lt;STRONG&gt;source_count/host_count&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main | eval host_count=[ search index=main sourcetype=log1 | dedup host | stats dc(host) as Host_Count | return $Host_Count | eval source_count=[ search index=main sourcetype=log1 | dedup source | stats dc(source) as Source_Count | return Source_Count] | eval count=source_count + "/" + host_count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:59:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-pass-a-single-value-query-output-to-a-field/m-p/385155#M112467</guid>
      <dc:creator>twh1</dc:creator>
      <dc:date>2020-09-29T21:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a single value query output to a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-pass-a-single-value-query-output-to-a-field/m-p/385156#M112468</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=log1 
| stats dc(host) as Host_Count dc(source) as Source_Count 
| eval count=Source_Count + "/" + Host_Count 
| fields count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Nov 2018 17:42:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-pass-a-single-value-query-output-to-a-field/m-p/385156#M112468</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2018-11-14T17:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a single value query output to a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-pass-a-single-value-query-output-to-a-field/m-p/385157#M112469</link>
      <description>&lt;P&gt;Hi @kmaron &lt;BR /&gt;
I have two different query to fetch the data. I cann't get both count in same stats.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 17:49:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-pass-a-single-value-query-output-to-a-field/m-p/385157#M112469</guid>
      <dc:creator>twh1</dc:creator>
      <dc:date>2018-11-14T17:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a single value query output to a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-pass-a-single-value-query-output-to-a-field/m-p/385158#M112470</link>
      <description>&lt;P&gt;sorry. they look the same in your example. &lt;/P&gt;

&lt;P&gt;Try this instead then &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(first base search)
| stats dc(host) as Host_Count 
| append 
    [ search (second base search)
    | stats dc(source) as Source_Count 
    | fields Source_Count] 
| stats values(Host_Count) as Host_Count values(Source_Count) as Source_Count 
| eval count=Source_Count + "/" + Host_Count 
| fields count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Nov 2018 17:53:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-pass-a-single-value-query-output-to-a-field/m-p/385158#M112470</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2018-11-14T17:53:42Z</dc:date>
    </item>
  </channel>
</rss>

