Knowledge Management

Dealing with field names with a period in it

hcastell
Path Finder

Hi all, I have the following in a macro that I'm basically using to retrieve a integer value that will be used later in my search string:

| eval TestRxSNRTemp=split(Ipd.TestRxSNR," ")
| eval TestRxSNRValue=mvindex(TestRxSNRTemp,0)

The value of Ipd.TestRxSNR field will typically be a value like 20db. I just need the 20. Using the above does not yield the result I'm looking for. Unfortunately, the fields with the period in the name are in input files (XML files) that I don't have any controller over. I'm trying to figure out a way to work around this. I was wondering if there was a way to use the field name (with the period) as is? Thanks for your support.

Tags (2)
1 Solution

hcastell
Path Finder

Sorry to be unclear. Basically all I needed was to use single quotes around the field name as you instructed. Works fine now. Thanks for your help.

View solution in original post

aljohnson_splun
Splunk Employee
Splunk Employee

Periods shouldn't pose a problem. Try using the rename command to rename one of your fields to include a .; no worries there.

There are a ton of ways to approach this. The first thought, personally, is to use regular expressions ! Here is but one way; if it doesn't work just post a comment and I'll revise.

There is a cool sed mode on the rex command, check it like this:

| rex field=Ipd.TestRxSNR mode=sed "s/[^0-9]//g"

What's this black magic? you screech? Ah, nothing but a global blank substitution for anything that isn't a number in the field we specify.

0 Karma

hcastell
Path Finder

Thanks for the suggestion. May try that one day. This time around the single quote did the trick.

hcastell
Path Finder

Sorry to be unclear. Basically all I needed was to use single quotes around the field name as you instructed. Works fine now. Thanks for your help.

acharlieh
Influencer

I'm not entirely sure what you're asking here. To use fields with special characters in them in eval and where functions you'd use single quotes to refer to the fields. (E.x. 'lpd.TestRxSNR' ) If you're having trouble extracting a value, you could also consider the rex command to use a regular expression instead.

aljohnson_splun
Splunk Employee
Splunk Employee

If possible, @acharlieh, please convert your comment to an answer and @hcastell, mark it as accepted. Thanks !

0 Karma

acharlieh
Influencer

Converted!

hcastell
Path Finder

Sorry to be unclear. Basically all I needed was to use single quotes around the field name as you instructed. Works fine now. Thanks for your help.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...