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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Persistent Queue at TcpOut — One of Splunk's Most Practical Features

Splunk introduced persistent queueing at the tcpout layer as one of the most practical resilience features in ...

Skip the Awkward Silence: Have a .conf-ersation at .conf26

Picture this. You arrive at .conf26 already having your socializing and networking plans mapped out. No ...

Rethinking Zero Trust: From Product Purchases to Logical Control Evidence

Implementing Zero Trust (ZT) across complex environments often falters at the very beginning due to a ...