Splunk Search

"bin=2h time" doesn't split the bucket by every 2 hour.

cheriemilk
Path Finder

Hi team,

with below query, I can't get expected result with the bins splitted by every 2 hour which I specified by "| bin span=2h TIME"

index=*bizx_application AND sourcetype=perf_log_bizx AND AutoSaveForm OR SaveFormV2 OR SaveForm

| eval TIME=strftime(_time,"%Y-%m-%d %H:%M:%S")

| bin span=2h TIME

| stats count by TIME SFDC

 

The result I got from above query is below table. As you see, the TIME column, it's not splitted by 2 hour. What's wrong here?

 

bin with 2h.jpg

 

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

So the original problem has been solved. Please mark the solution as solving the issue so that others looking for the same issue can find it. As for the reversing the order of time, you already have another question to cover that, so I will post suggestions there.

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Use _time instead of time for your bin and stats. If you want the time displayed in a particular format, use fieldformat

index=*bizx_application AND sourcetype=perf_log_bizx AND AutoSaveForm OR SaveFormV2 OR SaveForm

| fieldformat _time=strftime(_time,"%Y-%m-%d %H:%M:%S")

| bin span=2h _time

| stats count by _time SFDC
0 Karma

cheriemilk
Path Finder

Hi @ITWhisperer ,

It works by using _time, but I have another requirement that I want to display the time order in chart descendly, by reverse command , which means latest time and corresponding count are put in left, instead of right.

So with below query, the reverse command doesn't reverse _time actually.  That  why I didn't use _time at first. Any idea?

 

 

index=*bizx_application AND sourcetype=perf_log_bizx AND AutoSaveForm OR SaveFormV2 OR SaveForm

| fieldformat _time=strftime(_time,"%Y-%m-%d %H:%M:%S")

| bin span=2h _time

| stats count by _time SFDC

| chart values(count) by _time SFDC

| reverse

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

So the original problem has been solved. Please mark the solution as solving the issue so that others looking for the same issue can find it. As for the reversing the order of time, you already have another question to cover that, so I will post suggestions there.

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

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...