Splunk Search

Time comparison different results in search and dashboar

Ste
Path Finder

Dear experts

Why is the following line

 

| where my_time>=relative_time(now(),"-1d@d") AND my_time<=relative_time(now(),"@d")

 

Accepted as a valid statement in a search window, but as soon I want to use exactly this code in a dashboard, I get the error message: "Error in line 100: Unencoded <" ?

The dashboard code validator somehow fails with the <= comparison. 

>= works, as well = but not <= 

We're on splunkcloud. 

0 Karma
1 Solution

luizlimapg
Path Finder

Hi @Ste, how are you?

Is &gt; for >
Your SPL is using &gr; instead.

 

| where my_time&gt;=relative_time(now(),"-1d@d") AND my_time&lt;=relative_time(now(),"@d")

 

 

View solution in original post

luizlimapg
Path Finder

Hi @Ste, how are you?

Is &gt; for >
Your SPL is using &gr; instead.

 

| where my_time&gt;=relative_time(now(),"-1d@d") AND my_time&lt;=relative_time(now(),"@d")

 

 

yuanliu
SplunkTrust
SplunkTrust

@luizlimapg is correct.  If you copy and paste your search into Simple XML code window (or Dashboard Studio code window for that matter), some special characters will be interpreted by the XML engine (or the JSON engine).  If you need to do that, use HTML entities to represent these special characters.

It is best to avoid this, however.  If you have a panel, copy and paste your search code into the Search popup. (Similarly in the search box under Input.)

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Ste ,

in dashboards, you cannot use <> and you have to replace them with &lt; and &gt;

| where my_time&gr;=relative_time(now(),"-1d@d") AND my_time&lt;=relative_time(now(),"@d")

Ciao.

giuseppe

Ste
Path Finder

Using the html tags from your proposal would lead into the error message "Error in Line 100: Invalid character entity"

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Ste ,

Please share the code of your dashboard with the error using the "Insert/Edit Code Cample" button.

Ciao.

Giuseppe

0 Karma

Ste
Path Finder

Gentlemen you're right

Search code:

 

| where my_time>=relative_time(now(),"-1d@d") AND _time<=relative_time(now(),"@d")

 

updated to 

 

| where my_time &gt;=relative_time(now(),"-1d@d") AND _time &lt;=relative_time(now(),"@d")

 

will work in a dashboard.

I started from scratch with all my trials and were not able to reproduce my issues with the html tags. 

This must be a classic PIBCAK (Problem Is Between Chair and Keyboard)

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...