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!

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...

What’s New in Splunk Observability – September 2025

What's NewWe are excited to announce the latest enhancements to Splunk Observability, designed to help ITOps ...

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...