An R6 class that extends api_client to provide a Kusto Query Language
(KQL) query() method against the public Azure Log Analytics REST API,
bound to a specific Azure subscription and resource group at construction.
Details
The client is bound to subscription_id and resource_id (the resource
group name) at construction. The $query() method issues a POST to
https://{endpoint}/{api_version}/subscriptions/{subscription_id}/resourceGroups/{resource_id}/query
with a JSON body ({"query": ..., "timespan": ..., "workspaces": [...]}).
Pass scope = "hierarchy" (or any other supported query-string parameter)
via ... on $query() to traverse the resource hierarchy.
Super class
azr::api_client -> api_log_analytics_client
Public fields
.subscription_idThe Azure subscription ID the client is bound to.
.resource_idThe Azure resource group name the client is bound to.
.api_versionThe API version segment prepended to all query paths.
Methods
Method new()
Create a new Azure Log Analytics API client instance bound to a specific subscription and resource group.
Usage
api_log_analytics_client$new(
subscription_id,
resource_id,
endpoint = default_log_analytics_endpoint(),
api_version = "v1",
scope = default_azure_scope("azure_log_analytics"),
provider = NULL,
chain = NULL,
tenant_id = NULL,
...
)Arguments
subscription_idA character string specifying the Azure subscription ID (GUID) to bind the client to.
resource_idA character string specifying the Azure resource group name to bind the client to.
endpointA character string specifying the Log Analytics query endpoint host (e.g.
"api.loganalytics.io"). Defaults todefault_log_analytics_endpoint(). Any leadinghttps?://scheme or trailing slashes are stripped.api_versionA character string specifying the API version segment prepended to the query path. Defaults to
"v1".scopeA character string specifying the OAuth2 scope. Defaults to
default_azure_scope("azure_log_analytics").providerAn optional credential provider object that inherits from
CredentialorDefaultCredential. If provided,chainis ignored.chainA credential_chain instance for authentication. If
NULL, a default credential chain is created using DefaultCredential.tenant_idA character string specifying the Azure tenant ID. Passed to DefaultCredential when
chainisNULL....Additional arguments passed to the parent api_client constructor.
Method query()
Issue a KQL query against the bound subscription and resource group.
Arguments
queryA character string containing the KQL query to execute.
date_fromStart of the time range as a
DateorPOSIXct. When provided together withdate_to, appends| where TimeGenerated between(datetime(...), datetime(...))to the query and setstimespantoNULL. Defaults toSys.Date() - 3.date_toEnd of the time range as a
DateorPOSIXct. Defaults toSys.Date() + 1.timespanAn ISO 8601 duration (e.g.
"PT12H") or start/end pair separated by/(e.g."2024-01-01/2024-01-02"). Passed as a URL query parameter. Ignored whendate_fromanddate_toare set. Defaults toNULL.max_rowsMaximum number of rows to return. Defaults to
500001.optionsA named list of query options. Defaults to
list(truncationMaxSize = 67108864).workspace_filtersA named list of workspace filters. Defaults to
list(regions = list())....Additional URL query parameters. Override defaults (e.g.
scope = "resource"to change from the default"hierarchy").rawIf
TRUE, returns the parsed JSON response as a list. IfFALSE(the default), returns a named list ofdata.frames — one per table in the response — or the single table directly if only one is returned.coerce_typesIf
TRUE(the default), columns are coerced to their native R types based on the Log Analytics schema (e.g.datetime→POSIXct,bool→logical). Set toFALSEto keep all values as character.
