Splunk Search

How to create a timechart to show only when values change for a particular field?

vrmandadi
Builder

Hello Splunkers ,

 

I want to know if we can create a timechart that will show only values when they change ..If  there is a change in field value

Below is the timechart of events every minute

2022-12-12 20:41:00 IDLE
2022-12-12 20:40:00 ACTIVE
2022-12-12 20:39:00 FALSE
2022-12-12 20:38:00 FALSE
2022-12-12 20:37:00 FALSE
2022-12-12 20:36:00 TRUE
2022-12-12 20:35:00 TRUE
2022-12-12 20:34:00 TRUE
2022-12-12 20:33:00 TRUE
2022-12-12 20:31:00 NEGATIVE
2022-12-12 20:30:00 NEGATIVE
2022-12-12 20:29:00 NEGATIVE
2022-12-12 20:28:00 TRUE

 

 

I am looking for

2022-12-12 20:41:00 IDLE
2022-12-12 20:40:00 ACTIVE
2022-12-12 20:39:00 FALSE
2022-12-12 20:36:00 TRUE
2022-12-12 20:31:00 NEGATIVE
2022-12-12 20:28:00 TRUE

 

 

Thanks in advance!!

Labels (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Use streamstats to find the first instance of each type - here's an example using your data - the last two lines are relevant to your use case - I've assumed your field name is called 'Status'

| makeresults
| eval _raw="2022-12-12 20:41:00	IDLE
2022-12-12 20:40:00	ACTIVE
2022-12-12 20:39:00	FALSE
2022-12-12 20:38:00	FALSE
2022-12-12 20:37:00	FALSE
2022-12-12 20:36:00	TRUE
2022-12-12 20:35:00	TRUE
2022-12-12 20:34:00	TRUE
2022-12-12 20:33:00	TRUE
2022-12-12 20:31:00	NEGATIVE
2022-12-12 20:30:00	NEGATIVE
2022-12-12 20:29:00	NEGATIVE
2022-12-12 20:28:00	TRUE"
| multikv noheader=t
| eval _time=strptime(Column_1, "%F %T")
| rename Column_2 as Status
| table _time Status
``` Do this ```
| streamstats count by Status reset_on_change=t
| where count=1

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

Use streamstats to find the first instance of each type - here's an example using your data - the last two lines are relevant to your use case - I've assumed your field name is called 'Status'

| makeresults
| eval _raw="2022-12-12 20:41:00	IDLE
2022-12-12 20:40:00	ACTIVE
2022-12-12 20:39:00	FALSE
2022-12-12 20:38:00	FALSE
2022-12-12 20:37:00	FALSE
2022-12-12 20:36:00	TRUE
2022-12-12 20:35:00	TRUE
2022-12-12 20:34:00	TRUE
2022-12-12 20:33:00	TRUE
2022-12-12 20:31:00	NEGATIVE
2022-12-12 20:30:00	NEGATIVE
2022-12-12 20:29:00	NEGATIVE
2022-12-12 20:28:00	TRUE"
| multikv noheader=t
| eval _time=strptime(Column_1, "%F %T")
| rename Column_2 as Status
| table _time Status
``` Do this ```
| streamstats count by Status reset_on_change=t
| where count=1

vrmandadi
Builder

Thank you

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...