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!

Enter the Dashboard Challenge and Watch the .conf24 Global Broadcast!

The Splunk Community Dashboard Challenge is still happening, and it's not too late to enter for the week of ...

Join Us at the Builder Bar at .conf24 – Empowering Innovation and Collaboration

What is the Builder Bar? The Builder Bar is more than just a place; it's a hub of creativity, collaboration, ...

Combine Multiline Logs into a Single Event with SOCK - a Guide for Advanced Users

This article is the continuation of the “Combine multiline logs into a single event with SOCK - a step-by-step ...