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!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...