Splunk Enterprise

How to add new entry to lookups and older values are overridden by new values?

sagar_shubham23
Explorer

Why i am getting Duplicate entries while using outputlookups.

Query: 

|inputlookup append=t test1_checks.csv| eval Alert_type="test2", Correlated_alert="test2", Correlation_type=0| outputlookup append=true test1_checks.csv

Result:

Alert Type      Correlated_alert

test2                   test2

test2                   test2

test2                    test2

 

I need only one entry for all kind of entries in Alert_type and Correlated_alert.

 

Kindly help

Labels (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

|inputlookup append=t test1_checks.csv
| append [| makeresults | eval Alert_type="test2", Correlated_alert="test2", Correlation_type=0 | table Alert_type Correlated_alert Correlation_type ]
| stats last(Correlation_type) as Correlation_type by Alert_type Correlated_alert
| outputlookup append=true test1_checks.csv

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

The append=true option to outputlookup tells Splunk to keep the existing lookup file content.  To replace the content with the current result set, use append=false (the default).

 

| inputlookup test1_checks.csv
| eval Alert_type="test2", Correlated_alert="test2", Correlation_type=0
| outputlookup test1_checks.csv

 

As @somesoni2 mentioned, to eliminate duplicate entries, you need to use the stats or dedup command.

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

somesoni2
Revered Legend

Give this a try

|inputlookup append=t test1_checks.csv
| append [| makeresults | eval Alert_type="test2", Correlated_alert="test2", Correlation_type=0 | table Alert_type Correlated_alert Correlation_type ]
| stats last(Correlation_type) as Correlation_type by Alert_type Correlated_alert
| outputlookup append=true test1_checks.csv
Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...