Dashboards & Visualizations

How to separate multiple results in one line ?

mah
Builder

Hi,

I have a table like this : 3 column minimum :

mah_0-1604913285996.png

The problem is that I want a table which is showing results in separate lines like : 

name targetUrltime
loading...htthps://...942
/servicedesk/.../user/...htthps://...5194
/servicedesk/customer/...htthps://...1447

 

I tried a stats commands like : 

|stats count by name targetUrl Time 

but the result gave me that : 

name targetUrltime
loading...htthps://...1447
/servicedesk/.../user/...htthps://...1447
/servicedesk/customer/...htthps://...1447

 

Can you help me please ?

Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Did you use spath to split the json or was it done when the event was indexed?

The issue can be resolved by splitting the parsing of the json into two parts. First to get the actions list, then to split each action. By putting a mvexpand between the two you can separate each action into a different line

| makeresults | eval _raw="{
\"actions\" : [{
\"targetUrl\":\"https://..\",
\"Time\":942,
\"name\":\"loading\"},
{
\"targetUrl\":\"https://..\",
\"Time\":5194,
\"name\":\"/servicedesk/\"},
{
\"targetUrl\":\"https://..\",
\"Time\":1447,
\"name\":\"/servicedesk/customer\"}]
}"
| spath path=actions{} output=actions
| fields - _raw
| mvexpand actions
| spath input=actions
| fields - actions

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

It might be easier to not have multi-values in the first place. Can you show more of your query for your original table to show how the multi-value fields are being generated?

0 Karma

mah
Builder

The query is very simple : 

Index=A sourcetype=B Type=C | table name targetUrl Time

for the example of a log, I filtered on one user that did 3 actions :

actions: [ [-] 
     {  [-] 

targetUrl:  https...    

Time942

name : loading 
     }

     {  [-] 

targetUrlhttps://.. .     

Time5194

name : /servicedesk/...
     }

 {  [-] 

targetUrlhttps...    

Time: 1447

name : /servicedesk/customer
     }
   ]

}

The actions are in a list [] in the json and I think that is causing the issue to group in one line, no ?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Did you use spath to split the json or was it done when the event was indexed?

The issue can be resolved by splitting the parsing of the json into two parts. First to get the actions list, then to split each action. By putting a mvexpand between the two you can separate each action into a different line

| makeresults | eval _raw="{
\"actions\" : [{
\"targetUrl\":\"https://..\",
\"Time\":942,
\"name\":\"loading\"},
{
\"targetUrl\":\"https://..\",
\"Time\":5194,
\"name\":\"/servicedesk/\"},
{
\"targetUrl\":\"https://..\",
\"Time\":1447,
\"name\":\"/servicedesk/customer\"}]
}"
| spath path=actions{} output=actions
| fields - _raw
| mvexpand actions
| spath input=actions
| fields - actions

mah
Builder

That exactly what I was looking for. 

Works perfectly ! 

Thank you very much !

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...