observe-http-sender


Nameobserve-http-sender JSON
Version 1.3.3 PyPI version JSON
download
home_pagehttps://github.com/observeinc/observe-http-sender-python
SummaryA Python class to send events to an Observe Inc Datastream via the HTTP API endpoint
upload_time2024-03-16 22:05:50
maintainer
docs_urlNone
authorObserve Inc
requires_python>=3.7
license
keywords observeinc http ingest
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Class for Sending Data to ObserveInc HTTP Endpoint

Version/Date: 1.3.3 2024-3-16

## Description:

This is a python class to send events to an Observe Inc Datastream via the [HTTP API endpoint](https://docs.observeinc.com/en/latest/content/data-ingestion/endpoints/http.html).

## Using this Python Class

### Usage: Manual

You will need to put this with any other code and import the class as needed.
1. Instantiate a copy of the `ObserveHttpSender` object
1. Submit JSON dictionary payload(s) via the `post_observation` method.
1. Call the `flush` method to ensure any non batched payload data is flushed to Observe.

### Usage: With pip3

    pip3 install observe-http-sender

Once installed you can start python try the following.

#### Python Test:

    from observe_http_sender import ObserveHttpSender 
    help(ObserveHttpSender)

### Getting Started:

The arguments needed to initialize an Observer:

* OBSERVE_URL -- The base Observe customer URL - required (Example: https://154418444508.observeinc.com/)
* OBSERVE_TOKEN -- The configured Datastream API Token - required

#### Python Usage:

    from observe_http_sender import ObserveHttpSender

    # Setup Observer and its logging level.
    observer = ObserveHttpSender(OBSERVE_URL,OBSERVE_TOKEN)
    observer.log.setLevel(logging.INFO)

### Logging

You may use logging by setting up a logger in your code from the `import logging` module.

    logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S %z')
    logger = logging.getLogger(u"OBSERVE_EXAMPLE")
    logger.setLevel(logging.INFO)

You may set a different logging level for the `ObserveHttpSender` class.

    # Setup Observer and its logging level.
    observer = ObserveHttpSender(OBSERVE_CUSTOMER,OBSERVE_TOKEN,OBSERVE_DOMAIN)
    observer.log.setLevel(logging.INFO)
    
# Notes:

* The `check_connectivity` method that is optional but recommended before attempting to submit large amounts of data to Observe. See example.py for use and docstrings on the method for details.
* You MUST call the method `flush` before your code completes to ensure all remaining non batch posted data is sent to Observe.
* Methods `get_pop_empty_fields` and `set_pop_empty_fields`. Defaults to True to remove empty/null fields from payloads to save ingestion cost.
* Methods `get_payload_json_format` and `set_payload_json_format`. Defaults to True to post payload in format `application/json`. False will post the payload in format `text/plain` Set this at instantiation for text payloads.
* Methods `get_post_path` and `set_post_path`. Defaults to None append an optional path segment example `/orca/alerts`. This will show in the Datastream EXTRAS field as `path`.

# Example Usage:

The included python script `example-postcsv.py` takes a csv file with a header row and posts it to Observe in JSON format.

Usage: 

    python3 example-postcsv.py data/sample-authevents.csv


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/observeinc/observe-http-sender-python",
    "name": "observe-http-sender",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "observeinc,http,ingest",
    "author": "Observe Inc",
    "author_email": "Observe Inc <devinfra@observeinc.com>",
    "download_url": "https://files.pythonhosted.org/packages/94/30/3af1e5f18a1a5ddafd71ea23fe5b252bd7b7a6075a4572dd8e02c2890327/observe-http-sender-1.3.3.tar.gz",
    "platform": null,
    "description": "# Python Class for Sending Data to ObserveInc HTTP Endpoint\n\nVersion/Date: 1.3.3 2024-3-16\n\n## Description:\n\nThis is a python class to send events to an Observe Inc Datastream via the [HTTP API endpoint](https://docs.observeinc.com/en/latest/content/data-ingestion/endpoints/http.html).\n\n## Using this Python Class\n\n### Usage: Manual\n\nYou will need to put this with any other code and import the class as needed.\n1. Instantiate a copy of the `ObserveHttpSender` object\n1. Submit JSON dictionary payload(s) via the `post_observation` method.\n1. Call the `flush` method to ensure any non batched payload data is flushed to Observe.\n\n### Usage: With pip3\n\n    pip3 install observe-http-sender\n\nOnce installed you can start python try the following.\n\n#### Python Test:\n\n    from observe_http_sender import ObserveHttpSender \n    help(ObserveHttpSender)\n\n### Getting Started:\n\nThe arguments needed to initialize an Observer:\n\n* OBSERVE_URL -- The base Observe customer URL - required (Example: https://154418444508.observeinc.com/)\n* OBSERVE_TOKEN -- The configured Datastream API Token - required\n\n#### Python Usage:\n\n    from observe_http_sender import ObserveHttpSender\n\n    # Setup Observer and its logging level.\n    observer = ObserveHttpSender(OBSERVE_URL,OBSERVE_TOKEN)\n    observer.log.setLevel(logging.INFO)\n\n### Logging\n\nYou may use logging by setting up a logger in your code from the `import logging` module.\n\n    logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S %z')\n    logger = logging.getLogger(u\"OBSERVE_EXAMPLE\")\n    logger.setLevel(logging.INFO)\n\nYou may set a different logging level for the `ObserveHttpSender` class.\n\n    # Setup Observer and its logging level.\n    observer = ObserveHttpSender(OBSERVE_CUSTOMER,OBSERVE_TOKEN,OBSERVE_DOMAIN)\n    observer.log.setLevel(logging.INFO)\n    \n# Notes:\n\n* The `check_connectivity` method that is optional but recommended before attempting to submit large amounts of data to Observe. See example.py for use and docstrings on the method for details.\n* You MUST call the method `flush` before your code completes to ensure all remaining non batch posted data is sent to Observe.\n* Methods `get_pop_empty_fields` and `set_pop_empty_fields`. Defaults to True to remove empty/null fields from payloads to save ingestion cost.\n* Methods `get_payload_json_format` and `set_payload_json_format`. Defaults to True to post payload in format `application/json`. False will post the payload in format `text/plain` Set this at instantiation for text payloads.\n* Methods `get_post_path` and `set_post_path`. Defaults to None append an optional path segment example `/orca/alerts`. This will show in the Datastream EXTRAS field as `path`.\n\n# Example Usage:\n\nThe included python script `example-postcsv.py` takes a csv file with a header row and posts it to Observe in JSON format.\n\nUsage: \n\n    python3 example-postcsv.py data/sample-authevents.csv\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Python class to send events to an Observe Inc Datastream via the HTTP API endpoint",
    "version": "1.3.3",
    "project_urls": {
        "Download": "https://github.com/observeinc/observe-http-sender-python/archive/refs/heads/main.zip",
        "Homepage": "https://github.com/observeinc/observe-http-sender-python",
        "Issues": "https://github.com/observeinc/observe-http-sender-python/issues"
    },
    "split_keywords": [
        "observeinc",
        "http",
        "ingest"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "696044ee1ad0bfbca711ddfcade8889da26e8d363d67e7662052df551476e14e",
                "md5": "11286eec055254b756355a89ef06d84e",
                "sha256": "cb6584ffb50967fbc0837b4cd55b97c70171e493cdfe36311b72ee77212ac84b"
            },
            "downloads": -1,
            "filename": "observe_http_sender-1.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "11286eec055254b756355a89ef06d84e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9098,
            "upload_time": "2024-03-16T22:05:48",
            "upload_time_iso_8601": "2024-03-16T22:05:48.889215Z",
            "url": "https://files.pythonhosted.org/packages/69/60/44ee1ad0bfbca711ddfcade8889da26e8d363d67e7662052df551476e14e/observe_http_sender-1.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "94303af1e5f18a1a5ddafd71ea23fe5b252bd7b7a6075a4572dd8e02c2890327",
                "md5": "86a947d7898433630a7ac13aa3463963",
                "sha256": "ca77dd1e31dc1eed5895ccc6a24dc1265ef114f73c0b0157eeffe7df21c6cdfc"
            },
            "downloads": -1,
            "filename": "observe-http-sender-1.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "86a947d7898433630a7ac13aa3463963",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 9235,
            "upload_time": "2024-03-16T22:05:50",
            "upload_time_iso_8601": "2024-03-16T22:05:50.731985Z",
            "url": "https://files.pythonhosted.org/packages/94/30/3af1e5f18a1a5ddafd71ea23fe5b252bd7b7a6075a4572dd8e02c2890327/observe-http-sender-1.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-16 22:05:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "observeinc",
    "github_project": "observe-http-sender-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "observe-http-sender"
}
        
Elapsed time: 0.77983s