Splunk Search

How to edit my search to allow filtering by date and time on a dashboard?

cdo_splunk
Splunk Employee
Splunk Employee

The search below works only in reports, not in dashboards

sourcetype=ped_venda_e_remessa_via_arq Tipo_Linha=WS |fields Num_Remessa |dedup Num_Remessa | mvcombine delim="," Num_Remessa |nomv Num_Remessa |eval searchquery="SELECT VBELN, COUNT(VBELN) AS CONTAGEM FROM SAPSR3.LIPS WHERE VBELN IN (".Num_Remessa.") GROUP BY VBELN ORDER BY VBELN" | map search="|dbxquery connection="SAP_PRD_DR" query=$searchquery$ shortnames=true" | join VBELN [search sourcetype=ped_venda_e_remessa_via_arq Tipo_Linha=WS | fields Num_Remessa | stats count by Num_Remessa | rename Num_Remessa AS VBELN]

My interpretation of the error:

The statement query=$searchquery$ works well in reports, because is correctly interpreted as a string variable.

The same statement in dashboards does not work, probably because is interpreted as an "input token"., so the dashboard gets frozen, awaiting for an data input before showing the results.

If I adapt my query to the proposed solution by Splunk (putting an input token by time), and inserting it in the dashboard as a "Search Report" my problem will persist in the dashboard:

The statement query=$searchquery$ will continue "awaiting for a data input" that does not exist

If I adapt my query to the proposed solution by Splunk (putting an input token by time), and inserting it in the dashboard as a "Report", The statement query=$searchquery$ will works well, but the statement with the "input token by time" will not be interpreted well, because the dashboard code will just calls the query name (not the statement in full), and the "input token by time" will not receive a proper value.

We need at least one of the two below
- A way to “Search Report” specific query works well in the dashboard; OR
- A way to “Report” specific query allows filtering by date/time in the dashboard

0 Karma
1 Solution

sundareshr
Legend

if you need a literal $ sign, you just put two consecutive $ signs $$. So your search will be

sourcetype=ped_venda_e_remessa_via_arq Tipo_Linha=WS |fields Num_Remessa |dedup Num_Remessa | mvcombine delim="," Num_Remessa |nomv Num_Remessa |eval searchquery="SELECT VBELN, COUNT(VBELN) AS CONTAGEM FROM SAPSR3.LIPS WHERE VBELN IN (".Num_Remessa.") GROUP BY VBELN ORDER BY VBELN" | map search="|dbxquery connection="SAP_PRD_DR" query=$$searchquery$$ shortnames=true" | join VBELN [search sourcetype=ped_venda_e_remessa_via_arq Tipo_Linha=WS | fields Num_Remessa | stats count by Num_Remessa | rename Num_Remessa AS VBELN]

View solution in original post

sundareshr
Legend

if you need a literal $ sign, you just put two consecutive $ signs $$. So your search will be

sourcetype=ped_venda_e_remessa_via_arq Tipo_Linha=WS |fields Num_Remessa |dedup Num_Remessa | mvcombine delim="," Num_Remessa |nomv Num_Remessa |eval searchquery="SELECT VBELN, COUNT(VBELN) AS CONTAGEM FROM SAPSR3.LIPS WHERE VBELN IN (".Num_Remessa.") GROUP BY VBELN ORDER BY VBELN" | map search="|dbxquery connection="SAP_PRD_DR" query=$$searchquery$$ shortnames=true" | join VBELN [search sourcetype=ped_venda_e_remessa_via_arq Tipo_Linha=WS | fields Num_Remessa | stats count by Num_Remessa | rename Num_Remessa AS VBELN]

View solution in original post

cdo_splunk
Splunk Employee
Splunk Employee

So far:
- The proposed query worked well in reports
- The proposed query worked well in dashboards without explicit time picker (just putting doubled symbol $)

When I add an Explicit Time Picker to the dashboard and associate it without each panel, the proposed query shows an error:

Error in 'map': Did not find value for required attribute 'searchquery'.

Remembering that when “searchquery string variable” assumes value between one $ symbol in the dashboard, It returns to the undesirable message “Search is waiting for input”

With double $$ applied to “searchquery string variable”, the query in dashboard works well without associated time picker, and starts presenting error when associate it to an explicit time picker

0 Karma
Did you miss .conf21 Virtual?

Good news! The event's keynotes and many of its breakout sessions are now available online, and still totally FREE!