Splunk Enterprise

Is there a reverse split command?

antonio147
Communicator

Hello everybody,
I have a question for the community:
Is there a reverse split command?

I'll explain my problem:
I have a:
| eval Holidays = "01 / 01.01 / 06.08 / 15.11 / 01.12 / 08.12 / 25.12 / 26.05 / 01.04 / 25.06 / 02"
with the holidays that I want to remove from the day count
(I create it, it can be a single value or a multivalue) now I have to add the current year:
| eval year = strftime (now (), "% Y")
and have this day excluded from the final count:
| eval dates = mvrange (C3, now (), 86400)
| eval dates = mvfilter (NOT match (dates, "(Excluded)"))
| convert ctime (dates) timeformat = "% A"
| eval dates = mvfilter (NOT match (dates, "(Saturday | Sunday)"))
| eval noOfDays = mvcount (dates)

I want to create an Excluded field that has holidays with the current year as value for example:
Excluded = "1640991600.000000 | 1641423600.00000 | 1660514400.000000 | ........"
It's possible?
Is there a reverse split command?
Tks
Br

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults
| eval Holidays = "01 / 01.01 / 06.08 / 15.11 / 01.12 / 08.12 / 25.12 / 26.05 / 01.04 / 25.06 / 02"
| streamstats count as row 
| eval Holidays = split(Holidays,".")
| mvexpand Holidays
| eval Holidays = strftime(now(),"%Y / ").Holidays
| eval Holidays = strptime(Holidays, "%Y / %m / %d")
| stats values(*) as * by row
| eval Holidays=mvjoin(Holidays,"|")

View solution in original post

antonio147
Communicator

Hi ITWhisperer,
thanks for the solution !!
It works perfectly.
Thank you so much

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults
| eval Holidays = "01 / 01.01 / 06.08 / 15.11 / 01.12 / 08.12 / 25.12 / 26.05 / 01.04 / 25.06 / 02"
| streamstats count as row 
| eval Holidays = split(Holidays,".")
| mvexpand Holidays
| eval Holidays = strftime(now(),"%Y / ").Holidays
| eval Holidays = strptime(Holidays, "%Y / %m / %d")
| stats values(*) as * by row
| eval Holidays=mvjoin(Holidays,"|")
Get Updates on the Splunk Community!

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 ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...