Dashboards & Visualizations

Custom Log in Splunk

New Member


i write a batch script that pings IP-Adresses.
The Results are in a .log file looks like:
Switch1 Online
Switch2 Online

When i add the .log as syslog in Splunk i see this entry:
1 » 12/4/12
2:07:44.000 PM

Switch2 Online

host=Splunkserver   Options|  
sourcetype=syslog   Options|  
source=C:\test.log   Options

2 » 12/4/12
2:07:44.000 PM

Switch1 Online

host=Splunkserver   Options|  
sourcetype=syslog   Options|  
source=C:\test.log  Options

How can i change the Entry for "host"? The i see host=Switch1 or Switch2, how must look my log file? And How can i add the Option "Status=Online", "Status=Offline" that i can create a search command like this:
source="C:\test.log" host="*" | stats count count(eval(Type="Online")) as On count(eval(Type="Offline")) as Off by host

When i try this, i see only a count at "counter" nothing at Off and On.

Any idea or tips for me?

Tags (1)
0 Karma

Ultra Champion

You will have to make a dive into the world of index-time transforms.

Firstly, you have set the sourcetype to 'syslog', which it clearly isn't. This has implications, because Splunk will try to extract host information from each event. This will fail, since the events are not properly syslog-formatted. Change the sourcetype to 'my_ping_log' or something unique. Also, if possible, let the script add a date/timestamp to each event as well.

You should look at the following docs for rewriting the host value prior to indexing the events.


I guess that your files should look something like;


TRANSFORMS-set_host = ping_script_host


REGEX = ^(\S+)\s+.*
DEST_KEY = MetaData:Host
FORMAT = host::$1

Please note that the REGEX works for the current event format, i.e. without a timestamp.

Hope this helps,


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