Splunk Enterprise Security

How to read a field from a result using a search?

rendie
Path Finder

Hi everyone,

Can I read the value of a field from each previous result using a search? Something similar to:

 

| streamstats current=f last(status) as lastStatus by _time
| eval status = if(isnull(lastStatus), 0, lastStatus+1)
| table status, lastStatus

 

I want to get the result:

statuslastStatus
10
21
32

 

Is it possible?

Thanks

Labels (2)
0 Karma

scelikok
SplunkTrust
SplunkTrust

If you run this command after table command it will pick the status field from table output. There is no difference.

Please describe your goal better, maybe sample data, sample output, sample SPL ...

If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

rendie
Path Finder

The main point is in next:

For example, we have an index where are the next sample of the data:

timenumber
18:010
18:021
18:031
18:040
18:051

 

And I want to create a search that will do the next steps: 1. If 'number' is '1' then to new field add +1

| eval count = 0
| streamstats current=f last(count) as lastCount by _time
| eval count = if(isnull(lastCount), 0, lastCount+1)
| table time, number, count

// but this search doesnt work

 

And the result in the table should be

timenumbercount
18:0100
18:0211
18:0312
18:0402
18:0513
0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @rendie,

You can use autoregress command;

| autoregress status as lastStatus p=1
| table status lastStatus
If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

rendie
Path Finder

This command works similar to | streamstats. They get the last value from an event in an index, but not from the result in a table.

0 Karma
Get Updates on the Splunk Community!

Splunk Search APIを使えば調査過程が残せます

   このゲストブログは、JCOM株式会社の情報セキュリティ本部・専任部長である渡辺慎太郎氏によって執筆されました。 Note: This article is published in both Japanese ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...