Splunk Search

multivalue field not ordered properly

Dantuzzo
Loves-to-Learn Lots

Hi,

i'm trying to calculate the average events weekly by their severity and comparing the daily amount with the weekly average, i created a multivalue field but the values in the field get reordered and they don't match the rest of the data (the severity multivalue field),  I tried using mvsort() but it did not work, what did i do wrong? Thank you for any help. Query, results and expected results below:

 

index=myindex earliest=-7d@d latest=now()
    | bin _time span=1d
    | fields _time, severity
    | stats count by _time, severity
    | eventstats avg(count) as average by severity
    | eval change_percent=round(((count-average)*100)/count,0)
    | eval average=round(average,2)
    | eval change_percent=change_percent+"%"
    | table _time severity count average change_percent
    | stats values(severity) as severity, values(count) as AlertCount, values(average) as average, values(change_percent) as change_percent by _time
    | sort - _time
    | eval average=mvsort(average)
    | eval change_percent=mvsort(change_percent)
    | eval AlertCount=mvsort(AlertCount)
    | eval severity=mvsort(severity)

 

results:

 

_time
severity
AlertCount
average
change_percent
2022-12-23
High
Informational
3
8
3.25
3.67
-22%
59%
2022-12-22High13.25-225%
2022-12-21
High
Informational
3
3.25
3.67
-22%
-8%
2022-12-20High43.2519%
2022-12-19
High
Informational
Medium
1
2
5
2.00
3.25
3.67
-100%
-62%
27%

 

 

expected results:

 

_time severity AlertCount average change_percent

_time
severity
AlertCount
average
change_percent
2022-12-23
High
Informational
3
8
3.25
3.67
-22%
59%
2022-12-22High13.25-225%
2022-12-21
High
Informational
3
3.25
3.67
-8%
-22%
2022-12-20High43.2519%
2022-12-19
High
Informational
Medium
1
2
5
3.25
3.67
2.00
-225%
-83,5%
60%
Labels (4)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The values function returns values in lexicographical order with no attempts made to retain any associations to other fields.  The mvsort function won't help because it sorts the values the exact same way.

---
If this reply helps you, Karma would be appreciated.
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!

Event Series: Telemetry Pipeline Management

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...