<?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 Stats count query across possible fields from multiple sources? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-query-across-possible-fields-from-multiple-sources/m-p/467491#M131568</link>
    <description>&lt;P&gt;I am trying to create an alert but some issues with logging that is not standard, so each sourcetype has it's own certain fieldname for error levels (e.g. type), and another certain fieldname for their error message (e.g. msg, or Massage)... in other words, I know the possible field values common across sourcetypes and eventually wanting to timechart or stat to cover all possible fields regardless of data source&lt;/P&gt;
&lt;P&gt;This still does not work and if a certain field does not exist, all results will be null. any ideas or a different way to do it?&lt;/P&gt;
&lt;P&gt;My query: index=t sourcetype=* (type=error OR T=error OR Level=Critical) (msg=* OR MSG=* OR Message=* OR message=* OR reason=*) |eval MM=msg."&lt;EM&gt;".MSGmsg."&lt;/EM&gt;".Message."&lt;EM&gt;".message."&lt;/EM&gt;".reason|timechart count by MM&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jun 2020 18:11:34 GMT</pubDate>
    <dc:creator>spark2310</dc:creator>
    <dc:date>2020-06-08T18:11:34Z</dc:date>
    <item>
      <title>Stats count query across possible fields from multiple sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-query-across-possible-fields-from-multiple-sources/m-p/467491#M131568</link>
      <description>&lt;P&gt;I am trying to create an alert but some issues with logging that is not standard, so each sourcetype has it's own certain fieldname for error levels (e.g. type), and another certain fieldname for their error message (e.g. msg, or Massage)... in other words, I know the possible field values common across sourcetypes and eventually wanting to timechart or stat to cover all possible fields regardless of data source&lt;/P&gt;
&lt;P&gt;This still does not work and if a certain field does not exist, all results will be null. any ideas or a different way to do it?&lt;/P&gt;
&lt;P&gt;My query: index=t sourcetype=* (type=error OR T=error OR Level=Critical) (msg=* OR MSG=* OR Message=* OR message=* OR reason=*) |eval MM=msg."&lt;EM&gt;".MSGmsg."&lt;/EM&gt;".Message."&lt;EM&gt;".message."&lt;/EM&gt;".reason|timechart count by MM&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 18:11:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-count-query-across-possible-fields-from-multiple-sources/m-p/467491#M131568</guid>
      <dc:creator>spark2310</dc:creator>
      <dc:date>2020-06-08T18:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Stats count query across possible fields from multiple sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-query-across-possible-fields-from-multiple-sources/m-p/467492#M131569</link>
      <description>&lt;P&gt;Concatenation will not solve that problem.  You want the &lt;CODE&gt;coalesce&lt;/CODE&gt; function.  It chooses the first non-null field from its arguments as its result, which is exactly what you need when some fields are present in some events, but not others.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=t sourcetype= (type=error OR T=error OR Level=Critical) (msg= OR MSG= OR Message= OR message= OR reason=) 
|eval MM=coalesce(msg,  MSGmsg, Message, message, reason) 
|timechart count by MM
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 May 2020 12:44:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-count-query-across-possible-fields-from-multiple-sources/m-p/467492#M131569</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-05-30T12:44:40Z</dc:date>
    </item>
  </channel>
</rss>

