Splunk Search

How to 2 spunk search into one result and substract the sum value of 1 search to another search and display it?

archonixm
New Member

index=oswindows sourcetype="winhost" host=npe OR host=npw source=service earliest="-30d@d" latest="@d DisplayName="Vontu Monitor"
| transaction DisplayName !(startswith="State=Stopped" endswith="State=Running")
| stats sum(duration) as abc1 by host,DisplayName

index=oswindows sourcetype="winhost" host=npe OR host=npw source=service earliest="-30d@d" latest="@d" DisplayName="Vontu Monitor"
| transaction DisplayName startswith="State=Stopped" endswith="State=Running"
| stats sum(duration) as abc2 by host, DisplayName

What I want is to substract the first sum of value by host for first search with second search. Please help me. I tried append and appendcols but it doesn't display the second search result.

0 Karma

kmorris_splunk
Splunk Employee
Splunk Employee

This is a simple example, but give something like this a try:

sourcetype=access_combined action=addtocart 
| stats sum(bytes) as bytes_atc by clientip 
| appendcols 
    [ search sourcetype=access_combined action=purchase 
    | stats sum(bytes) as bytes_purch by clientip] 
| eval sum_all=bytes_atc + bytes_purch
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The two searches are identical except for the as clause so the result will always be zero.
Perhaps you meant to paste a different second search?

---
If this reply helps you, Karma would be appreciated.
0 Karma

archonixm
New Member

one with ! in it...in the transaction command...

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...