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!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...