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)

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.2.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

datacollector_api_client-0.1.2-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

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