Dashboards & Visualizations

Graph edge weight SPL query

mohitab
Path Finder

I could not figure out the proper title, so kindly bear with me. The query results in edge lengths of a Graph.

I have output of a query like this:

x y weight

a b 10
b a 15
a c 12
c a 15

I want to get desired output like:

x y weight

a b 25
a c 27

Any ideas?

Tags (2)
0 Karma
1 Solution

aweitzman
Motivator

Try this:

...your search...
| eval edges=x.",".y 
| makemv delim="," edges 
| eval edgessorted=mvjoin(mvsort(edges),",") 
| stats sum(weight) as weight by edgessorted 
| rex field=edgessorted "(?<x>.*),(?<y>.*)" 
| table x y weight

The trick here is to create a new field (edges) that holds both the x and y values, then use multivalue field functions to sort them so that the edges appear in the same order. Once you've done that you can sum the weights, and lastly get the x and y values back out.

View solution in original post

aweitzman
Motivator

Try this:

...your search...
| eval edges=x.",".y 
| makemv delim="," edges 
| eval edgessorted=mvjoin(mvsort(edges),",") 
| stats sum(weight) as weight by edgessorted 
| rex field=edgessorted "(?<x>.*),(?<y>.*)" 
| table x y weight

The trick here is to create a new field (edges) that holds both the x and y values, then use multivalue field functions to sort them so that the edges appear in the same order. Once you've done that you can sum the weights, and lastly get the x and y values back out.

Get Updates on the Splunk Community!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...