A Python class to send events to an Observe Inc Datastream via the HTTP API endpoint
Project description
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.
Using this Python Class
Usage: Manual
You will need to put this with any other code and import the class as needed.
- Instantiate a copy of the
ObserveHttpSenderobject - Submit JSON dictionary payload(s) via the
post_observationmethod. - Call the
flushmethod 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_connectivitymethod 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
flushbefore your code completes to ensure all remaining non batch posted data is sent to Observe. - Methods
get_pop_empty_fieldsandset_pop_empty_fields. Defaults to True to remove empty/null fields from payloads to save ingestion cost. - Methods
get_payload_json_formatandset_payload_json_format. Defaults to True to post payload in formatapplication/json. False will post the payload in formattext/plainSet this at instantiation for text payloads. - Methods
get_post_pathandset_post_path. Defaults to None append an optional path segment example/orca/alerts. This will show in the Datastream EXTRAS field aspath.
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file observe-http-sender-1.3.3.tar.gz.
File metadata
- Download URL: observe-http-sender-1.3.3.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca77dd1e31dc1eed5895ccc6a24dc1265ef114f73c0b0157eeffe7df21c6cdfc
|
|
| MD5 |
86a947d7898433630a7ac13aa3463963
|
|
| BLAKE2b-256 |
94303af1e5f18a1a5ddafd71ea23fe5b252bd7b7a6075a4572dd8e02c2890327
|
File details
Details for the file observe_http_sender-1.3.3-py3-none-any.whl.
File metadata
- Download URL: observe_http_sender-1.3.3-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb6584ffb50967fbc0837b4cd55b97c70171e493cdfe36311b72ee77212ac84b
|
|
| MD5 |
11286eec055254b756355a89ef06d84e
|
|
| BLAKE2b-256 |
696044ee1ad0bfbca711ddfcade8889da26e8d363d67e7662052df551476e14e
|