Registry / azure / azure-loganalytics

azure-loganalytics

JSON →
library0.1.1pypypi✓ verified 23d ago

This is an older Microsoft Azure client library for interacting with Azure Log Analytics. It is no longer maintained and has been officially deprecated. For querying data, users are advised to migrate to the `azure-monitor-query` library. For ingesting data into Log Analytics, the `azure-monitor-ingestion` library should be used. The last stable release for this package was 0.1.1 in 2021.

pip install azure-loganalytics
INSTALL
IMPORT
SIG · AZURE-LOGANALYTICS
A
azure-loganalytics
azurepythonv0.1.1
Install
3.2s avg
Import
Disk
54MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 99.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.2s · import 0.000s · 26MB
54MB installed
● package 54MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LogsQueryClient
from azure.loganalytics.models import LogsQueryClient
from azure.loganalytics import LogsQueryClient

This quickstart demonstrates how to query Azure Log Analytics using the recommended `azure-monitor-query` client library. It authenticates using `DefaultAzureCredential` (which leverages environment variables or Azure CLI login) and executes a Kusto Query Language (KQL) query against a specified Log Analytics workspace. Replace `<your_log_analytics_workspace_id>` with your actual workspace ID.

import os from azure.identity import DefaultAzureCredential from azure.monitor.query import LogsQueryClient from datetime import timedelta # Set your Log Analytics Workspace ID # Can be found in the Azure portal under your Log Analytics workspace's 'Overview' page LOGS_WORKSPACE_ID = os.environ.get("LOGS_WORKSPACE_ID", "<your_log_analytics_workspace_id>") # Authenticate using DefaultAzureCredential # Ensure environment variables AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET are set, # or you are logged in via 'az login' (Azure CLI) for this to work automatically. credential = DefaultAzureCredential() # Create a LogsQueryClient client = LogsQueryClient(credential) # Define a Kusto Query Language (KQL) query query = """ AzureActivity | summarize count() by ResourceGroup | limit 5 """ try: # Execute the query for data from the last 1 day response = client.query_workspace( LOGS_WORKSPACE_ID, query, timespan=timedelta(days=1) ) # Process and print the results if response.tables: for table in response.tables: print(f"\nTable: {table.name}") print(f"Columns: {[col.name for col in table.columns]}") for row in table.rows: print(row) else: print("No results found for the query.") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingThe `azure-loganalytics` package (0.1.1) is no longer maintained and has been deprecated. It will not receive new features or bug fixes. Continued use is not recommended for production environments.
fix
Migrate your code to use `azure-monitor-query` for querying logs and `azure-monitor-ingestion` for sending custom logs. Install them via `pip install azure-monitor-query azure-monitor-ingestion azure-identity`.
affects: 0.1.0, 0.1.1
deprecatedThe functionality for querying Azure Log Analytics programmatically has been moved to the `azure-monitor-query` library, and for ingesting data to `azure-monitor-ingestion`. These new libraries offer improved features, async support, and consistent Azure SDK patterns.
fix
Refactor your application to use `LogsQueryClient` from `azure.monitor.query` and `LogsIngestionClient` from `azure.monitor.ingestion`. Refer to their respective documentation for migration guidance.
affects: 0.1.0, 0.1.1
gotchaThere are multiple Azure Python packages related to Log Analytics. `azure-loganalytics` (this package) is for data operations and is deprecated. `azure-mgmt-loganalytics` is for *managing* Log Analytics workspaces (e.g., creating, updating, deleting workspaces). The modern data querying library is `azure-monitor-query`.
fix
Ensure you are using the correct library for your task: `azure-mgmt-loganalytics` for management tasks, and `azure-monitor-query` for querying logs.
affects: All versions
gotchaAuthentication for modern Azure SDK client libraries relies on `azure-identity`. Older `azure-loganalytics` (if still used) might have different, outdated authentication patterns. `DefaultAzureCredential` is the recommended way to authenticate for new libraries.
fix
Install `azure-identity` and use `DefaultAzureCredential`. Set environment variables like `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET` or use `az login` via Azure CLI to enable automatic authentication.
affects: All versions
Upgrade
Version history
0.1.1latest on PyPI · released Nov 12, 2021
Audit
Dependencies
azure-identityrequiredRequired for authentication with Azure Monitor Query and Ingestion client libraries.
azure-monitor-queryrequiredRecommended replacement for querying Log Analytics data.
azure-monitor-ingestionrequiredRecommended replacement for ingesting data into Log Analytics.
Agent activity
35 hits · last 30 days
node
28
OpenAI (training)
1
Resources