Monitoring Splunk

Statistics table does not show results for valid search

jojopup123
Explorer

I set up a flexible Splunk dashboard that responds to 4 custom input fields:

1. clientType (text)

2. region (text)

3. report window (dropdown)

4. refresh interval (dropdown)

 

My base query is:

 

<search id="baseSearch">
    <query>index=myIndex $clientType$ region=$region$</query>
    <earliest>$reportWindow.earliest$</earliest>
    <latest>$reportWindow.latest$</latest>
    <refresh>$refreshInterval$</refresh>
    <refreshType>delay</refreshType>
</search>

 

 

Now, I want to create a new panel in the form of a statistics table based on the `baseSearch` query:

 

<search base="baseSearch">
    <query>search 
           | stats first(timestamp) as timestamp, first(applicationName) as applicationName, values(message) as message by entryKey
           | table timestamp, entryKey, applicationName, message
    </query>
    <refresh>$refreshInterval$</refresh>
    <refreshType>delay</refreshType>
</search>

 

 

However, the Splunk panel shows "No Results found". Yet, when I press "Open in Search", the Splunk query looks correct, and I can see results in a table in Splunk search.

Why doesn't the statistics table in the Splunk panel get populated in the same way?

Labels (1)
Tags (1)
0 Karma
1 Solution

dave_null
Path Finder

Ah sorry, it is <event> (not plural)

What are all the sections it is wrapped in? I may have a workaround but I don't know how it would interfere with your other XML

 

The workaround is to put a table into the base search, but leave the base search in a <event> section so that it saves the fields in the table, but does not display them as a table:

<search id="baseSearch">
  <query>index=myIndex $clientType$ region=$region$ | table timestamp applicationName message entryKey</query>
  <earliest>$reportWindow.earliest$</earliest>
  <latest>$reportWindow.latest$</latest>
  <refresh>$refreshInterval$</refresh>
  <refreshType>delay</refreshType>
</search>

 

View solution in original post

0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @jojopup123,

Did you try removing "search" term on your query?

  <panel>
      <table>
        <title>Reference Events</title>
        <search base="baseSearch">
          <query>
           | stats first(timestamp) as timestamp, first(applicationName) as applicationName, values(message) as message by entryKey
           | table timestamp, entryKey, applicationName, message
          </query>
          <refresh>$refreshInterval$</refresh>
          <refreshType>delay</refreshType>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </table>
    </panel>
If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

jojopup123
Explorer

Thanks for the suggestion, but unfortunately it seems like nothing has changed.

0 Karma

dave_null
Path Finder

Could you also post the base search XML, with sensitive information omitted?

0 Karma

jojopup123
Explorer

Here's the base search:

<search id="baseSearch">
  <query>index=myIndex $clientType$ region=$region$</query>
  <earliest>$reportWindow.earliest$</earliest>
  <latest>$reportWindow.latest$</latest>
  <refresh>$refreshInterval$</refresh>
  <refreshType>delay</refreshType>
</search>

 Here's an example of a (dummy) result you get if you "Open in Search" for the panel I was trying to create:

timestampentryKeyapplicationNamemessage
PST 2021-03-04 23:22:33,273JKHF96623JFPaymentAppSent payment to...

 

0 Karma

dave_null
Path Finder

Is the base search in an <events> xml section? The problem may be that the base search is doing a Fast search and not properly extracting the fields for the next search. When you press the "Open in Search" button, then Splunk combines the searches so that the baseSearch is required to find fields for the subsequent search.

0 Karma

jojopup123
Explorer

No, the search is not in an <events> section. 

I just tried wrapping it like so:

<events>
<search id="baseSearch">
  <query>index=myIndex $clientType$ region=$region$</query>
  <earliest>$reportWindow.earliest$</earliest>
  <latest>$reportWindow.latest$</latest>
  <refresh>$refreshInterval$</refresh>
  <refreshType>delay</refreshType>
</search>
<events>

but the console complained - "Unknown node "events". Node "events" is not allowed here".

0 Karma

dave_null
Path Finder

Ah sorry, it is <event> (not plural)

What are all the sections it is wrapped in? I may have a workaround but I don't know how it would interfere with your other XML

 

The workaround is to put a table into the base search, but leave the base search in a <event> section so that it saves the fields in the table, but does not display them as a table:

<search id="baseSearch">
  <query>index=myIndex $clientType$ region=$region$ | table timestamp applicationName message entryKey</query>
  <earliest>$reportWindow.earliest$</earliest>
  <latest>$reportWindow.latest$</latest>
  <refresh>$refreshInterval$</refresh>
  <refreshType>delay</refreshType>
</search>

 

0 Karma

jojopup123
Explorer

The workaround works for the statistics table. However, I have to adjust the other panels' XML...can you explain why we have to have it in a table first? Thanks

0 Karma

dave_null
Path Finder

I can't say for sure without seeing your full dashboard XML, but I believe it is because you aren't using the right tags. Are you nesting the search in a <table>?


For example:

<dashboard>
  <label>test_temp_delete_me</label>
  <init>
    <set token="clientType">something</set>
    <set token="reportWindow.earliest">-1h</set>
    <set token="reportWindow.latest">-5m</set>
    <set token="refreshInterval">5m</set>
  </init>
  <row>
    <panel>
      <table>
        <search id="baseSearch">
          <query>|makeresults | eval clientType = $clientType$,eval timestamp=50, applicationName="someapp", message= "somemessage", entryKey="somekey"</query>
    <earliest>$reportWindow.earliest$</earliest>
    <latest>$reportWindow.latest$</latest>
    <refresh>$refreshInterval$</refresh>
    <refreshType>delay</refreshType>
        </search>
      </table>
    </panel>
<panel>
  <table>
    <search base="baseSearch">
    <query> | stats first(timestamp) as timestamp, first(applicationName) as applicationName, values(message) as message by entryKey
           | table timestamp, entryKey, applicationName, message
    </query>
  </search>
  </table>
  </panel>
  </row>
</dashboard>
0 Karma

jojopup123
Explorer

Here's the XML for my table:

  <panel>
      <table>
        <title>Reference Events</title>
        <search base="baseSearch">
          <query>search 
           | stats first(timestamp) as timestamp, first(applicationName) as applicationName, values(message) as message by entryKey
           | table timestamp, entryKey, applicationName, message
          </query>
          <refresh>$refreshInterval$</refresh>
          <refreshType>delay</refreshType>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </table>
    </panel>

So it's nested in a <table>, yes

Tags (1)
0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...