Splunk Dev

Iam getting different outputs for same query

krishna1
Explorer

Iam getting different results for same query when checked in statistics and visualizations, Attaching both screenshots

krishna1_0-1706696012959.png

 

krishna1_1-1706696220064.png

 

 

 

0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

The data in the chart is consistent with the data in the table - the issue is that the chart is treating _time as a special case of field - you can get around this by creating a new field called time and removing _time - you would need to ensure that the time field is listed first so that it becomes the x-axis

| gentimes start=-365
| rename starttime as _time 
| fields _time
| eval location=mvindex(split("ABCDEFGH",""),random()%8)
``` the lines above generate random data for testing ```
| timechart span=1mon count by location
| tail 6
| eval time=strftime(_time,"%Y-%m")
| fields - _time
| table time *

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The data in the chart is consistent with the data in the table - the issue is that the chart is treating _time as a special case of field - you can get around this by creating a new field called time and removing _time - you would need to ensure that the time field is listed first so that it becomes the x-axis

| gentimes start=-365
| rename starttime as _time 
| fields _time
| eval location=mvindex(split("ABCDEFGH",""),random()%8)
``` the lines above generate random data for testing ```
| timechart span=1mon count by location
| tail 6
| eval time=strftime(_time,"%Y-%m")
| fields - _time
| table time *
0 Karma

krishna1
Explorer

Thank you! It is working

0 Karma

PickleRick
SplunkTrust
SplunkTrust

What do you mean by "different results"? They seem pretty much consistent.

0 Karma

krishna1
Explorer

in table , _time is converted into month buckets but in chart, in X-axis its not getting showing monthly buckets

 

0 Karma

PickleRick
SplunkTrust
SplunkTrust

That's simply how Splunk shows the _time field. The data is consistent, the presentation might indeed be a bit confusing. You can get  around it as @ITWhisperer showed already.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...