Splunk Search

Purpose of the "AS" statement in SPLUNK

mahbs
Path Finder

Hi,

What is the purpose of the AS statement in splunk?

I thought, when used, it creates an alias of a column/field as it does in SQL, however, I've found that when used in a lookup statement, it acts as a sort of comparison, for instance in the following query:

index=web_proxy | lookup full_user_names.csv username AS local_user OUTPUTNEW first_name, last_name

i thought username field would be renamed as"Local_user" because of the AS statement, however, I've been told that the statement in this scenario checks to see if a value in local_user matches a value in username.

Can someone explain to me what the function of this statement is?

Thanks

Tags (1)
0 Karma
1 Solution

HiroshiSatoh
Champion

It just specifies a field that matches the lookup table.

<lookup-field> [AS <event-field>]

EX.
index=web_proxy|rename local_user as username
| lookup full_user_names.csv username OUTPUTNEW first_name, last_name

EX.
index=web_proxy
| lookup full_user_names.csv username as local_user OUTPUTNEW first_name, last_name,username
|table local_user ,username,first_name, last_name

View solution in original post

HiroshiSatoh
Champion

It just specifies a field that matches the lookup table.

<lookup-field> [AS <event-field>]

EX.
index=web_proxy|rename local_user as username
| lookup full_user_names.csv username OUTPUTNEW first_name, last_name

EX.
index=web_proxy
| lookup full_user_names.csv username as local_user OUTPUTNEW first_name, last_name,username
|table local_user ,username,first_name, last_name

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...