Splunk Dev

Is it possible to use Python (or other languages) to get logs that originated from specific hosts?

sameratassi
Engager

Hi,

Is it possible to use Python (or other languages) to get logs that originated from specific hosts?

For example, search for a list of hosts and return the logs that were ingested during a specific date range.

Thanks !   

Labels (3)
0 Karma

mayurr98
Super Champion

Hello , if its a dynamic list of hosts you could create a lookup table for hosts using settings » Lookups » Lookup table files » New Table Lookup File.

and use below search 

index=<your_index> [inputlookup hosts.csv | table host ]
Select date range on the top right side of the search bar to get the appropriate results.
 
let me know if this helps!
 

richgalloway
SplunkTrust
SplunkTrust

The SPL for that would look something like this.

index=foo earliest=bar latest=baz [ 
  <<your search for a list of hosts>>
  | field host 
  | format
  ]

Crafting that in Python (or other languages) is an exercise left to the reader.

---
If this reply helps you, Karma would be appreciated.
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 ...