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
Super Champion

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
Super Champion

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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...