Splunk Search

What is the difference between == and = in SPL ?

HeinzWaescher
Motivator

Hi,

I've seen it several times but don't know the difference and when to use == instead of = .
Like in these samples from the docs:

  1. | eval description=case(status == 200, "OK", status ==404, "Not found", status == 500, "Internal Server Error")

  2. | eval action=if(action=="view",...)

Thanks in advance

Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

The == operator means "is equal to". The = operator means either "is equal to" or "is assigned to" depending on the context.
Either operator can be used to compare two fields/values with == more clearly indicating a comparison rather than an assignment.
Use = to assign a value to a field.

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

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

The == operator means "is equal to". The = operator means either "is equal to" or "is assigned to" depending on the context.
Either operator can be used to compare two fields/values with == more clearly indicating a comparison rather than an assignment.
Use = to assign a value to a field.

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

HeinzWaescher
Motivator

Thanks a lot. I never used == and never ran into problems, that's why I was wondering.
So in the end it is more a cosmetical thing to use ==.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...