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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...