Splunk Search

Help me with my usecase

sravankaripe
Communicator

-------------------------------------| stats count by status | eval status=" Status: ".status.", Count : ".count | fields status

the search result is like this

status
----------
Status: 200, Count: 10
--------------------------------
Status: 400 Count: 20
--------------------------------

But i need to display like this...
----------
Status: 200
Count: 10
----------
Status: 400
Count: 20

Please help me with this use case

Tags (2)
0 Karma
1 Solution

DalJeanis
Legend
| makeresults | eval mystatus="200=10 400=20" | makemv mystatus | mvexpand mystatus 
| rex field=mystatus "(?<status>[^=]+)=(?<count>\d+)" 
| table status count 
| rename COMMENT as "The above just enters your test data up through the line '| stats count by status'." 

| rename COMMENT as "This formats the data into a multivalue field with three lines per status." 
| eval status=mvappend("---------------","Status: ".status,"Count: ".count) 
| table status

...with these results...

status
---------------
Status: 200
Count: 10
---------------
Status: 400
Count: 20

If you absolutely need a separator after the last one, then you can add this line at the end

| append [| makeresults | eval status="---------------"|table status] 
0 Karma

alemarzu
Motivator

Hi there, try something like this

main search | stats count by status | eval status=" Status: ".status.", Count : ".count | makemv delim="," Status | mvexpand Status

Hope it helps.

cmerriman
Super Champion

sravankaripe
Communicator

got it thanks

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 ...