Dashboards & Visualizations

how to group by day but with different time ?

mah
Builder

Hi, 

I have a table like this : 

mah_0-1600872463368.png

I want to group by day and tried the commande | bucket span=1d field_date but without success. 

How can I do ? 

Labels (1)
Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

The bin is to set up buckets for a stats command - if we assume you want to sum the OK, KO and TOTAL columns by day

| eval time=strptime(substr(field_date,1,10),"%Y-%m-%d")
| fieldformat time=strftime(time,"%Y-%m-%d")
| bin time span=1d
| stats sum(OK) as OK sum(KO) as KO sum(TOTAL) as TOTAL by time

 

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Is your field a string rather than a datetime field? Perhaps you can create a time field from the first 10 characters of the field_date?

| eval day=strptime(substr(field_date,1,10),"%Y-%m-%d")
| bin span=1d day
0 Karma

mah
Builder

Hi @ITWhisperer ,

It returns this : 

mah_0-1600874499754.png

How can I write values of day field in %Y%m%d ?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| fieldformat day=strftime(day,"%Y%m%d")
0 Karma

mah
Builder

Thanks, 

Now I have this :

mah_0-1600875652131.png

 I applied the bin command, it doesn't work. I tried the bucket command, it doesn't work too. 

| eval time=strptime(substr(field_date,1,10),"%Y-%m-%d")
| fieldformat time=strftime(time,"%Y-%m-%d")
| table time OK KO TOTAL
| bin time span=1d

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The bin is to set up buckets for a stats command - if we assume you want to sum the OK, KO and TOTAL columns by day

| eval time=strptime(substr(field_date,1,10),"%Y-%m-%d")
| fieldformat time=strftime(time,"%Y-%m-%d")
| bin time span=1d
| stats sum(OK) as OK sum(KO) as KO sum(TOTAL) as TOTAL by time

 

mah
Builder

hi @ITWhisperer ,

Exactly what I was looking for. 

I didn't know that the stat command had to be written after the bin command. That why the bin didn't work. 

Thank you very much. 

0 Karma
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...