Skip to content

Commit b555274

Browse files
committed
Updated to savedsearches, dashboards and macros due to change to comment syntax
1 parent 8310d26 commit b555274

File tree

4 files changed

+178
-137
lines changed

4 files changed

+178
-137
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,10 @@ Feel free to open an issue on github or use the contact author on the SplunkBase
360360

361361
## Release Notes
362362
### 3.0.15
363-
- Merged pull request from sifters relating to replacing comment macro with the triple backtick option introduced in Splunk 8.1
363+
- Merged pull request from sifters relating to replacing comment macro with the triple backtick option introduced in Splunk 8.1. This involved editing many searches to change the format of the comments.
364+
365+
New reports:
366+
- SearchHeadLevel - configtracker index example2
364367

365368
### 3.0.14
366369
New reports:

default/data/ui/nav/default.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@
321321
<saved name="SearchHeadLevel - Job performance data per indexer" />
322322
<saved name="SearchHeadLevel - Jobs endpoint example" />
323323
<saved name="SearchHeadLevel - configtracker index example" />
324+
<saved name="SearchHeadLevel - configtracker index example2" />
324325
<saved name="IndexerLevel - RemoteSearches Indexes Stats" />
325326
<saved name="IndexerLevel - RemoteSearches Indexes Stats Wilcard" />
326327
<saved name="IndexerLevel - RemoteSearches - lookup usage" />

