All Apps and Add-ons

What Is the advised way to log exceptions from a Python onboarding script to Splunk?

sboogaar
Path Finder

What Is the advised way to log exceptions from a Python onboarding script to Splunk.
e.g when I have:

except TypeError as te:
    print("Type Error: %s" % te)
except Exception as e:
    print("Unhandled Error is %s" % e)

I want to log it inside Splunk so I can see what went wrong. I do not want to log it to the source type of the onboarding script but prefer to have it in _internal so if there is no data for a source type I know right away something is wrong without having to know anything about the expected format of the events. (results = 0 means something is wrong).

PS How do I add the tag data-onboarding?

0 Karma

DavidHourani
Super Champion

Hi @sboogaar,

Adding tags can be done as shown here :
http://docs.splunk.com/Documentation/Splunk/7.2.1/SearchReference/Tags

You can create your tags based on eventtypes in eventtypes.conf and save them in tags.conf.

As for generating logs into _internal or somewhere else please have a look here :
https://answers.splunk.com/answers/567938/where-do-i-find-the-python-log-of-a-custom-endpoin.html

Python logs are by default logged into:
$SPLUNK_HOME/var/log/splunk/python.log

Cheers,
David

0 Karma

sboogaar
Path Finder

With the tag I ment a tag for this question 😉

0 Karma

DavidHourani
Super Champion

hahaha that's a meta question. When you're asking the question you can scroll down and chose which product it affects and add a tag, you can also edit and include it if needed ^^

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...