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!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...