default/macros.conf

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -572,14 +572,14 @@ iseval = 0
572572
#Substitute `<macro name>` within the audit.log files with the audit definition based on a lookup file
573573
#note this version only substitutes the first macro seen...the Splunk 8 version can handle multiple macros at once
574574
[splunkadmins_audit_logs_macro_sub]
575-
definition = search ```Set all values to null() in case this macro is called again within the same search. Subsitute a macro used inside a search with the definition found in the lookup file```\
575+
definition = ```Set all values to null() in case this macro is called again within the same search. Subsitute a macro used inside a search with the definition found in the lookup file```\
576576
| eval definition=null(), commas=null(), commas2=null(), argCount2=null(), argCount=null(), match=null()\
577577
| rex field=search max_match=1 "\`(?!\")(?!')(?P<macro>[^\`]+)\`" \
578-
| search ```You can have multiple macro definitions with either 0 or more arguments so we have to count them...``` \
578+
```You can have multiple macro definitions with either 0 or more arguments so we have to count them...``` \
579579
| rex max_match=10 field=macro "([^\"]+\")|([^']+')\s*(?P<commas>,)" \
580580
| rex max_match=10 field=macro "(?P<commas2>,)" \
581581
| rex max_match=1 field=macro "(?P<match>[^\(]+\()" \
582-
| search ```Two count methods are used as if we have macro(arg1) that has no commas, but macro(arg1,arg2) will work as expected...``` \
582+
```Two count methods are used as if we have macro(arg1) that has no commas, but macro(arg1,arg2) will work as expected...``` \
583583
| eval argCount2=if(match(macro,"([^\"]+\")|([^']+')") AND isnull(commas),-1,if(isnotnull(commas2),mvcount(commas2),null())) \
584584
| eval argCount=if(isnull(argCount2),0,argCount2+1) \
585585
| eval argCount=if(argCount==0,if(isnotnull(match),1,0),argCount) \
@@ -595,54 +595,54 @@ iseval = 0
595595
#Substitute `<macro name>` within the audit.log files with the audit definition based on a lookup file
596596
#note this version only works on Splunk 8 due to the use of mvmap
597597
[splunkadmins_audit_logs_macro_sub_v8]
598-
definition = search ```Set all values to null() in case this macro is called again within the same search. Subsitute a macro used inside a search with the definition found in the lookup file``` \
599-
| eval definition=null(), definition2=null(), definition3=null(), commas=null(), commas2=null(), argCount2=null(), argCount=null(), match=null() \
598+
definition = ```Set all values to null() in case this macro is called again within the same search. Subsitute a macro used inside a search with the definition found in the lookup file``` \
599+
eval definition=null(), definition2=null(), definition3=null(), commas=null(), commas2=null(), argCount2=null(), argCount=null(), match=null() \
600600
| rex field=search "\\`(?!\")(?!')(?P<macro>[^\\`]+)\\`" max_match=20 \
601-
| search ```remove any commas inside double quotes or single quotes inside a macro, they are probably not arguments to the macro itself``` \
601+
```remove any commas inside double quotes or single quotes inside a macro, they are probably not arguments to the macro itself``` \
602602
| eval remove_commas_inside_macros=mvmap(macro,replace(macro,"(\"[^\"]+\"|'[^']+')","")) \
603-
| search ```Originally a regex, the replace+len works in mvmap and determines number of commas so we can find a macro name``` \
603+
```Originally a regex, the replace+len works in mvmap and determines number of commas so we can find a macro name``` \
604604
| eval commas2=mvmap(remove_commas_inside_macros,if(match(remove_commas_inside_macros,"^[^\(]+$"),"-1",len(replace(remove_commas_inside_macros,"[^,]+",""))+1)) \
605605
| rex field=macro "(?P<macro_name>^[^\( ]+)" max_match=20 \
606606
| eval macro_commas=mvzip(macro_name,commas2,"!!!!!!!") \
607-
| search ```A macro with zero arguments is -1 from the previous mvmap, if it has non-zero arguments the definition changes to macro(number)...``` \
607+
```A macro with zero arguments is -1 from the previous mvmap, if it has non-zero arguments the definition changes to macro(number)...``` \
608608
| eval macroName=mvmap(macro_commas,if(mvindex(split(macro_commas,"!!!!!!!"),1)=="-1",mvindex(split(macro_commas,"!!!!!!!"),0),mvindex(split(macro_commas,"!!!!!!!"),0) . "(" . mvindex(split(macro_commas,"!!!!!!!"),1) . ")")) \
609609
| lookup splunkadmins_macros title AS macroName, app AS app_name, splunk_server \
610610
| eval app_name2="global" \
611-
| search ```The original version just did an OUTPUTNEW definition, however this has the limitation that if 1 of the 5 macros found resolves, output stops. And this can result in missing macros. So this version over-matches but that appears to be the tradeoff...without making this even more complicated``` \
611+
```The original version just did an OUTPUTNEW definition, however this has the limitation that if 1 of the 5 macros found resolves, output stops. And this can result in missing macros. So this version over-matches but that appears to be the tradeoff...without making this even more complicated``` \
612612
| lookup splunkadmins_macros title AS macroName, app AS app_name2, splunk_server OUTPUT definition AS definition2 \
613613
| lookup splunkadmins_macros title AS macroName, splunk_server OUTPUT definition AS definition3 \
614614
| eval definition=mvdedup(mvappend(definition,definition2,definition3)) \
615615
| fillnull definition value="macronotfound" \
616616
| nomv definition \
617617
| eval definition=" " . definition . " " \
618-
| search ```While an mvmap could replace per-macro that results in a multivalue output. Also replace doesn't handle a multivalued replacement argument so just replace the first macro if it exists with the definitions of all the macros, close enough for what we want``` \
618+
```While an mvmap could replace per-macro that results in a multivalue output. Also replace doesn't handle a multivalued replacement argument so just replace the first macro if it exists with the definitions of all the macros, close enough for what we want``` \
619619
| eval search=if(isnotnull(macro_name),replace(search,mvindex(macro_name,0),definition),search)
620620
iseval = 0
621621

