Splunk Search

Get all data even host name is getting changed while searching


I am monitoring log file from one folder and giving host field name as hostname.
ex. I am monitoring C:\Logs\GTA(Brazil).*zip
and here my host name is "GTA(Brazil)"
but after some days I changed my folder name to GSTA(Brazil)
Now I want whenever I am searching with index and new host name, I want to see old data as well(including new hostname data) with hostname- GTA(Brazil).
For mapping I am creating one lookup which contain below information-

Name            new_name
GTTA(Brazil)    GTA(Brazil)
GTTA(Brazil)      GSTA(Brazil)

now how macro should be created which will take input as new host name/ old host name and give results with combination of both.
or is there any other way?
Note- the folder name can get changed any time and I can update lookup with new name but while searching for data with host i want to get all data present within folder.

Tags (1)
0 Karma


Hi @ips_mandar ,

There are many was to index and segregate data while indexing it.
- If all the files from the folder are same type, than create a new sourcetype for the data and index data to the particular sourcetype created for GTA/GSTA(Brazil)/MTA(UK)/ATD(USA). Than you can search for the particular sourcetype and Splunk will return events from old and new host names.

index=index_name sourcetype=<your_sourcetype>
  • Now, if the country name part is going to be constant even after folder name changed, than you can simply search for host name containing the country name.

    index=index_name souretype=sourcetype_name host=brazil
    There are many other possible ways, but it all depends on your environment.
    If folder is having multiple types of log files and all them are getting indexed to different index & sourcetype than it will make it very complex scenario.

Regarding creating macros following reference will help (if the above options solves your problem, create the macro of base search query)

accept & upvote the answer if ti helps.

0 Karma


Thanks but unfortunately it won't help me.
since there can be multiple folders with same country/city/state

0 Karma


Create csv file as below:


Use csv file lookup in search query as below.

index=INDEXNAME [| inputlookup filename.csv | format]
0 Karma


@manjunathmeti, My Bad! sorry I haven't mentioned that I have multiple folders under Logs folder which I am monitoring and any folders name may renamed under log folder and I want to get results of all data contain within that folder.
ex. Folder structure is like -

and If GTA(Brazil) folder name is changed then while searching with new name GSTA(Brazil) I want old data from host GTA(Brazil) as well but not from any other folders like MTA(UK) or ATD(USA).

0 Karma


Then you should use calculated field. Add below configuration in props.conf on search head.

EVAL-host = if(host=="GTA(Brazil)", "GSTA(Brazil)", host)

You can create same from search head UI.
1. Select Settings > Fields.
2. Select Calculated Fields > New Calculated Field.
3. Select the app that will use the calculated field.
4. Select sourcetype to apply to the calculated field and specify a name.
5. Name the resultant calculated field: host
6. Define the eval expression: if(host=="GTA(Brazil)", "GSTA(Brazil)", host)
7. Save and change permissions to other apps and roles.

0 Karma


Thanks but unfortunately it won't help me.
Since it will change host name at search time but in my case user require to search with old/new folder name as host name and he should get all results contained in a folder.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

 (view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...