Splunk Search

query for top value

DTERM
Contributor

Let's say you have a log that looks like....

X -- Y -- Z

=== === ===

AAA BBB 123

AAA BBB 356

YYY ZZZ 800

AAA BBB 900

YYY ZZZ 345

What query would allow me to extract the highest number Z where X and Y are equal.

So for the example above, I would expect to see results like:

AAA BBB 900

YYY ZZZ 800

Thanks.

Tags (1)
0 Karma
1 Solution

kristian_kolb
Ultra Champion

Well, depending on the nature of X and Y, there are a couple of options, one of them being a simple string concatenation for the comparison:

... | eval Q = X." ".Y | stats max(Z) AS Z by Q | rename Q AS "X and Y"

which would give you a table like;

X and Y          Z
AAA BBB          900
CCC DDD          800

Hope this helps,

Krisitan

View solution in original post

kristian_kolb
Ultra Champion

Well, depending on the nature of X and Y, there are a couple of options, one of them being a simple string concatenation for the comparison:

... | eval Q = X." ".Y | stats max(Z) AS Z by Q | rename Q AS "X and Y"

which would give you a table like;

X and Y          Z
AAA BBB          900
CCC DDD          800

Hope this helps,

Krisitan

DTERM
Contributor

Thanks much!!

0 Karma

kristian_kolb
Ultra Champion

The dot (.) is the concatenation operator; so the eval statement creates the 'AAA BBB' and 'CCC DDD' strings, which appear under the 'X and Y' heading.

Of course, this could have been illustrated better with proper log events.

The reason for doing so is that you'll need to find the highest value for the combination of A and Y.

/k

DTERM
Contributor

Perfect. Thanks so much!! But can you explain the "eval Q = X." ".Y" portion of that. I don't quite get that...

0 Karma

Ayn
Legend

Explain how X and Y are equal in the lines you're expecting to see? Also, do you mean that the actual log event looks like this in a kind of tabular format?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Painting a Clearer Picture: Creating Cross-Domain Visibility with AI Canvas

    Thursday, June 25, 2026  |  11AM PDT / 2PM EDT  Duration: 1 Hour (Includes live Q&A) Register to ...

Analytics Workspace deprecation

As of Splunk Cloud Platform 10.4.2604 and Splunk Enterprise 10.4, Analytics Workspace is now deprecated. ...

Splunk Developer Day Recap: Building, Publishing, and Growing on the Splunk Platform

Splunk Developer Day brought the Splunk developer community together for a practical look at what it means to ...