You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* added queryresource
* update autorest version
* update autorest.md
* test
* test example
* documentation
Co-authored-by: Charles Lowell <10964656+chlowell@users.noreply.github.com>
---------
Co-authored-by: Charles Lowell <10964656+chlowell@users.noreply.github.com>
Copy file name to clipboardExpand all lines: sdk/monitor/azquery/README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,8 +13,8 @@ The Azure Monitor Query client module is used to execute read-only queries again
13
13
14
14
* Go, version 1.18 or higher - [Install Go](https://go.dev/doc/install)
15
15
* Azure subscription - [Create a free account][azure_sub]
16
-
* To query logs, an Azure Log Analytics workspace ID - Create an [Azure Log Analytics workspace][log_analytics_workspace_create]
17
-
* To query metrics, the Resource URI of an Azure resource (Storage Account, Key Vault, CosmosDB, etc.) that you plan to monitor
16
+
* To query some logs, an Azure Log Analytics workspace ID - Create an [Azure Log Analytics workspace][log_analytics_workspace_create]
17
+
* To query metrics and some logs, the Resource URI of an Azure resource (Storage Account, Key Vault, CosmosDB, etc.) that you plan to monitor
18
18
19
19
### Install the packages
20
20
@@ -100,7 +100,7 @@ To do the same with `QueryBatch`, set the values in the `BatchQueryRequest.Heade
100
100
101
101
Get started with our [examples][azquery_pkg_go_samples].
102
102
103
-
* For the majority of log queries, use the `LogsClient.QueryWorkspace` method. Only use the `LogsClient.QueryBatch` method in advanced scenerios.
103
+
* For the majority of log queries, use the `LogsClient.QueryWorkspace`or the `LogsClient.QueryResource`method. Only use the `LogsClient.QueryBatch` method in advanced scenerios.
104
104
105
105
* Use `MetricsClient.QueryResource` for metric queries.
// Instead of requiring a Log Analytics workspace,
156
+
// QueryResource allows users to query logs directly from an Azure resource through a resource ID.
157
+
158
+
// To find the resource ID:
159
+
// 1. Navigate to your resource's page in the Azure portal.
160
+
// 2. From the **Overview** blade, select the **JSON View** link.
161
+
// 3. In the resulting JSON, copy the value of the `id` property.
162
+
163
+
resourceID:="/subscriptions/fajfkx93-c1d8-40ad-9cce-e49c10ca8qe6/resourceGroups/testgroup/providers/Microsoft.Storage/storageAccounts/mystorageacount"// example resource ID
164
+
165
+
res, err:=logsClient.QueryResource(
166
+
context.TODO(),
167
+
resourceID,
168
+
azquery.Body{
169
+
Query: to.Ptr("StorageBlobLogs | where TimeGenerated > ago(3d)"), // example Kusto query
0 commit comments