Splunk Search

Enforcing string field type on digit-only data

sschuerger
Engager

Hi, I'm working with log data which contains MSISDNs (mobile numbers), which are in the form of "491701234567". It's a CSV-style flatfile log format I'm using.

Doing a search
msisdn=491701234567
does not work (double-quoting also doesn't help). Strangely, using "491701234567" without field name works, but I need field name matches.

Apparently, Splunk stores the MSISDNs in some kind of numerical format where mantissa precision loss is an issue. But MSISDNs are not numbers, they are basically strings with a numerical alphabet (you can't do sensible numerical operations with MSISDNs).

How do I get Splunk to store them in a string field type despite of digit-only content?

Thanks,
Stefan

Tags (3)
0 Karma

woodcock
Esteemed Legend

You must tell Splunk to treat this field in a special way in $SPLUNK_HOME/etc/system/local/fields.conf:


[msisdn]
INDEXED_VALUE = false

0 Karma

lguinn2
Legend

I don't know why this is happening, but I do have a work-around.

"491701234567"
| regex msisdn="491701234567"

This should work. This is based on what I think might be wrong here. First, Splunk does not store the field values, so "Splunk stores the MSISDNs in some kind of numerical format" is certainly false. What I think is going wrong is this: In the search command itself, the 491701234567 is converted to a number and tested against the value of the msisdn field. I think that Splunk sees the values in the msisdn field and decides that the field is numeric, so the constant should be as well; this conversion occurs regardless of the quotation marks. This is consistent with other Splunk behavior regarding the automatic detection of numeric fields.

In my example, I first search for the string to reduce the overall number of events that need to be tested. The second command uses a regular expression to do the comparison, so no string-to-numeric conversion will occur.

All that said, I would file a support ticket on this. Your original search really should work.

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...