Splunk Search

How to get only active hosts?

Stephcg
Explorer

I have an application that have some instances/hosts. Because of change of throughput or instability new instances/hosts can be initiated and old can be terminated.
There are many different events/logs being registered. 

When a new instance/host is initiated it shows the following event/log:

1/20/23
6:00:01.256 PM
 
[app=gateway-example-app, traceId=, spanId=, INFO 1 [ main] gateway.GatewayApplicationKt : Started GatewayApplicationKt in 21.081 seconds (JVM running for 48.641)
  • host = ip-example-of-ip-01
  • source = http:source-example
  • sourcetype = example-sourcetype 

 

When an instance is terminated, it shows the following log:

1/20/23
3:53:42.778 PM
 
CoreServiceImpl INFO: JVM is shutting down
  • host = ip-example-of-ip-02
  • source = http:source-example
  • sourcetype = example-sourcetype 



Is there a way of getting a list of hosts that have the log of initialization, but don't have the log of termination? 
In other words, a list of currently active hosts?

Thank you for any help in advance. And sorry if I wrote anything wrong, english is not my main language.

0 Karma
1 Solution

scelikok
SplunkTrust
SplunkTrust

Hi @Stephcg,

There are other ways but the below should work for your case;

index=application source=http:source-example sourcetype=example-sourcetype ("is shutting down" OR "Started") 
| dedup host 
| search "Started"
| table _time host

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

View solution in original post

scelikok
SplunkTrust
SplunkTrust

Hi @Stephcg,

There are other ways but the below should work for your case;

index=application source=http:source-example sourcetype=example-sourcetype ("is shutting down" OR "Started") 
| dedup host 
| search "Started"
| table _time host

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

Stephcg
Explorer

That worked perfectly! Thank you so much for the help!

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, ...