Splunk Search

How to calculate date based upon a patch lot value.

sbhatnagar88
Path Finder

How can we apply below logic in splunk.

We have the data in Splunk which is coming out as below.

Host Patching Lot
A Lot 1
B Lot2
C Lot 3

Lets say
Lot 1 means - First Sunday of Every Month
Lot 2 means - First Saturday of Every month
Lot 3 Means - Second Sunday of Every Month.

How can we calculate the date corresponding to each lot for the current month.

Required Output is

Host Patching Lot Date
A Lot 1 4- Aug (First Sunday of Aug)
B Lot2 3- Aug (First Saturday of Aug)
C Lot 3 11- Aug (Second Sunday of Aug.)

Thanks

Tags (1)
0 Karma

sbhatnagar88
Path Finder

Hi Chinmoy,

Thanks for Responding.

Your logic seems correct, but I need this information in date format. can we do so?

Thanks

0 Karma

chinmoya
Communicator

Use creates date_mday and date_wday field for all index. Use can use these fields.
Below is an example using splunks internal index

| tstats values(date_wday) as Day where index=_internal by date_mday
| rename date_mday as date
| sort date
| eval dayFlag = ( floor((date/7)) ) + 1
| eval Message = date." is the ".dayFlag." ".Day." of the Month"
| table Message

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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...