Splunk Search

Can you remove a unit of measurement from a field value?

mbond81
Engager

I'm trying to calculate man hours, but my field format is "12 Mins" not simply "12". How can I either calculate this numeric value with the unit attached, or remove the unit "Mins" and calculate the total that way?

Tags (3)
0 Karma

sansay
Contributor

The simplest flexible way:
... | convert rmunit(FieldName) | ...

mattymo
Splunk Employee
Splunk Employee

beauty command, that I didn't even know existed! thanks!

- MattyMo
0 Karma

woodcock
Esteemed Legend

Remove it like this:

... | rex field=MyField mode=sed "s/\s+Mins$//"
0 Karma

ehudb
Contributor

Lets assume your field is named "time", you can extract it with rex:

|rex field=time "(?\d+)" |stats sum(mins) as total

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...