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 Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...