Splunk Enterprise

How to count the uptime of Websites?

tobi2k
Explorer

Hi There!
I am collecting every 2 minutes the response_code of several websites. In my Dashboard I want to have just two Numbers "X Websites up" and "X Websites down" in realtime.

The Logic is:
Response_code=200 means Website is up
Response_code!=200 means Website is down

How should the query looks like?
index="main" sourcetype="web_ping" response_code="200" delivers all Responses. But how can I count only the Sourcetype?
| stats count by sourcetype delivers the sum of all querys and not the unique Websites.

Help is very appreachiated... Thank you!

Labels (2)

renjith_nair
SplunkTrust
SplunkTrust

@tobi2k ,

Does this work for you ?

index="main" sourcetype="web_ping" |stats latest(response_code) as response_code by <replace with your website field>
|stats count(eval(response_code==200)) as "Websites Up",count(eval(response_code!=200))  as  "Websites Down"
Happy Splunking!

tobi2k
Explorer

Awesome! That has solved my issue!

0 Karma

renjith_nair
SplunkTrust
SplunkTrust

@tobi2k , Glad that it worked 🙂 . Please accept as answer to close the thread

Happy Splunking!
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 ...