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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...