{"id":24636,"library":"splunk-hec-handler","title":"splunk-hec-handler","description":"A Python logging handler that sends logs to Splunk via HTTP Event Collector (HEC). Current version 1.2.0, maintained on GitHub with occasional updates.","status":"active","version":"1.2.0","language":"python","source_language":"en","source_url":"https://github.com/vavarachen/splunk_hec_handler","tags":["logging","splunk","hec","handler"],"install":[{"cmd":"pip install splunk-hec-handler","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"SplunkHecHandler","correct":"from splunk_hec_handler import SplunkHecHandler"},{"note":"Incorrect: leads to ModuleNotFoundError","wrong":"import SplunkHecHandler","symbol":"SplunkHecHandler","correct":"from splunk_hec_handler import SplunkHecHandler"}],"quickstart":{"code":"import logging\nfrom splunk_hec_handler import SplunkHecHandler\n\nlogger = logging.getLogger('splunk')\nlogger.setLevel(logging.DEBUG)\nhandler = SplunkHecHandler(\n    'https://splunkhec.example.com',\n    token='your-hec-token',\n    source='python',\n    sourcetype='json',\n    index='main'\n)\nlogger.addHandler(handler)\nlogger.info('Test message')\n","lang":"python","description":"Basic setup: create handler with HEC URL and token, add to logger, log a test message."},"warnings":[{"fix":"Initialize handler with verify=False (not recommended for production) or pass a valid cert path.","message":"The handler uses HTTP POST by default. If your Splunk HEC endpoint uses HTTPS with a self-signed certificate, you must set verify=False or provide a CA bundle.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add a custom error handler via logging.Handler.handleError or monitor your Splunk HEC endpoint for 401/403 errors.","message":"The handler silently drops logs if HEC token is invalid or endpoint unreachable, unless you add a custom error handler.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install with 'pip install splunk-hec-handler' and import with 'from splunk_hec_handler import SplunkHecHandler'.","cause":"Package not installed or import name misspelled (underscore vs hyphen). Correct import is 'splunk_hec_handler' (underscores).","error":"ModuleNotFoundError: No module named 'splunk_hec_handler'"},{"fix":"Use 'from splunk_hec_handler import SplunkHecHandler'.","cause":"Incorrect import style (e.g., import splunk_hec_handler then splunk_hec_handler.SplunkHecHandler should work; but if using old version or typo, fails).","error":"AttributeError: module 'splunk_hec_handler' has no attribute 'SplunkHecHandler'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}