Skip to main content

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.

Linux and Windows build status

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

datacollector-api-client-0.1.4.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datacollector_api_client-0.1.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

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

Hashes for datacollector-api-client-0.1.4.tar.gz
Algorithm Hash digest
SHA256 4d41d95aa1486599f24d02407603a6cc0b8fe0ff3d2217f35f8bd2f9e4644c0f
MD5 fe166bdf7758314081455c515057674c
BLAKE2b-256 d4ea1b5d7481160865453e6f14d2e9b714d719144f8691bf72a0d927a08810fc

See more details on using hashes here.

File details

Details for the file datacollector_api_client-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for datacollector_api_client-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4cb8f0e34a6fee6eaff035b6cc896c8ff97bc2f4ad46f293979b2a6700e08008
MD5 83d17c48d075eef2d6e8c5ca1b0eec7f
BLAKE2b-256 cf3a9652a74e7456423ed0e8fed05ed59c4df1fe0e52bfadc025d74ce9945377

See more details on using hashes here.

Supported by

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