Splunk Search

How to sort values on x-axis based on the values of other fields

bollam
Path Finder

Hello,

I'm trying to plot a graph based on three fields.

The events contain the job, startTime, usedMemory. I want to plot a graph based on the start_time(epochTime) of the job.

I have a query written as follow.

index=main 
| eventstats earliest(startTime) as start_time by job
| stats first(totalMB) as total sum(UsedMB) AS a by start_time, stage
| eval pct=round((a/total)*100,2)
| table start_time stage pct

This query is giving me the right results as expected.

job start_time pct
b 00:05 20
c 00:10 15
f 00:25 55
a 00:00 40
d 00:15 60

When trying to plot a graph using following query, The job is getting sorted in the ascending order which I do not want.
I wanted the way how it is shown above on the x-axis ( b c f a d )

I need the values on the x-axis how the results with table command.

index=main 
| eventstats earliest(startTime) as start_time by job
| stats first(totalMB) as total sum(UsedMB) AS a by start_time, job
| eval pct=round((a/total)*100,2)
| table start_time job pct
| chart avg(pct) as Mem_used by job
Tags (3)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@bollam

You can try by retaining order in other field..

Can you please try this?

index=main 
| eventstats earliest(startTime) as start_time by job
| stats first(totalMB) as total sum(UsedMB) AS a by start_time, job
| eval pct=round((a/total)*100,2)
| table job start_time pct | eval no=1 | accum no | chart avg(pct) as Mem_used values(no) as no by job | sort no | fields - no
0 Karma

bollam
Path Finder

@kamlesh_vaghela, Thanks much!! It worked

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@bollam

Glad to help you. Can you please accept the answer to help the community.

Happy Splunking

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...