Skip to main content

Simple splunk log python package.

Project description

This is a package for internal use only. Use with Python 3.8+.

Usage

On command line:

$ pip install pysplunk

Add this code to the entryfile:

from pysplunk import splunk
splunk.configure_logger(
    index="index_name",
    token="splunk_token",
    version="1.0.0",
    env="production",
    level="DEBUG")

To log something:

splunk.loginfo(
    account=account_id,
    workflowtype="workflow_type",
    workflowinstance="workflow_instance",
    msg="message",
    customfields={"customField1": 3})

splunk.logdebug(
    account=account_id,
    workflowtype="workflow_type",
    workflowinstance="workflow_instance",
    msg="message",
    customfields={"customField1": 3})

splunk.logwarn(
    account=account_id,
    workflowtype="workflow_type",
    workflowinstance="workflow_instance",
    msg="message",
    customfields={"customField1": 1, "customField2": "2"})

splunk.logerror(
    account=account_id,
    workflowtype="workflow_type",
    workflowinstance="workflow_instance",
    msg="message",
    customfields={"customField1": 1},
    evidencia="Exception traceback")

Definitions

  • account: An integer representing the ID of the logged account.

  • workflowtype: Some identification for the overall operation, example: “login”.

  • workflowinstance: Some identification for the specific part of the operation, examples “start_login”, “login_error”, “superuser_login”, etc

  • msg: A desciptive message of the log.

  • customfields: Additional fields, examples: “operation_id”, “user_id”, “product_id”, etc.

  • evidencia: Some string evidence (can be multiline) to attach into the log. This is convenient to add exceptions or API responses.

Configuration

  • AEROSPIKE_EVIDENCE_URL URL for aerospike

  • AEROSPIKE_EVIDENCE_TTL TTL for aerospike evidence, default: 2592000 seconds

  • AEROSPIKE_EVIDENCE_TIMEOUT Timetou for sending data to aerospike, default: 0.800 seconds

  • SPLUNK_URL URL for splunk

  • SPLUNK_LOG_FORMAT Splunk log format, default is set in splunk.py

  • SPLUNK_LOG_HANDLER_NAME Handler for splunk log, default: Log

Requirements

splunkfowarder is required for this package work.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysplunk-1.0.0.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file pysplunk-1.0.0.tar.gz.

File metadata

  • Download URL: pysplunk-1.0.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.2

File hashes

Hashes for pysplunk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b6922de1cd81be3820db72c4caacdadf64d75bb0031cc4e4940ff5ac76ebf4cb
MD5 488991925ec4cf5271abea21b0f52281
BLAKE2b-256 22a03af3ac8b975c209051d8d7fce4b79bed7e5d7741c38f95f69de7759250a4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page