Dashboards & Visualizations

Reporting / Dashboard issues

magneto417x
New Member

So I am using the following search to grab data:

source="mhn-splunk.log" |eval Time=strftime(_time,"%b %Y") | stats count as daycount by date_mday | streamstats avg(daycount) |

Issue I noticed today when looking at month to date it orders result in below order which also messes up bar chart any suggestions to fix would be much appreciated.

1
10
2
3
4
5
6
7
8
9

Tags (1)
0 Karma
1 Solution

rjthibod
Champion

Quick note, I am not entirely sure what you are doing with the eval Time ... step because that doesn't have any effect.

Regadless, you can fix your sorting problem by adding a leading zero to date_mday. Add this to your search for ascending calendar dates..

| eval date_mday = if(date_mday < 10, "0".tostring(date_mday), tostring(date_mday)) | sort +date_mday

View solution in original post

0 Karma

puneethgowda
Communicator

eval Time=strftime(_time,"%b %Y")

You are not using eval for any results.

My suggestion is to make use of strftime

Like below

eval datemday=strftime(_time,????)

Give the required format

And count by datemday

You can also use raw date column instead of _tim because daylight matters

0 Karma

magneto417x
New Member

I'm not sure I understand that would make my search be then I tried it a few times and it fails. Would you be able to post what the complete statement would look like?

0 Karma

puneethgowda
Communicator

Sleeping time in India now let me try tomorrow

0 Karma

rjthibod
Champion

Quick note, I am not entirely sure what you are doing with the eval Time ... step because that doesn't have any effect.

Regadless, you can fix your sorting problem by adding a leading zero to date_mday. Add this to your search for ascending calendar dates..

| eval date_mday = if(date_mday < 10, "0".tostring(date_mday), tostring(date_mday)) | sort +date_mday

0 Karma

rjthibod
Champion

@magneto417X Did you try my suggestion of prepending the 0 to some dates?

0 Karma

magneto417x
New Member

That worked. Thanks 🙂

0 Karma

magneto417x
New Member

Not yet had to go to a meeting but plan to give it a spin when I'm back. I will try and update thread 🙂

0 Karma

somesoni2
Revered Legend

Try like this

source="mhn-splunk.log" |eval Time=strftime(_time,"%b %Y") | stats count as daycount by date_mday | sort 0 num(date_mday) | streamstats avg(daycount) 
0 Karma

magneto417x
New Member

The returns same results and still not in order 😞

0 Karma

somesoni2
Revered Legend

That works for me for similar query. Did you use the exact query I gave or there was any modification. Give @rjthibod's answer a try then.

0 Karma

magneto417x
New Member

Copied the query and ran it and it failed 😞

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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...