622622
#Substitute `<macro name>` within the any file
623623
[splunkadmins_macro_sub(1)]
624624
args = fieldname
625-
definition = search ```Set all values to null() in case this macro is called again within the same search. Subsitute a macro used inside a search with the definition found in the lookup file``` \
626-
| eval definition=null(), definition2=null(), definition3=null(), commas=null(), commas2=null(), argCount2=null(), argCount=null(), match=null() \
625+
definition = ```Set all values to null() in case this macro is called again within the same search. Subsitute a macro used inside a search with the definition found in the lookup file``` \
626+
eval definition=null(), definition2=null(), definition3=null(), commas=null(), commas2=null(), argCount2=null(), argCount=null(), match=null() \
627627
| rex field=$fieldname$ "\\`(?!\")(?!')(?P<macro>[^\\`]+)\\`" max_match=20 \
628-
| search ```remove any commas inside double quotes or single quotes inside a macro, they are probably not arguments to the macro itself``` \
628+
```remove any commas inside double quotes or single quotes inside a macro, they are probably not arguments to the macro itself``` \
629629
| eval remove_commas_inside_macros=mvmap(macro,replace(macro,"(\"[^\"]+\"|'[^']+')","")) \
630-
| search ```Originally a regex, the replace+len works in mvmap and determines number of commas so we can find a macro name``` \
630+
```Originally a regex, the replace+len works in mvmap and determines number of commas so we can find a macro name``` \
631631
| eval commas2=mvmap(remove_commas_inside_macros,if(match(remove_commas_inside_macros,"^[^\(]+$"),"-1",len(replace(remove_commas_inside_macros,"[^,]+",""))+1)) \
632632
| rex field=macro "(?P<macro_name>^[^\( ]+)" max_match=20 \
633633
| eval macro_commas=mvzip(macro_name,commas2,"!!!!!!!") \
634-
| search ```A macro with zero arguments is -1 from the previous mvmap, if it has non-zero arguments the definition changes to macro(number)...``` \
634+
```A macro with zero arguments is -1 from the previous mvmap, if it has non-zero arguments the definition changes to macro(number)...``` \
635635
| eval macroName=mvmap(macro_commas,if(mvindex(split(macro_commas,"!!!!!!!"),1)=="-1",mvindex(split(macro_commas,"!!!!!!!"),0),mvindex(split(macro_commas,"!!!!!!!"),0) . "(" . mvindex(split(macro_commas,"!!!!!!!"),1) . ")")) \
636636
| lookup splunkadmins_macros title AS macroName, app AS app_name, splunk_server \
637637
| eval app_name2="global" \
638-
| search ```The original version just did an OUTPUTNEW definition, however this has the limitation that if 1 of the 5 macros found resolves, output stops. And this can result in missing macros. So this version over-matches but that appears to be the tradeoff...without making this even more complicated``` \
638+
```The original version just did an OUTPUTNEW definition, however this has the limitation that if 1 of the 5 macros found resolves, output stops. And this can result in missing macros. So this version over-matches but that appears to be the tradeoff...without making this even more complicated``` \
639639
| lookup splunkadmins_macros title AS macroName, app AS app_name2, splunk_server OUTPUT definition AS definition2 \
640640
| lookup splunkadmins_macros title AS macroName, splunk_server OUTPUT definition AS definition3 \
641641
| eval definition=mvdedup(mvappend(definition,definition2,definition3)) \
642642
| fillnull definition value="macronotfound" \
643643
| nomv definition \
644644
| eval definition=" " . definition . " " \
645-
| search ```While an mvmap could replace per-macro that results in a multivalue output. Also replace doesn't handle a multivalued replacement argument so just replace the first macro if it exists with the definitions of all the macros, close enough for what we want``` \
645+
```While an mvmap could replace per-macro that results in a multivalue output. Also replace doesn't handle a multivalued replacement argument so just replace the first macro if it exists with the definitions of all the macros, close enough for what we want``` \
646646
| eval search=if(isnotnull(macro_name),replace($fieldname$,mvindex(macro_name,0),definition),$fieldname$)
647647
iseval = 0
648648

