Thin client for Azure Monitor DataCollector API.
Project description
A thin client to send log data to Azure Monitor by using the HTTP Data Collector API.
Installation
$ pip install datacollector-api-client
Usage
from datacollector_api_client.client import DataCollectorWrapper
wrapper = DataCollectorWrapper(LOGANALYTICS_WORKSPACE_ID, LOGANALYTICS_WORKSPACE_KEY)
data = [{
"application": "my_app",
"message": "my log message"
}]
response = wrapper.log_info(structured_log_message=data)
print(response)
To log a message as error, use: wrapper.log_error(structured_log_message=data)
You can also override the default name of the tables by setting parameter: log_type=”your_preferred_table_name”
Enriching structured logging with Databricks information
Pass your dbutils instance from your Databricks session to the library
wrapper = DataCollectorWrapper(LOGANALYTICS_WORKSPACE_ID, LOGANALYTICS_WORKSPACE_KEY, dbutils)
data = [{
"application": "Notebook",
"message": f'Number of rows in dataframe: {df.count()}'
}]
response = wrapper.log_info(structured_log_message=data)
print(response)
- The following data is also collected and appended to your log:
dbutils.notebook.entry_point.getDbutils().notebook().getContext().notebookPath().get()
dbutils.notebook.entry_point.getDbutils().notebook().getContext().tags().apply(‘clusterId’)
dbutils.notebook.entry_point.getDbutils().notebook().getContext().tags().apply(‘sessionId’)
dbutils.notebook.entry_point.getDbutils().notebook().getContext().tags().apply(‘user’)
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
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 datacollector-api-client-0.1.4.tar.gz.
File metadata
- Download URL: datacollector-api-client-0.1.4.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.10 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d41d95aa1486599f24d02407603a6cc0b8fe0ff3d2217f35f8bd2f9e4644c0f
|
|
| MD5 |
fe166bdf7758314081455c515057674c
|
|
| BLAKE2b-256 |
d4ea1b5d7481160865453e6f14d2e9b714d719144f8691bf72a0d927a08810fc
|
File details
Details for the file datacollector_api_client-0.1.4-py3-none-any.whl.
File metadata
- Download URL: datacollector_api_client-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.10 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cb8f0e34a6fee6eaff035b6cc896c8ff97bc2f4ad46f293979b2a6700e08008
|
|
| MD5 |
83d17c48d075eef2d6e8c5ca1b0eec7f
|
|
| BLAKE2b-256 |
cf3a9652a74e7456423ed0e8fed05ed59c4df1fe0e52bfadc025d74ce9945377
|