Getting Data In

How to combine Data from a lookup with a query to Pull latest values?

amedina
Engager

Hello,

Background story:
I have a data set that is being ingested by Splunk by the HTTP event collector, when this connector was added to Splunk, the connector started ingesting current logs from the appliance and no historical logs prior to that day it was connected.

Fast forward, in order to account for those missing logs a lookup was created. The dataset contains "Issue IDs" with its corresponding "status"

What I am trying to do is, combine the data from the lookup with the index to look pull back the latest value for "status" for the "Issue ID".
However, when the query is ran, the value from the lookup always trumps the recent data from the index, even though the lookup is 1 week older then the log comparing it.

Without the lookup, the query works fine, it is able to pull the latest values for "status".


This is how I have formulated the query:

|inputlookup OpenIssues
|fields "Issue ID",Status,Severity
|rename Status AS issue.status
|rename "Issue ID" as issue.id
|rename Severity as issue.severity
|append [search index="dataset A" sourcetype=_json
|fields  issue.id issue.status
|stats latest(issue.status)

richgalloway
SplunkTrust
SplunkTrust

If newer events have to trump older events then the lookup file must contain timestamps.  After the indexed data is appended to the lookup data, sort by timestamp then take the first (newest) event.

|inputlookup OpenIssues
|fields "Issue ID",Status,Severity, timestamp
|rename Status AS issue.status
|rename "Issue ID" as issue.id
|rename Severity as issue.severity
|append [search index="dataset A" sourcetype=_json
|fields  issue.id issue.status timestamp
```Put the newest events first```
|sort 0 - timestamp
|stats first(issue.status)
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...