Splunk Search

bandwidth utilization percentage

ayomotukoya
Explorer

I have the below search and I want to modify it to get the bandwidth utilization percentage. Whats the best way to go about that and what should I add to my search?

 

index=snmp sourcetype=snmp_attributes Name=ifHCInOctets host=xyz
| streamstats current=t global=f window=2 range(Value) AS delta BY UID
| eval mbpsIn=delta*8/1024/1024
| append
[search index=snmp sourcetype=snmp_attributes Name=ifHCOutOctets host=xyz
| streamstats current=t global=f window=2 range(Value) AS delta BY UID
| eval mbpsOut=delta*8/1024/1024 ]
| search UID=1
| timechart span=5m per_second(mbpsIn) AS MbpsIn per_second(mbpsOut) AS MbpsOut BY UID

Labels (1)
0 Karma

ayomotukoya
Explorer

10 mbs

0 Karma

PickleRick
SplunkTrust
SplunkTrust

1. How do you define percentage?

2. You're overthinking your search with this append thingy. You should search for both Names and streamstats by Name. Append uses subsearch and it has its limitations so you might be getting wrong results and not even knowing it.

0 Karma

ayomotukoya
Explorer

Percentage of bandwidth utilized. I’m thinking bytes in+bytes out/1024 then I’m stumped from there

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Yes but percentage is counted from a value against some bigger total. What would be the total in your case?

0 Karma

ayomotukoya
Explorer

10 mb

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Ah, so if it's a static value, you just do something like

| eval inpercentage=Mbpsin/10*100

(or (10*1024*1024), or whatever static value you calculate it against; didn't check your scale). No magic here.

0 Karma

ayomotukoya
Explorer

When I run the search I dont get a field for Bytesinpercentage

index=snmp sourcetype=snmp_attributes Name=ifHCInOctets host=a154
| streamstats current=t global=f window=2 range(Value) AS delta BY UID
| eval mbpsIn=delta*8/1024/1024
| append
[search index=snmp sourcetype=snmp_attributes Name=ifHCOutOctets host=a154
| streamstats current=t global=f window=2 range(Value) AS delta BY UID
| eval mbpsOut=delta*8/1024/1024 ]
| search UID=1
| timechart span=5m per_second(mbpsIn) AS MbpsIn per_second(mbpsOut) AS MbpsOut BY UID
| eval Bytesinpercentage=MbpsIn/10*1024*1024

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Ahhh... right. It's timechart with a BY clause so you'll have separate series for each UID. So if there is a small, fixed set of those UIDs you can do separate eval for each of those fields; you have to adjust the names of course. (If you have too many series your timechart will get clogged anyway).

Alternatively you can loop over those fields with a foreach command.

0 Karma

ayomotukoya
Explorer

Spl isn’t really my strong suit. Would you mind showing me how you’d do it for this UID?

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Well, you have this

| search UID=1

part in your search which means that you're effectively getting just two series in output.

And if you want the data for just this UID, it's best to filter your data as early as possible so that Splunk doesn't drag all unnecessary data along just to filter most of it out at the end. So you can completely refactor your search to something like.

index=snmp sourcetype=snmp_attributes Name IN (ifHCInOctets,ifHCOutOctets) host=xyz UID=1
| streamstats current=t global=f window=2 range(Value) AS delta BY  Name
| eval mbps=delta*8/1024/1024
| timechart span=5m per_second(mbps) AS Mbps BY Name

This should give you two series as output - ifHCInOctets and ifHCOutOctets.

You can of course

| rename ifHCInOctets as In, ifHCOutOctets as Out

for brevity.

And now you can just do

| eval InPerc=In/(10*1024*1024)
| eval OutPerc=Out/(10*1024*1024)

You can multiply it by 100 if you want actual percents.

0 Karma
Get Updates on the Splunk Community!

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...

Stay Connected: Your Guide to October Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...