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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...