Getting Data In

Parsing dynamic fields when indexing from script?

jm8thew
Engager

I'm new to splunk and I'm trying to import some data from a database that I'd like to have indexed by Splunk. I have a script that returns the info from the database in column name = value pairs. However, some of the column names and values have spaces in them, which seem to mess with Splunk's ability to extract field names. Putting quotes around the column name and value didn't work. Replacing spaces with underscores works, but that is not an ideal solution.

Using the MySQL Connector app I'm able to view the database as it is, but I can't maintain historical data.

So how does Splunk decide what is a field and what isn't beyond simple field=value pairs?

Can I do something so that it will accept spaces in the field names from the script data?

Can I change the way my script outputs data (currently columnname=value for every row) so that it captures the column name and values properly?

Is there a way to use the MySQL Connector app for monitoring changes in my database?

Thanks

Tags (1)
0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Splunk field names cannot contain spaces, like most identifier types you'll find. For example, the following extraction will fail,

  • | rex "foo:'(?<foo field>[^']+)'"

while replacing the space with an underscore will work:

  • | rex "foo:'(?<foo_field>[^']+)'"

Personally, I would consider replacing the spaces with underscores in the script's output to be reasonably good practice.

However, you can write your own field extractions that go beyond Splunk's default key=value behaviour. For example you can use the interactive field extractor available from the event options menu. You still will not be able to get spaces in field names though, you will need to come up with a different name for the field. At that point you might be better off going the underscore way.

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!

Your Path to AgenticOps: AI Experiences for Every Splunk Practitioner

Your Path to AgenticOps: AI Experiences for Every Splunk Practitioner   Watch on demand us for a demo-driven ...

The Data Connection - October 2026

We all have data. Lots of it. But that’s not the problem – it’s understanding what we should we do with it, ...

Beyond the Acceleration Zone: Maximizing Your Success with Splunk Customer Experience ...

Customer success is built on tailored guidance and accessible resources. As a Splunk user, you are encouraged ...