Splunk Search

Why are eval fields not in table?

Span
Engager

Hi,

Iam trying a simple query where i want to see the percentage of calls with a particular response time in splunk and somehow the percent field is coming as empty in the table.

 

index = xyz http_status=200 | stats count(request_ms) as web-calls by request_ms | eventstats sum(web-calls) as totalwb |eval percent=(web-calls*100/totalwb) | table request_ms web-calls totalwb percent

Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

The problem is with the web-calls field name.  The eval command is computing percent as (web-(calls*100/totalweb)), but since the web and calls fields don't exist they can't be subtracted so the percent field can't be computed.  Percent is set to null and is displayed as an empty field.  This is why hyphens should not be used in field names.  If the hyphen can't be changed then surround the field name in single quotes ('web-calls') so Splunk knows it's a field rather than an expression.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

The problem is with the web-calls field name.  The eval command is computing percent as (web-(calls*100/totalweb)), but since the web and calls fields don't exist they can't be subtracted so the percent field can't be computed.  Percent is set to null and is displayed as an empty field.  This is why hyphens should not be used in field names.  If the hyphen can't be changed then surround the field name in single quotes ('web-calls') so Splunk knows it's a field rather than an expression.

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...