Splunk Search

Adding a column

Muthu_Vinith
Path Finder

Hi Splunk experts,

I’m a Splunk beginner. I need help with a requirement. I have fields named 'location,' 'login,' and 'desk' with the following values:

 

location  login  desk

AA             1       0

BB             1       0

CC             0       10

DD             1       1

EE             0       1

 

 

My goal is to create a new location called 'ABC,' which should be the sum of all four locations (AA, BB, CC, DD). I've tried the following search, but it's not summing up all four locations:

 

| appendpipe [search AA BB CC DD | eval location=“ABC”]

| stats sum(login) as login by desk

 

Please guide me on how to achieve this. Thank you.

 

 

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Please clarify your question - you say you want to add a column but appendpipe will add row(s) - you  have 5 locations not 4, do you wish to exclude a particular location or sum the logins for all locations by desk?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Use the addcoltotals command to sum the values and put them into the location field as "ABC".

... | addcoltotals labelfield=location label="ABC"
---
If this reply helps you, Karma would be appreciated.
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, ...