Splunk Search

Rounding a Calculated Field

jason_hotchkiss
Communicator

Greeting Splunkers:

Referring to: eval - Splunk Documentation where:

round(X,Y)Returns X rounded to the amount of decimal places specified by Y. The default is to round to an integer.


I am attempting the following:

| eval MemoryUtilization = round((memTotalMB - memFreeMB) / memTotalMB * 100),2)

I am receiving the following error: Error in 'eval' command: Failed to parse the provided arguments. Usage: eval dest_key = expression.

I know I can do it this way:

| eval MemoryUtilization = ((memTotalMB - memFreeMB) / memTotalMB * 100)
| eval MemoryUtilization = round(MemoryUtilization,2)


Is there a way to combine the two eval statements into one?

Thank you!

Labels (1)
Tags (1)
0 Karma
1 Solution

anilchaithu
Builder

@jason_hotchkiss 

parentheses is missing. The below should work

| eval MemoryUtilization = round(((memTotalMB - memFreeMB) / memTotalMB * 100),2)

 

-- Hope this helps

View solution in original post

0 Karma

anilchaithu
Builder

@jason_hotchkiss 

parentheses is missing. The below should work

| eval MemoryUtilization = round(((memTotalMB - memFreeMB) / memTotalMB * 100),2)

 

-- Hope this helps

0 Karma

jason_hotchkiss
Communicator

I was so close... thank you!  

0 Karma
Get Updates on the Splunk Community!

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to Officially Supported Splunk ...