Getting Data In

Multiple sourcetypes from single directory source

jordans
Path Finder

SQL Server puts both the ERRORLOG and SQLAGENT logs in the same directory. When Splunk automatically assigns a sourcetype, it can end up with some random sourcetypes over time (e.g. ERRORLOG-95).

I have been assigning aliases to these random sourcetypes, but that is not a scalable solution.

How can I either:
- assign all ERRORLOG* sourcetypes to an alias
- manually specify that all ERRORLOG files get one sourcetype and the SQLAGENT logs in the same directory get another sourcetype

Thank you

Tags (2)
1 Solution

gkanapathy
Splunk Employee
Splunk Employee

The easiest way is to just use wildcard specifications in your input files, e.g.:

[monitor://c:\logs\SQLAGENT*.LOG]
sourcetype = sqlagent

[monitor://c:\logs\ERRORLOG*.LOG]
sourcetype = sqlerror

[monitor://c:\logs\]
sourcetype = sqlother

I added an entry to catch other logs, but that is optional. Splunk will work fine and chose the most specific (longest) matching monitor, provided you're collecting using version 4.1 or higher forwarders or indexers. In older versions, you can accomplish the same things (with a slightly more complexity) using a companion props.conf with [source::] stanzas to set the sourcetype on the forwarders. Finally, you can always use an index-time TRANSFORM, but that is the most complex and most resource-intensive method.

View solution in original post

gkanapathy
Splunk Employee
Splunk Employee

The easiest way is to just use wildcard specifications in your input files, e.g.:

[monitor://c:\logs\SQLAGENT*.LOG]
sourcetype = sqlagent

[monitor://c:\logs\ERRORLOG*.LOG]
sourcetype = sqlerror

[monitor://c:\logs\]
sourcetype = sqlother

I added an entry to catch other logs, but that is optional. Splunk will work fine and chose the most specific (longest) matching monitor, provided you're collecting using version 4.1 or higher forwarders or indexers. In older versions, you can accomplish the same things (with a slightly more complexity) using a companion props.conf with [source::] stanzas to set the sourcetype on the forwarders. Finally, you can always use an index-time TRANSFORM, but that is the most complex and most resource-intensive method.

jbsplunk
Splunk Employee
Splunk Employee

You can do a transform to change the sourcetype for ERRORLOG at index time. Instructions for this can be found at this splunk blog:

http://blogs.splunk.com/2010/02/11/sourcetypes-gone-wild/

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...