Dashboards & Visualizations

X axis per month with average

Lucie99
Explorer

Hi you all,

I'm very new on Splunk and I'm trying to learn the SPL code.

Pour le moment j'ai un graphique qui a dans l'axe X la date (JJ / MM / AAAA en désordre) et dans l'axe Y une valeur. Je veux savoir comment puis-je classer l'axe X dans l'ordre chronologique par mois et réaliser la moyenne de toute la valeur par mois?

For the moment I have a graphic that has the date in the X axis (DD/MM/YYYY in disorder) and Y axis the value. I want to know how can I sort the X axis in the chronogical order per month and realize the average of all the value per month ?

Thanks you for your help.

 

screen.PNG

Labels (1)
0 Karma
1 Solution

to4kawa
Ultra Champion

sample:

| gentimes start=1/1/2019 end=1/1/2020
| rename starttime as _time
| rename COMMENT as "this is sample, from here the logic."

| bin _time span=1month
| eval date=strftime(_time,"%d/%m/%Y")
| eval count=random() % 100
| stats avg(count) as count by _time date
| table date count

recommend

your search
| eval _time=strptime(DateJour,"%d/%m/%Y")
| bin _time span=1month
| eventstats avg(May) as avgMay by _time
| eval _time=strptime(DateJour,"%d/%m/%Y")
| sort _time
| eval criticalmin = -2 ,criticalmax = 2
| table DateJour May avgMay criticalmin criticalmax

View solution in original post

to4kawa
Ultra Champion

sample:

| gentimes start=1/1/2019 end=1/1/2020
| rename starttime as _time
| rename COMMENT as "this is sample, from here the logic."

| bin _time span=1month
| eval date=strftime(_time,"%d/%m/%Y")
| eval count=random() % 100
| stats avg(count) as count by _time date
| table date count

recommend

your search
| eval _time=strptime(DateJour,"%d/%m/%Y")
| bin _time span=1month
| eventstats avg(May) as avgMay by _time
| eval _time=strptime(DateJour,"%d/%m/%Y")
| sort _time
| eval criticalmin = -2 ,criticalmax = 2
| table DateJour May avgMay criticalmin criticalmax

Lucie99
Explorer

Many thanks !!

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!

A Four-Part Event Series: Full Stack Observability For the AI Era

As AI reshapes applications, infrastructure, and the way teams operate, the traditional boundaries of ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...