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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...