Splunk Search

How can I divide two variables in the same search?

byessayian
New Member

Here's an example of a string I'm looking for:

15:55:37.732 ( 5436:15032) G-MST: 2000001D "00020000-dff6-5032-e3c7-0010491e0e23" ("10.101.16.126","10.101.16.147"),6(G722),rsn:1,23:55:37.629 (UTC),pl:20,(s:45, r:38, l:2294),(j:0,u:0,o:0) flgs:0x00000000 "sip:255@10.101.16.11:5441",vpn:0

I'm interested in the percentage of packet loss. Packets sent are "s:45" and packets received are "r:38". For this example, I'd like to generate an alert on a packet loss of 10% or more.

Could someone please help me?

0 Karma
1 Solution

Ayn
Legend
... | rex "\(s:(?<packets_sent>\d+), r:(?<packets_received>\d+)" | eval packet_loss=1-(packets_received/packets_sent) | where packet_loss>0.1

View solution in original post

Ayn
Legend
... | rex "\(s:(?<packets_sent>\d+), r:(?<packets_received>\d+)" | eval packet_loss=1-(packets_received/packets_sent) | where packet_loss>0.1

byessayian
New Member

Wow! That's brilliant! I'm new to the Splunk community. You answered promptly and accurately. That did it. Thank you so much!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...