Knowledge Management

Where to put macros.conf so available everywhere (all users/apps/searches)?

woodcock
Esteemed Legend

The subject has the entirety of my question but as a bonus to anyone who reads this, here is a macro that everyone should find useful (if you understand why this is useful, add that to your answer):

[unknownify(1)]
args = FieldName
definition = eval $FieldName$=if(isnull($FieldName$),"unknown",$FieldName$)
[unknownify(2)]
args = FieldName, UnknownText
definition = eval $FieldName$=if(isnull($FieldName$),"$UnknownText$",$FieldName$)
Tags (3)
1 Solution

_d_
Splunk Employee
Splunk Employee

You need to give your macro enough permissions to be available for use everywhere. You can use the UI to do this or you can use the local.meta and export it to system. Assuming you have your macros.conf in /opt/splunk/etc/apps/distsearch_base/local/, then in /opt/splunk/etc/apps/distsearch_base/metadata/local.meta you need to enter the following:

[macros]
export = system

This stanza will export all macros defined in macros.conf in that app/config bundle to system so that they'll available to all users/apps etc.

Hope this helps.

> please upvote and accept answer if you find it useful - thanks!

View solution in original post

woodcock
Esteemed Legend
Adding the local.meta change and putting the file in this directory DID work:
/opt/splunk/etc/apps/searcher_base/local/

It did NOT work when put here:
/opt/splunk/etc/apps/distsearch_base/local/
0 Karma

_d_
Splunk Employee
Splunk Employee

I just assumed you had your macros in distsearch_base. But, nonetheless, it's good to hear that your problem is resolved. Please consider upvoting marking the question as answered. Thanks. 🙂

0 Karma

_d_
Splunk Employee
Splunk Employee

You need to give your macro enough permissions to be available for use everywhere. You can use the UI to do this or you can use the local.meta and export it to system. Assuming you have your macros.conf in /opt/splunk/etc/apps/distsearch_base/local/, then in /opt/splunk/etc/apps/distsearch_base/metadata/local.meta you need to enter the following:

[macros]
export = system

This stanza will export all macros defined in macros.conf in that app/config bundle to system so that they'll available to all users/apps etc.

Hope this helps.

> please upvote and accept answer if you find it useful - thanks!

woodcock
Esteemed Legend

I should have mentioned what I tried, none of which worked:

/opt/splunk/etc/system/local/

/opt/splunk/etc/apps/distsearch_base/local/

/opt/splunk/etc/apps/forwarder_base/local/

/opt/splunk/etc/apps/indexer_cluster_base/local/

/opt/splunk/etc/apps/searcher_base/local/

/opt/splunk/etc/apps/splunk_base/local/

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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...