Splunk Dev

Custom Alert Action - How to get search head DNS name?

hughkelley
Path Finder

I was expecting to find a helper object function for this, but I don't see one here:

https://docs.splunk.com/Documentation/AddonBuilder/4.1.1/UserGuide/PythonHelperFunctions

I want to use the DNS name/URL of the search head in my alert action code.   How can this be accessed (Splunk cloud, if it matters)?    At least in my local test server,  I see this, but it returns an IP address, not a DNS name.

helper.settings["server_uri"]
0 Karma

hughkelley
Path Finder

This was suggested to me by a colleague (reading the email alert action link hostname) .   This works nicely for me inside AOB code:

 

from splunk.clilib import cli_common as cli

def process_event(helper, *args, **kwargs):
   alert_actions_config = cli.getMergedConf("alert_actions")
    alert_actions_hostname = alert_actions_config.get("email", {}).get("hostname", None)
    if alert_actions_hostname:
        helper.log_debug("Alert action hostname: {}".format(alert_actions_hostname))

 

isoutamo
SplunkTrust
SplunkTrust

Hi

will splunk_server be your answer? 

At least rest return it for me 

| rest splunk_server=local /services/server/sysinfo f=splunk_server
| table splunk_server

Of course if you have set it to something else then it didn't work.

r. Ismo 

0 Karma

hughkelley
Path Finder

I'm afraid that returns the actual hostname, not the DNS name used for the UI and API.

sh-0000000000.XXX.splunkcloud.com

0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco + Splunk! We’ve ...