Splunk Search

What is the difference between fieldformat and eval operation time conversion?

splunkn
Communicator

I am able to see that the following search returns the same result for fieldformat as well as eval time conversion operation. Is there any significant difference between these two in performance wise or in any others?

index=_internal | head 1 | eval abc="1468308151" | fieldformat mytime=strftime(abc,"%H:%M") | eval mytime1=strftime(abc,"%H:%M") | table abc mytime mytime1

index=_internal | head 1 | eval abc="1468308151" | fieldformat mytime=strftime(abc,"%c") | eval mytime1=strftime(abc,"%c") | table abc mytime mytime1

Here mytime and mytime1 fetch the same results. as "12:51"

Thanks

woodcock
Esteemed Legend

Using fieldformat creates an alias for a field leaving the original field value completely unchanged, whereas using eval updates (completely destroys) the original field value and replaces it with a new value. There should be no difference in performance in either case.

kishorksudha
Explorer

fieldformat is good for viewing purpose, when you want to do some calculations on the underlying field you need to use eval and work out.

Basically

  1. With FieldFormat you cant use the modified format to do calculations
  2. With eval you can use the modified values to do calculations
0 Karma

javiergn
SplunkTrust
SplunkTrust

Fieldformat

With the fieldformat command you can
use eval expressions to change the
format of a field value when the
results render. You can change the
format without changing the underlying
value of the field
.

Eval

Eval will change the underlying value of the field.

splunkn
Communicator

thanks javiergn..so coming to this scenario, formattting my epoch time here going to work same right? no better performance over one another?

0 Karma

javiergn
SplunkTrust
SplunkTrust

If there was any performance difference it would be tiny in any case but I couldn't say without running thorough tests.

What you need to keep in mind is whether you want your field value to change or not. If you want to keep the value as it is but just display it differently (user-friendly for instance), then use fieldformat. Otherwise eval can do.

0 Karma
Get Updates on the Splunk Community!

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 ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...