Splunk Search

Is comma ignored during a Splunk search?

filmon6402e
Explorer

Hello Everyone,

I noticed that commas are not necessary when searching as the following would give the same results.


... | stats count, value(product_id) ...
OR
... | stats count value(product_id) ...


Just want to confirm my assumption of commas as a syntax aid is correct.

Thanks.

0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

In that case, commas are indeed optional. However, not all commas are optional - here's an example:

index=_internal | timechart avg(bytes) as bytes, values(sourcetype) as sourcetypes | eval bytes = round(bytes, 2)

The first comma is optional, the second is not.

View solution in original post

filmon6402e
Explorer

Thanks a lot.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

In that case, commas are indeed optional. However, not all commas are optional - here's an example:

index=_internal | timechart avg(bytes) as bytes, values(sourcetype) as sourcetypes | eval bytes = round(bytes, 2)

The first comma is optional, the second is not.

filmon6402e
Explorer

Thanks a lot.

0 Karma

somesoni2
Revered Legend

As per my understanding "," is optional for statistical or formatting commands like stats, chart, timechart, table, fields. They do increase the readability of the code.

Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...