Splunk Search

Rex expression built with field extractor not working?

nkavouris
Path Finder

I have a reliable base query to find events containing the information I want.

I built a rex using the field extractor, but applying the rex expression in a search does not yield any results, the values(gts_percent) column is always blank


Sample query:

index="june_analytics_logs_prod" $serial$ log_level=info message=*hardware_controller*|
rex field=message "(?=[^G]*(?:GTS weight:|G.*GTS weight:))^(?:[^\.\n]*\.){7}\d+\w+,\s+\w+:\s+(?P<gts_percent>\d+)"|
convert rmunit(gts_percent)|
chart values(gts_percent) by _time

 

Sample raw_ result :

{"bootcount":8,"device_id":"XXX","environment":"prod_walker","event_source":"appliance","event_type":"GENERIC","local_time":"2025-02-20T00:47:48.124-06:00",
"
location":{"city":"XX","country":"XX","latitude":XXX,"longitude":XXX,"state":"XXX"},
"
log_level":"info","message":"martini::hardware_controller: GTS weight: 17.05kg, tare weight: 8.1kg, net weight: 8.95kg, fill weight: 6.8kg, percent: 100%\u0000",
"
model_number":"XXX","sequence":403659,"serial":"XXX","software_version":"2.3.0.276","ticks":0,"timestamp":1740034068,"timestamp_ms":1740034068124}

 

I am trying to extract the bold value in the raw, Where is my rex messing up?

Labels (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

The field extractor and erex commands tend to create overly complicated expressions.  This one should work.

| rex field=message "percent: (?<gts_percent>\d+)"

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

The field extractor and erex commands tend to create overly complicated expressions.  This one should work.

| rex field=message "percent: (?<gts_percent>\d+)"

 

---
If this reply helps you, Karma would be appreciated.

nkavouris
Path Finder

this worked like a charm! 
thank you!

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...