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 (3)
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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...