Splunk Search

How to build a query that returns the hostname of the search head the query is running on?

cwacha
Path Finder

Hi,

I have built an app that aggregates data into a summary index. The app also provides a query that searches for the data in the summary index and displays it. When running the app on one single search head everything works fine.

The problem is that I have two search heads and the app should run on the other search head as well. Both search heads also have the "other" search head configured as a search peer in distributed search.

So here is the problem:
When the query runs from the app on the first search head it searches for data from index=my_summary_index. Since the app also runs on the other search head we also have such a summary index on that other indxer too. Both indexes are returning data and thus duplicate the results.

How can I prevent results from the "other" search head to pollute my query? How can I find out the hostname or splunk_server of the search head "this" query is running on?

0 Karma
1 Solution

sowings
Splunk Employee
Splunk Employee

splunk_server=local will give results from only the current search head.

Note, however, that you can have your search head behave as a forwarder (with an outputs.conf pointing at your indexers), and that the summary indexing data from search head #1 will also be sent there. This means that both (or all, if you expand the number of search heads) will be able to see the summary data.

View solution in original post

sowings
Splunk Employee
Splunk Employee

splunk_server=local will give results from only the current search head.

Note, however, that you can have your search head behave as a forwarder (with an outputs.conf pointing at your indexers), and that the summary indexing data from search head #1 will also be sent there. This means that both (or all, if you expand the number of search heads) will be able to see the summary data.

Get Updates on the Splunk Community!

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

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...