@@ -709,27 +709,27 @@ args = search_id
709709
definition = eval from=null(), username=null(), searchname2=null(), searchname=null()\
710710
| rex field=$search_id$ "(_rt)?(_?subsearch)*_?(?P<from>[^_]+)((_(?P<base64username>[^_]+))|(__(?P<username>[^_]+)))((__(?P<app>[^_]+)__(?P<searchname2>[^_]+))|(_(?P<base64appname>[^_]+)__(?P<searchname>[^_]+)))"\
711711
| rex field=$search_id$ "^_?(?P<from>SummaryDirector)"\
712-
| search ```Pattern appears to vary but remote_<hostname>_ is consistent along with the optional _subsearch, the _from can be <username>__ownername__appname__RMD for dashboards as one pattern, it can also be unixepoch (ad-hoc), or scheduler__username__appname (scheduled search), or username__owner__(something)__dashboardview, among others. RMD values can be translated via audit.log, scheduler.log or remote_searches.log (if savedsearch_name is there)!```\
712+
```Pattern appears to vary but remote_<hostname>_ is consistent along with the optional _subsearch, the _from can be <username>__ownername__appname__RMD for dashboards as one pattern, it can also be unixepoch (ad-hoc), or scheduler__username__appname (scheduled search), or username__owner__(something)__dashboardview, among others. RMD values can be translated via audit.log, scheduler.log or remote_searches.log (if savedsearch_name is there)!```\
713713
| fillnull from value="adhoc"\
714714
| eval searchname=coalesce(searchname,searchname2)\
715715
| eval type=case(from=="scheduler","scheduled",from=="SummaryDirector","acceleration",match(search_id,"^'?alertsmanager_"),"scheduled",isnotnull(searchname),"dashboard",1=1,"ad-hoc")
716716
iseval = 0
717717

718718
[base64decode(1)]
719719
args = afield
720-
definition = eval $afield$=null() | search ```As per https://docs.splunk.com/Documentation/Splunk/latest/Report/Createandeditreports usernames/apps can be base64 encrypted, remove the eval when ready to use this...decrypt2 (splunkbase) can be used to decrypt with (remove the backslashes): eval $afield$=$afield$ . \"===\" | decrypt field=$afield$ atob emit('$afield$')```
720+
definition = eval $afield$=null() ```As per https://docs.splunk.com/Documentation/Splunk/latest/Report/Createandeditreports usernames/apps can be base64 encrypted, remove the eval when ready to use this...decrypt2 (splunkbase) can be used to decrypt with (remove the backslashes): eval $afield$=$afield$ . "===" | decrypt field=$afield$ atob emit('$afield$')```
721721
iseval = 0
722722

723723
[dashboard_depends_filter1]
724724
definition = ""
725725
iseval = 0
726726

727727
[dashboard_depends_filter2]
728-
definition = search ```potentially a where clause to only filter when a certain number of tokens exist...```
728+
definition = ```potentially a where clause to only filter when a certain number of tokens exist...``` ""
729729
iseval = 0
730730

731731
[dashboard_depends_filter3]
732-
definition = search ```potentially a where clause to only filter when a certain number of tokens were matched or similar...```
732+
definition = ```potentially a where clause to only filter when a certain number of tokens were matched or similar...``` ""
733733
iseval = 0
734734

735735
[splunkadmins_wineventlog_index]
@@ -800,7 +800,7 @@ definition = eval definition=null(), datamodel3=null(), datamodel1=null(), datam
800800
| lookup splunkadmins_datamodels datamodel AS datamodel_res, splunk_server OUTPUTNEW definition\
801801
| nomv definition \
802802
| eval definition=" " . definition . " "\
803-
| search ```While an mvmap could replace per-datamodel that results in a multivalue output. Also replace doesn't handle a multivalued replacement argument so just replace the first macro if it exists with the definitions of all the datamodels``` \
803+
```While an mvmap could replace per-datamodel that results in a multivalue output. Also replace doesn't handle a multivalued replacement argument so just replace the first macro if it exists with the definitions of all the datamodels``` \
804804
| eval search=if(isnotnull(datamodel_res),replace(search,mvindex(datamodel_res,0),definition),search)
805805
iseval = 0
806806

0 commit comments

Comments
 (0)