I have a multivalue field called weeksum that contains the following values
In this case, from the first to the last week, there are no missing weeks. I would like to create a field that identifies if there are any missing weeks in the sequence.
For example, if week 2024:51 is missing, the field should indicate that there is a gap in the sequence.
Please note that the weeksum multivalue field already consists of pre-converted values, so converting them back to epoch (using something like | eval week = strftime(_time, "%Y:%U")) does not work.
I will explain my issue from the beginning to make it clearer.
I have an index that contains vulnerabilities related to an IP, and on Splunk, I receive VA data every week. I would like to check based on my IP and vulnerabilities for different cases:
Hi @omcollia ,
ok, you need a completely different thing!
you should run a search to understand if a vulnerability is present in more weeks, so, if vulnerabilities are contained in a fied called vulnerability, you could run something like this:
<your_search>
| eval weeksum=strftime(_time,"%Y:%V")
| stats
dc(weeksum) AS weeksum_count
values(weeksum) AS weeksum
BY vulnerabilities
| eval present_weeksum=strftime(now(),"%Y:%V")
| eval status=case(
weeksum_count=1 AND weeksum=present_weeksum,"Present in Last Week",
weeksum_count=1 AND NOT weeksum=present_weeksum,"Present in Week: ".weeksum,
weeksum_count>1,"Present in More Weeks")you can customize this search using the field you have for vulnerabilities and the additional conditions for status following my approach.
Ciao.
Giuseppe
Here’s the translation of your text into English:
"If I run this command:
| eval year=substr(weeksum,1,4)
the field remains empty, maybe because my field weeksum comes from an eventstats command: | eventstats values(week) as weeksum by IP,dest_ip,plugin_id
and maybe the multivalue field is in a format that's not readable?"
Hi @omcollia ,
I suppose that your inserted the weeksum extraction with eventstat before the eval.
Ciao.
Giuseppe
Border case question (I like those) - how do you know how many weeks a year has? As silly as it sounds - depending on a particular year and how you're counting a year can have between 52 and 54 weeks.
Perhaps I just need to check when more than 7 days have passed between one VA and the next.
Hi @omcollia ,
you could use the delta command to check if the difference between one value and the following is 1, something like this:
<your_search>
| eval year=substr(weeksum,1,4), week=substr(weeksum,5,2)
| sort year week
| delta weeksum AS prevweeksum
| delta week AS prevweek
| delta year AS prevyear
| eval diff=week-prevweek
| search year=prevyear diff>1
| table weeksum prevweeksum year prevyear week prevweekin this way, if the search will have results there's some error.
Ciao.
Giuseppe