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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...