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
Legend

@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
Legend

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

Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...