<?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 use same field with same value to get result from two different sourcetype? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92121#M19142</link>
    <description>&lt;P&gt;I did make some mistakes, but I don't know what it is now. Actually yours works well.XD&lt;/P&gt;</description>
    <pubDate>Sat, 12 Oct 2013 01:32:26 GMT</pubDate>
    <dc:creator>titanwss</dc:creator>
    <dc:date>2013-10-12T01:32:26Z</dc:date>
    <item>
      <title>How to use same field with same value to get result from two different sourcetype?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92116#M19137</link>
      <description>&lt;P&gt;sample data like followed.&lt;BR /&gt;&lt;BR /&gt;
sourcetype A (like access log):&lt;BR /&gt;&lt;BR /&gt;
&lt;CODE&gt;clientip uri_path  status other fields....&lt;BR /&gt;
10.0.0.1 /bar.html 200    ...&lt;BR /&gt;
10.0.0.2 /admin/   200    ...&lt;/CODE&gt;   &lt;/P&gt;

&lt;P&gt;sourcetype B (like security audit log):&lt;BR /&gt;&lt;BR /&gt;
&lt;CODE&gt;clientip    uri_path  status other fields....&lt;BR /&gt;
192.168.0.1 /foo.html 403    ...&lt;BR /&gt;
192.168.1.1 /admin/   403    ...&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;These sourcetypes have three same fields. I just want get the result like&lt;BR /&gt;&lt;BR /&gt;
&lt;CODE&gt;clientip    uri_path statusB statusA&lt;BR /&gt;
192.168.1.1 /admin/  403     200&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;
To find out if uri_path in sourcetype B is existed(200)&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2013 06:55:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92116#M19137</guid>
      <dc:creator>titanwss</dc:creator>
      <dc:date>2013-10-10T06:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use same field with same value to get result from two different sourcetype?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92117#M19138</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;You can get this by several ways, but i think that the best performance would be something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="A" OR sourcetype="B" | stats values(statusB), values(statusA) by clientip, uri_path
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Other way would be using the join command, but i think it is worse from a performance point of view&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2013 07:55:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92117#M19138</guid>
      <dc:creator>gfuente</dc:creator>
      <dc:date>2013-10-10T07:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to use same field with same value to get result from two different sourcetype?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92118#M19139</link>
      <description>&lt;P&gt;Thanks for your reply. I've tried what you said, but it return nothing. Finally, I use append and distinct_count command to deal with it.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2013 09:43:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92118#M19139</guid>
      <dc:creator>titanwss</dc:creator>
      <dc:date>2013-10-11T09:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to use same field with same value to get result from two different sourcetype?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92119#M19140</link>
      <description>&lt;P&gt;The append command can be useful in some scenarios.&lt;BR /&gt;&lt;BR /&gt;
&lt;EM&gt;But&lt;/EM&gt; generally you'll get better performance (and not be restricted by result limits associated with the append command) if you use one all-encompassing base search.  &lt;/P&gt;

&lt;P&gt;Using the example in your original question, it would look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=A OR sourcetype=B | eval status{sourcetype}=status | stats count(status*) by clientip uri_path
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The status{sourcetype} will actually create distinct fields based on your sourcetype name.  In the above example, it would create a field called &lt;STRONG&gt;statusA&lt;/STRONG&gt; for events with sourcetype of A and a field called &lt;STRONG&gt;statusB&lt;/STRONG&gt; for events having a sourcetype of B.  The status* (in the stats command) includes both of those.  Using these techniques, we can expand the base search with additional sourcetypes and not have to worry about updating our search downstream to take advantage of that expansion.  &lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2013 11:20:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92119#M19140</guid>
      <dc:creator>bwooden</dc:creator>
      <dc:date>2013-10-11T11:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to use same field with same value to get result from two different sourcetype?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92120#M19141</link>
      <description>&lt;P&gt;reading your original question again, you may actually want this search (replacing count with values) --&amp;gt;  sourcetype=A OR sourcetype=B | eval status{sourcetype}=status | stats values(status*) by clientip uri_path&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2013 11:22:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92120#M19141</guid>
      <dc:creator>bwooden</dc:creator>
      <dc:date>2013-10-11T11:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to use same field with same value to get result from two different sourcetype?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92121#M19142</link>
      <description>&lt;P&gt;I did make some mistakes, but I don't know what it is now. Actually yours works well.XD&lt;/P&gt;</description>
      <pubDate>Sat, 12 Oct 2013 01:32:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92121#M19142</guid>
      <dc:creator>titanwss</dc:creator>
      <dc:date>2013-10-12T01:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use same field with same value to get result from two different sourcetype?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92122#M19143</link>
      <description>&lt;P&gt;The status{sourcetype} seems to be very useful. There must be something wrong in my search. Thanks for telling these techniques.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Oct 2013 01:56:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-same-field-with-same-value-to-get-result-from-two/m-p/92122#M19143</guid>
      <dc:creator>titanwss</dc:creator>
      <dc:date>2013-10-12T01:56:50Z</dc:date>
    </item>
  </channel>
</rss>

