[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71801KW1VSVFXGF8S4P3GFN":3,"skill-same:01M71801KW1VSVFXGF8S4P3GFN":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":14,"repositoryHtmlUrl":47,"repositoryHomepageUrl":6,"ownerHtmlUrl":48,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":49,"install":50,"resources":63},"01M71801KW1VSVFXGF8S4P3GFN","azure-monitor-query-java",null,"Azure Monitor Query SDK for Java. Execute Kusto queries against Log Analytics workspaces and query metrics from Azure resources.","sapsapshen\u002Fai-memory-router","sapsapshen","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F20347959?v=4","01M6XDQEF1DP50DKF37H81J3J5","shenmian","01M6XDQEJPE41Y3DT2763X8ZJN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fglobal\u002Fazure-monitor-query-java\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"query","monitor","azure","java","azure monitor query java","azure monitor","execute","query metrics","sdk","queries","for","metrics","analytics","safe","2026","log","workspaces","resources","community","2026-11-10 10:12:30",false,"---\nname: azure-monitor-query-java\ndescription: Azure Monitor Query SDK for Java. Execute Kusto queries against Log Analytics workspaces and query metrics from Azure resources.\nrisk: safe\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure Monitor Query SDK for Java\n\n> **DEPRECATION NOTICE**: This package is deprecated in favor of:\n> - `azure-monitor-query-logs` — For Log Analytics queries\n> - `azure-monitor-query-metrics` — For metrics queries\n>\n> See migration guides: [Logs Migration](https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-java\u002Fblob\u002Fmain\u002Fsdk\u002Fmonitor\u002Fazure-monitor-query-logs\u002Fmigration-guide.md) | [Metrics Migration](https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-java\u002Fblob\u002Fmain\u002Fsdk\u002Fmonitor\u002Fazure-monitor-query-metrics\u002Fmigration-guide.md)\n\nClient library for querying Azure Monitor Logs and Metrics.\n\n## Installation\n\n```xml\n\u003Cdependency>\n    \u003CgroupId>com.azure\u003C\u002FgroupId>\n    \u003CartifactId>azure-monitor-query\u003C\u002FartifactId>\n    \u003Cversion>1.5.9\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\nOr use Azure SDK BOM:\n\n```xml\n\u003CdependencyManagement>\n    \u003Cdependencies>\n        \u003Cdependency>\n            \u003CgroupId>com.azure\u003C\u002FgroupId>\n            \u003CartifactId>azure-sdk-bom\u003C\u002FartifactId>\n            \u003Cversion>{bom_version}\u003C\u002Fversion>\n            \u003Ctype>pom\u003C\u002Ftype>\n            \u003Cscope>import\u003C\u002Fscope>\n        \u003C\u002Fdependency>\n    \u003C\u002Fdependencies>\n\u003C\u002FdependencyManagement>\n\n\u003Cdependencies>\n    \u003Cdependency>\n        \u003CgroupId>com.azure\u003C\u002FgroupId>\n        \u003CartifactId>azure-monitor-query\u003C\u002FartifactId>\n    \u003C\u002Fdependency>\n\u003C\u002Fdependencies>\n```\n\n## Prerequisites\n\n- Log Analytics workspace (for logs queries)\n- Azure resource (for metrics queries)\n- TokenCredential with appropriate permissions\n\n## Environment Variables\n\n```bash\nLOG_ANALYTICS_WORKSPACE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\nAZURE_RESOURCE_ID=\u002Fsubscriptions\u002F{sub}\u002FresourceGroups\u002F{rg}\u002Fproviders\u002F{provider}\u002F{resource}\n```\n\n## Client Creation\n\n### LogsQueryClient (Sync)\n\n```java\nimport com.azure.identity.DefaultAzureCredentialBuilder;\nimport com.azure.monitor.query.LogsQueryClient;\nimport com.azure.monitor.query.LogsQueryClientBuilder;\n\nLogsQueryClient logsClient = new LogsQueryClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .buildClient();\n```\n\n### LogsQueryAsyncClient\n\n```java\nimport com.azure.monitor.query.LogsQueryAsyncClient;\n\nLogsQueryAsyncClient logsAsyncClient = new LogsQueryClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .buildAsyncClient();\n```\n\n### MetricsQueryClient (Sync)\n\n```java\nimport com.azure.monitor.query.MetricsQueryClient;\nimport com.azure.monitor.query.MetricsQueryClientBuilder;\n\nMetricsQueryClient metricsClient = new MetricsQueryClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .buildClient();\n```\n\n### MetricsQueryAsyncClient\n\n```java\nimport com.azure.monitor.query.MetricsQueryAsyncClient;\n\nMetricsQueryAsyncClient metricsAsyncClient = new MetricsQueryClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .buildAsyncClient();\n```\n\n### Sovereign Cloud Configuration\n\n```java\n\u002F\u002F Azure China Cloud - Logs\nLogsQueryClient logsClient = new LogsQueryClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .endpoint(\"https:\u002F\u002Fapi.loganalytics.azure.cn\u002Fv1\")\n    .buildClient();\n\n\u002F\u002F Azure China Cloud - Metrics\nMetricsQueryClient metricsClient = new MetricsQueryClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .endpoint(\"https:\u002F\u002Fmanagement.chinacloudapi.cn\")\n    .buildClient();\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| Logs | Log and performance data from Azure resources via Kusto Query Language |\n| Metrics | Numeric time-series data collected at regular intervals |\n| Workspace ID | Log Analytics workspace identifier |\n| Resource ID | Azure resource URI for metrics queries |\n| QueryTimeInterval | Time range for the query |\n\n## Logs Query Operations\n\n### Basic Query\n\n```java\nimport com.azure.monitor.query.models.LogsQueryResult;\nimport com.azure.monitor.query.models.LogsTableRow;\nimport com.azure.monitor.query.models.QueryTimeInterval;\nimport java.time.Duration;\n\nLogsQueryResult result = logsClient.queryWorkspace(\n    \"{workspace-id}\",\n    \"AzureActivity | summarize count() by ResourceGroup | top 10 by count_\",\n    new QueryTimeInterval(Duration.ofDays(7))\n);\n\nfor (LogsTableRow row : result.getTable().getRows()) {\n    System.out.println(row.getColumnValue(\"ResourceGroup\") + \": \" + row.getColumnValue(\"count_\"));\n}\n```\n\n### Query by Resource ID\n\n```java\nLogsQueryResult result = logsClient.queryResource(\n    \"{resource-id}\",\n    \"AzureMetrics | where TimeGenerated > ago(1h)\",\n    new QueryTimeInterval(Duration.ofDays(1))\n);\n\nfor (LogsTableRow row : result.getTable().getRows()) {\n    System.out.println(row.getColumnValue(\"MetricName\") + \" \" + row.getColumnValue(\"Average\"));\n}\n```\n\n### Map Results to Custom Model\n\n```java\n\u002F\u002F Define model class\npublic class ActivityLog {\n    private String resourceGroup;\n    private String operationName;\n    \n    public String getResourceGroup() { return resourceGroup; }\n    public String getOperationName() { return operationName; }\n}\n\n\u002F\u002F Query with model mapping\nList\u003CActivityLog> logs = logsClient.queryWorkspace(\n    \"{workspace-id}\",\n    \"AzureActivity | project ResourceGroup, OperationName | take 100\",\n    new QueryTimeInterval(Duration.ofDays(2)),\n    ActivityLog.class\n);\n\nfor (ActivityLog log : logs) {\n    System.out.println(log.getOperationName() + \" - \" + log.getResourceGroup());\n}\n```\n\n### Batch Query\n\n```java\nimport com.azure.monitor.query.models.LogsBatchQuery;\nimport com.azure.monitor.query.models.LogsBatchQueryResult;\nimport com.azure.monitor.query.models.LogsBatchQueryResultCollection;\nimport com.azure.core.util.Context;\n\nLogsBatchQuery batchQuery = new LogsBatchQuery();\nString q1 = batchQuery.addWorkspaceQuery(\"{workspace-id}\", \"AzureActivity | count\", new QueryTimeInterval(Duration.ofDays(1)));\nString q2 = batchQuery.addWorkspaceQuery(\"{workspace-id}\", \"Heartbeat | count\", new QueryTimeInterval(Duration.ofDays(1)));\nString q3 = batchQuery.addWorkspaceQuery(\"{workspace-id}\", \"Perf | count\", new QueryTimeInterval(Duration.ofDays(1)));\n\nLogsBatchQueryResultCollection results = logsClient\n    .queryBatchWithResponse(batchQuery, Context.NONE)\n    .getValue();\n\nLogsBatchQueryResult result1 = results.getResult(q1);\nLogsBatchQueryResult result2 = results.getResult(q2);\nLogsBatchQueryResult result3 = results.getResult(q3);\n\n\u002F\u002F Check for failures\nif (result3.getQueryResultStatus() == LogsQueryResultStatus.FAILURE) {\n    System.err.println(\"Query failed: \" + result3.getError().getMessage());\n}\n```\n\n### Query with Options\n\n```java\nimport com.azure.monitor.query.models.LogsQueryOptions;\nimport com.azure.core.http.rest.Response;\n\nLogsQueryOptions options = new LogsQueryOptions()\n    .setServerTimeout(Duration.ofMinutes(10))\n    .setIncludeStatistics(true)\n    .setIncludeVisualization(true);\n\nResponse\u003CLogsQueryResult> response = logsClient.queryWorkspaceWithResponse(\n    \"{workspace-id}\",\n    \"AzureActivity | summarize count() by bin(TimeGenerated, 1h)\",\n    new QueryTimeInterval(Duration.ofDays(7)),\n    options,\n    Context.NONE\n);\n\nLogsQueryResult result = response.getValue();\n\n\u002F\u002F Access statistics\nBinaryData statistics = result.getStatistics();\n\u002F\u002F Access visualization data\nBinaryData visualization = result.getVisualization();\n```\n\n### Query Multiple Workspaces\n\n```java\nimport java.util.Arrays;\n\nLogsQueryOptions options = new LogsQueryOptions()\n    .setAdditionalWorkspaces(Arrays.asList(\"{workspace-id-2}\", \"{workspace-id-3}\"));\n\nResponse\u003CLogsQueryResult> response = logsClient.queryWorkspaceWithResponse(\n    \"{workspace-id-1}\",\n    \"AzureActivity | summarize count() by TenantId\",\n    new QueryTimeInterval(Duration.ofDays(1)),\n    options,\n    Context.NONE\n);\n```\n\n## Metrics Query Operations\n\n### Basic Metrics Query\n\n```java\nimport com.azure.monitor.query.models.MetricsQueryResult;\nimport com.azure.monitor.query.models.MetricResult;\nimport com.azure.monitor.query.models.TimeSeriesElement;\nimport com.azure.monitor.query.models.MetricValue;\nimport java.util.Arrays;\n\nMetricsQueryResult result = metricsClient.queryResource(\n    \"{resource-uri}\",\n    Arrays.asList(\"SuccessfulCalls\", \"TotalCalls\")\n);\n\nfor (MetricResult metric : result.getMetrics()) {\n    System.out.println(\"Metric: \" + metric.getMetricName());\n    for (TimeSeriesElement ts : metric.getTimeSeries()) {\n        System.out.println(\"  Dimensions: \" + ts.getMetadata());\n        for (MetricValue value : ts.getValues()) {\n            System.out.println(\"    \" + value.getTimeStamp() + \": \" + value.getTotal());\n        }\n    }\n}\n```\n\n### Metrics with Aggregations\n\n```java\nimport com.azure.monitor.query.models.MetricsQueryOptions;\nimport com.azure.monitor.query.models.AggregationType;\n\nResponse\u003CMetricsQueryResult> response = metricsClient.queryResourceWithResponse(\n    \"{resource-id}\",\n    Arrays.asList(\"SuccessfulCalls\", \"TotalCalls\"),\n    new MetricsQueryOptions()\n        .setGranularity(Duration.ofHours(1))\n        .setAggregations(Arrays.asList(AggregationType.AVERAGE, AggregationType.COUNT)),\n    Context.NONE\n);\n\nMetricsQueryResult result = response.getValue();\n```\n\n### Query Multiple Resources (MetricsClient)\n\n```java\nimport com.azure.monitor.query.MetricsClient;\nimport com.azure.monitor.query.MetricsClientBuilder;\nimport com.azure.monitor.query.models.MetricsQueryResourcesResult;\n\nMetricsClient metricsClient = new MetricsClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .endpoint(\"{endpoint}\")\n    .buildClient();\n\nMetricsQueryResourcesResult result = metricsClient.queryResources(\n    Arrays.asList(\"{resourceId1}\", \"{resourceId2}\"),\n    Arrays.asList(\"{metric1}\", \"{metric2}\"),\n    \"{metricNamespace}\"\n);\n\nfor (MetricsQueryResult queryResult : result.getMetricsQueryResults()) {\n    for (MetricResult metric : queryResult.getMetrics()) {\n        System.out.println(metric.getMetricName());\n        metric.getTimeSeries().stream()\n            .flatMap(ts -> ts.getValues().stream())\n            .forEach(mv -> System.out.println(\n                mv.getTimeStamp() + \" Count=\" + mv.getCount() + \" Avg=\" + mv.getAverage()));\n    }\n}\n```\n\n## Response Structure\n\n### Logs Response Hierarchy\n\n```\nLogsQueryResult\n├── statistics (BinaryData)\n├── visualization (BinaryData)\n├── error\n└── tables (List\u003CLogsTable>)\n    ├── name\n    ├── columns (List\u003CLogsTableColumn>)\n    │   ├── name\n    │   └── type\n    └── rows (List\u003CLogsTableRow>)\n        ├── rowIndex\n        └── rowCells (List\u003CLogsTableCell>)\n```\n\n### Metrics Response Hierarchy\n\n```\nMetricsQueryResult\n├── granularity\n├── timeInterval\n├── namespace\n├── resourceRegion\n└── metrics (List\u003CMetricResult>)\n    ├── id, name, type, unit\n    └── timeSeries (List\u003CTimeSeriesElement>)\n        ├── metadata (dimensions)\n        └── values (List\u003CMetricValue>)\n            ├── timeStamp\n            ├── count, average, total\n            ├── maximum, minimum\n```\n\n## Error Handling\n\n```java\nimport com.azure.core.exception.HttpResponseException;\nimport com.azure.monitor.query.models.LogsQueryResultStatus;\n\ntry {\n    LogsQueryResult result = logsClient.queryWorkspace(workspaceId, query, timeInterval);\n    \n    \u002F\u002F Check partial failure\n    if (result.getStatus() == LogsQueryResultStatus.PARTIAL_FAILURE) {\n        System.err.println(\"Partial failure: \" + result.getError().getMessage());\n    }\n} catch (HttpResponseException e) {\n    System.err.println(\"Query failed: \" + e.getMessage());\n    System.err.println(\"Status: \" + e.getResponse().getStatusCode());\n}\n```\n\n## Best Practices\n\n1. **Use batch queries** — Combine multiple queries into a single request\n2. **Set appropriate timeouts** — Long queries may need extended server timeout\n3. **Limit result size** — Use `top` or `take` in Kusto queries\n4. **Use projections** — Select only needed columns with `project`\n5. **Check query status** — Handle PARTIAL_FAILURE results gracefully\n6. **Cache results** — Metrics don't change frequently; cache when appropriate\n7. **Migrate to new packages** — Plan migration to `azure-monitor-query-logs` and `azure-monitor-query-metrics`\n\n## Reference Links\n\n| Resource | URL |\n|----------|-----|\n| Maven Package | https:\u002F\u002Fcentral.sonatype.com\u002Fartifact\u002Fcom.azure\u002Fazure-monitor-query |\n| GitHub | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-java\u002Ftree\u002Fmain\u002Fsdk\u002Fmonitor\u002Fazure-monitor-query |\n| API Reference | https:\u002F\u002Flearn.microsoft.com\u002Fjava\u002Fapi\u002Fcom.azure.monitor.query |\n| Kusto Query Language | https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fdata-explorer\u002Fkusto\u002Fquery\u002F |\n| Log Analytics Limits | https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fazure-monitor\u002Fservice-limits#la-query-api |\n| Troubleshooting | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-java\u002Fblob\u002Fmain\u002Fsdk\u002Fmonitor\u002Fazure-monitor-query\u002FTROUBLESHOOTING.md |\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n","# Azure Monitor Query SDK for Java\n\n> **DEPRECATION NOTICE**: This package is deprecated in favor of:\n> - `azure-monitor-query-logs` — For Log Analytics queries\n> - `azure-monitor-query-metrics` — For metrics queries\n>\n> See migration guides: [Logs Migration](https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-java\u002Fblob\u002Fmain\u002Fsdk\u002Fmonitor\u002Fazure-monitor-query-logs\u002Fmigration-guide.md) | [Metrics Migration](https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-java\u002Fblob\u002Fmain\u002Fsdk\u002Fmonitor\u002Fazure-monitor-query-metrics\u002Fmigration-guide.md)\n\nClient library for querying Azure Monitor Logs and Metrics.\n\n## Installation\n\n```xml\n\u003Cdependency>\n    \u003CgroupId>com.azure\u003C\u002FgroupId>\n    \u003CartifactId>azure-monitor-query\u003C\u002FartifactId>\n    \u003Cversion>1.5.9\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\nOr use Azure SDK BOM:\n\n```xml\n\u003CdependencyManagement>\n    \u003Cdependencies>\n        \u003Cdependency>\n            \u003CgroupId>com.azure\u003C\u002FgroupId>\n            \u003CartifactId>azure-sdk-bom\u003C\u002FartifactId>\n            \u003Cversion>{bom_version}\u003C\u002Fversion>\n            \u003Ctype>pom\u003C\u002Ftype>\n            \u003Cscope>import\u003C\u002Fscope>\n        \u003C\u002Fdependency>\n    \u003C\u002Fdependencies>\n\u003C\u002FdependencyManagement>\n\n\u003Cdependencies>\n    \u003Cdependency>\n        \u003CgroupId>com.azure\u003C\u002FgroupId>\n        \u003CartifactId>azure-monitor-query\u003C\u002FartifactId>\n    \u003C\u002Fdependency>\n\u003C\u002Fdependencies>\n```\n\n## Prerequisites\n\n- Log Analytics workspace (for logs queries)\n- Azure resource (for metrics queries)\n- TokenCredential with appropriate permissions\n\n## Environment Variables\n\n```bash\nLOG_ANALYTICS_WORKSPACE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\nAZURE_RESOURCE_ID=\u002Fsubscriptions\u002F{sub}\u002FresourceGroups\u002F{rg}\u002Fproviders\u002F{provider}\u002F{resource}\n```\n\n## Client Creation\n\n### LogsQueryClient (Sync)\n\n```java\nimport com.azure.identity.DefaultAzureCredentialBuilder;\nimport com.azure.monitor.query.LogsQueryClient;\nimport com.azure.monitor.query.LogsQueryClientBuilder;\n\nLogsQueryClient logsClient = new LogsQueryClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .buildClient();\n```\n\n### LogsQueryAsyncClient\n\n```java\nimport com.azure.monitor.query.LogsQueryAsyncClient;\n\nLogsQueryAsyncClient logsAsyncClient = new LogsQueryClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .buildAsyncClient();\n```\n\n### MetricsQueryClient (Sync)\n\n```java\nimport com.azure.monitor.query.MetricsQueryClient;\nimport com.azure.monitor.query.MetricsQueryClientBuilder;\n\nMetricsQueryClient metricsClient = new MetricsQueryClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .buildClient();\n```\n\n### MetricsQueryAsyncClient\n\n```java\nimport com.azure.monitor.query.MetricsQueryAsyncClient;\n\nMetricsQueryAsyncClient metricsAsyncClient = new MetricsQueryClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .buildAsyncClient();\n```\n\n### Sovereign Cloud Configuration\n\n```java\n\u002F\u002F Azure China Cloud - Logs\nLogsQueryClient logsClient = new LogsQueryClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .endpoint(\"https:\u002F\u002Fapi.loganalytics.azure.cn\u002Fv1\")\n    .buildClient();\n\n\u002F\u002F Azure China Cloud - Metrics\nMetricsQueryClient metricsClient = new MetricsQueryClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .endpoint(\"https:\u002F\u002Fmanagement.chinacloudapi.cn\")\n    .buildClient();\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| Logs | Log and performance data from Azure resources via Kusto Query Language |\n| Metrics | Numeric time-series data collected at regular intervals |\n| Workspace ID | Log Analytics workspace identifier |\n| Resource ID | Azure resource URI for metrics queries |\n| QueryTimeInterval | Time range for the query |\n\n## Logs Query Operations\n\n### Basic Query\n\n```java\nimport com.azure.monitor.query.models.LogsQueryResult;\nimport com.azure.monitor.query.models.LogsTableRow;\nimport com.azure.monitor.query.models.QueryTimeInterval;\nimport java.time.Duration;\n\nLogsQueryResult result = logsClient.queryWorkspace(\n    \"{workspace-id}\",\n    \"AzureActivity | summarize count() by ResourceGroup | top 10 by count_\",\n    new QueryTimeInterval(Duration.ofDays(7))\n);\n\nfor (LogsTableRow row : result.getTable().getRows()) {\n    System.out.println(row.getColumnValue(\"ResourceGroup\") + \": \" + row.getColumnValue(\"count_\"));\n}\n```\n\n### Query by Resource ID\n\n```java\nLogsQueryResult result = logsClient.queryResource(\n    \"{resource-id}\",\n    \"AzureMetrics | where TimeGenerated > ago(1h)\",\n    new QueryTimeInterval(Duration.ofDays(1))\n);\n\nfor (LogsTableRow row : result.getTable().getRows()) {\n    System.out.println(row.getColumnValue(\"MetricName\") + \" \" + row.getColumnValue(\"Average\"));\n}\n```\n\n### Map Results to Custom Model\n\n```java\n\u002F\u002F Define model class\npublic class ActivityLog {\n    private String resourceGroup;\n    private String operationName;\n    \n    public String getResourceGroup() { return resourceGroup; }\n    public String getOperationName() { return operationName; }\n}\n\n\u002F\u002F Query with model mapping\nList\u003CActivityLog> logs = logsClient.queryWorkspace(\n    \"{workspace-id}\",\n    \"AzureActivity | project ResourceGroup, OperationName | take 100\",\n    new QueryTimeInterval(Duration.ofDays(2)),\n    ActivityLog.class\n);\n\nfor (ActivityLog log : logs) {\n    System.out.println(log.getOperationName() + \" - \" + log.getResourceGroup());\n}\n```\n\n### Batch Query\n\n```java\nimport com.azure.monitor.query.models.LogsBatchQuery;\nimport com.azure.monitor.query.models.LogsBatchQueryResult;\nimport com.azure.monitor.query.models.LogsBatchQueryResultCollection;\nimport com.azure.core.util.Context;\n\nLogsBatchQuery batchQuery = new LogsBatchQuery();\nString q1 = batchQuery.addWorkspaceQuery(\"{workspace-id}\", \"AzureActivity | count\", new QueryTimeInterval(Duration.ofDays(1)));\nString q2 = batchQuery.addWorkspaceQuery(\"{workspace-id}\", \"Heartbeat | count\", new QueryTimeInterval(Duration.ofDays(1)));\nString q3 = batchQuery.addWorkspaceQuery(\"{workspace-id}\", \"Perf | count\", new QueryTimeInterval(Duration.ofDays(1)));\n\nLogsBatchQueryResultCollection results = logsClient\n    .queryBatchWithResponse(batchQuery, Context.NONE)\n    .getValue();\n\nLogsBatchQueryResult result1 = results.getResult(q1);\nLogsBatchQueryResult result2 = results.getResult(q2);\nLogsBatchQueryResult result3 = results.getResult(q3);\n\n\u002F\u002F Check for failures\nif (result3.getQueryResultStatus() == LogsQueryResultStatus.FAILURE) {\n    System.err.println(\"Query failed: \" + result3.getError().getMessage());\n}\n```\n\n### Query with Options\n\n```java\nimport com.azure.monitor.query.models.LogsQueryOptions;\nimport com.azure.core.http.rest.Response;\n\nLogsQueryOptions options = new LogsQueryOptions()\n    .setServerTimeout(Duration.ofMinutes(10))\n    .setIncludeStatistics(true)\n    .setIncludeVisualization(true);\n\nResponse\u003CLogsQueryResult> response = logsClient.queryWorkspaceWithResponse(\n    \"{workspace-id}\",\n    \"AzureActivity | summarize count() by bin(TimeGenerated, 1h)\",\n    new QueryTimeInterval(Duration.ofDays(7)),\n    options,\n    Context.NONE\n);\n\nLogsQueryResult result = response.getValue();\n\n\u002F\u002F Access statistics\nBinaryData statistics = result.getStatistics();\n\u002F\u002F Access visualization data\nBinaryData visualization = result.getVisualization();\n```\n\n### Query Multiple Workspaces\n\n```java\nimport java.util.Arrays;\n\nLogsQueryOptions options = new LogsQueryOptions()\n    .setAdditionalWorkspaces(Arrays.asList(\"{workspace-id-2}\", \"{workspace-id-3}\"));\n\nResponse\u003CLogsQueryResult> response = logsClient.queryWorkspaceWithResponse(\n    \"{workspace-id-1}\",\n    \"AzureActivity | summarize count() by TenantId\",\n    new QueryTimeInterval(Duration.ofDays(1)),\n    options,\n    Context.NONE\n);\n```\n\n## Metrics Query Operations\n\n### Basic Metrics Query\n\n```java\nimport com.azure.monitor.query.models.MetricsQueryResult;\nimport com.azure.monitor.query.models.MetricResult;\nimport com.azure.monitor.query.models.TimeSeriesElement;\nimport com.azure.monitor.query.models.MetricValue;\nimport java.util.Arrays;\n\nMetricsQueryResult result = metricsClient.queryResource(\n    \"{resource-uri}\",\n    Arrays.asList(\"SuccessfulCalls\", \"TotalCalls\")\n);\n\nfor (MetricResult metric : result.getMetrics()) {\n    System.out.println(\"Metric: \" + metric.getMetricName());\n    for (TimeSeriesElement ts : metric.getTimeSeries()) {\n        System.out.println(\"  Dimensions: \" + ts.getMetadata());\n        for (MetricValue value : ts.getValues()) {\n            System.out.println(\"    \" + value.getTimeStamp() + \": \" + value.getTotal());\n        }\n    }\n}\n```\n\n### Metrics with Aggregations\n\n```java\nimport com.azure.monitor.query.models.MetricsQueryOptions;\nimport com.azure.monitor.query.models.AggregationType;\n\nResponse\u003CMetricsQueryResult> response = metricsClient.queryResourceWithResponse(\n    \"{resource-id}\",\n    Arrays.asList(\"SuccessfulCalls\", \"TotalCalls\"),\n    new MetricsQueryOptions()\n        .setGranularity(Duration.ofHours(1))\n        .setAggregations(Arrays.asList(AggregationType.AVERAGE, AggregationType.COUNT)),\n    Context.NONE\n);\n\nMetricsQueryResult result = response.getValue();\n```\n\n### Query Multiple Resources (MetricsClient)\n\n```java\nimport com.azure.monitor.query.MetricsClient;\nimport com.azure.monitor.query.MetricsClientBuilder;\nimport com.azure.monitor.query.models.MetricsQueryResourcesResult;\n\nMetricsClient metricsClient = new MetricsClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .endpoint(\"{endpoint}\")\n    .buildClient();\n\nMetricsQueryResourcesResult result = metricsClient.queryResources(\n    Arrays.asList(\"{resourceId1}\", \"{resourceId2}\"),\n    Arrays.asList(\"{metric1}\", \"{metric2}\"),\n    \"{metricNamespace}\"\n);\n\nfor (MetricsQueryResult queryResult : result.getMetricsQueryResults()) {\n    for (MetricResult metric : queryResult.getMetrics()) {\n        System.out.println(metric.getMetricName());\n        metric.getTimeSeries().stream()\n            .flatMap(ts -> ts.getValues().stream())\n            .forEach(mv -> System.out.println(\n                mv.getTimeStamp() + \" Count=\" + mv.getCount() + \" Avg=\" + mv.getAverage()));\n    }\n}\n```\n\n## Response Structure\n\n### Logs Response Hierarchy\n\n```\nLogsQueryResult\n├── statistics (BinaryData)\n├── visualization (BinaryData)\n├── error\n└── tables (List\u003CLogsTable>)\n    ├── name\n    ├── columns (List\u003CLogsTableColumn>)\n    │   ├── name\n    │   └── type\n    └── rows (List\u003CLogsTableRow>)\n        ├── rowIndex\n        └── rowCells (List\u003CLogsTableCell>)\n```\n\n### Metrics Response Hierarchy\n\n```\nMetricsQueryResult\n├── granularity\n├── timeInterval\n├── namespace\n├── resourceRegion\n└── metrics (List\u003CMetricResult>)\n    ├── id, name, type, unit\n    └── timeSeries (List\u003CTimeSeriesElement>)\n        ├── metadata (dimensions)\n        └── values (List\u003CMetricValue>)\n            ├── timeStamp\n            ├── count, average, total\n            ├── maximum, minimum\n```\n\n## Error Handling\n\n```java\nimport com.azure.core.exception.HttpResponseException;\nimport com.azure.monitor.query.models.LogsQueryResultStatus;\n\ntry {\n    LogsQueryResult result = logsClient.queryWorkspace(workspaceId, query, timeInterval);\n    \n    \u002F\u002F Check partial failure\n    if (result.getStatus() == LogsQueryResultStatus.PARTIAL_FAILURE) {\n        System.err.println(\"Partial failure: \" + result.getError().getMessage());\n    }\n} catch (HttpResponseException e) {\n    System.err.println(\"Query failed: \" + e.getMessage());\n    System.err.println(\"Status: \" + e.getResponse().getStatusCode());\n}\n```\n\n## Best Practices\n\n1. **Use batch queries** — Combine multiple queries into a single request\n2. **Set appropriate timeouts** — Long queries may need extended server timeout\n3. **Limit result size** — Use `top` or `take` in Kusto queries\n4. **Use projections** — Select only needed columns with `project`\n5. **Check query status** — Handle PARTIAL_FAILURE results gracefully\n6. **Cache results** — Metrics don't change frequently; cache when appropriate\n7. **Migrate to new packages** — Plan migration to `azure-monitor-query-logs` and `azure-monitor-query-metrics`\n\n## Reference Links\n\n| Resource | URL |\n|----------|-----|\n| Maven Package | https:\u002F\u002Fcentral.sonatype.com\u002Fartifact\u002Fcom.azure\u002Fazure-monitor-query |\n| GitHub | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-java\u002Ftree\u002Fmain\u002Fsdk\u002Fmonitor\u002Fazure-monitor-query |\n| API Reference | https:\u002F\u002Flearn.microsoft.com\u002Fjava\u002Fapi\u002Fcom.azure.monitor.query |\n| Kusto Query Language | https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fdata-explorer\u002Fkusto\u002Fquery\u002F |\n| Log Analytics Limits | https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fazure-monitor\u002Fservice-limits#la-query-api |\n| Troubleshooting | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-java\u002Fblob\u002Fmain\u002Fsdk\u002Fmonitor\u002Fazure-monitor-query\u002FTROUBLESHOOTING.md |\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n",{"name":5,"risk":32,"source":37,"date_added":43,"description":7},"2026-02-27","main","7a38d8e7073e61c16eda85681cb32fb68a8657a5","skills-store\u002Fglobal\u002Fazure-monitor-query-java","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router","https:\u002F\u002Fgithub.com\u002Fsapsapshen","2026-04-14 21:12:12",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add sapsapshen\u002Fai-memory-router --skill azure-monitor-query-java",{"tool":56,"command":57},"bunx","bunx skills add sapsapshen\u002Fai-memory-router --skill azure-monitor-query-java",{"tool":59,"command":60},"pnpm","pnpm dlx skills add sapsapshen\u002Fai-memory-router --skill azure-monitor-query-java","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fglobal\u002Fazure-monitor-query-java\u002FSKILL.md",true,[],[65,89,115,125,138,157],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":76,"publishedAt":38},"01M71ATQRKG48SH06FQ697T5G9","wechat-search","Search WeChat Official Account articles using OpenClaw's web search and fetch capabilities with compliance-focused design.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Fwechat-search-release\u002FSKILL.md",[71],{"categoryNo":72,"categoryName":73,"taxonomyType":74,"taxonomyTypeDesc":75},"01JBSEEDCAT000000000000037","律师与法务","PROFESSION","适用职业",[77,78,79,80,81,82,83,84,85,86,87,88],"wechat search","wechat","search","capabilities","openclaw","design","web search","compliance","web","official","fetch","with",{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":38},"01M71ATNAVGZB35PFYM2GC5N00","trend-tap","Real-time trending topics aggregator across 7 platforms (X\u002FTwitter, Reddit, Google Trends, Hacker News, Zhihu, Bilibili, Weibo). Trigger: when user says 'trend', 'trends', 'trend tap', '热点', '热搜', or asks what is trending\u002Fhot. Do NOT use web_search — this skill already fetches live data from all platforms with zero API keys.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Ftrend-tap\u002FSKILL.md",[],[96,97,98,99,100,101,79,102,103,104,105,106,107,108,109,110,111,112,113,114],"trend","trend tap","tap","api keys","Bash","time","trending","hacker","aggregator","do","when","brew","live","data","google","install","read","across","api",{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":38},"01M71ATJ9AM5KM15AA8PS302EB","trend-radar","Real-time trending topics aggregator across 7 platforms (X\u002FTwitter, Reddit, Google Trends, Hacker News, Zhihu, Bilibili, Weibo). Trigger: when user says 'trend', 'trends', 'trend pulse', '热点', '热搜', or asks what is trending\u002Fhot. Do NOT use web_search — this skill already fetches live data from all platforms with zero API keys.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Ftrend-radar\u002FSKILL.md",[],[122,123,96,107,108,109,110,100,79,112,124,113,114,106,104,103,102,111,101,99],"trend radar","radar","pulse",{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":129,"categories":130,"keywords":131,"publishedAt":38},"01M71ATGF095N3EJM9G8SD0BB5","tech-news-daily","每日科技新闻汇——从全球多个 RSS 源抓取最新科技新闻，翻译（英→中）、去重、排版成每日简报。当用户询问科技新闻、科技新鲜事、每日科技、技术动态、Daily Tech News 或类似表达时触发此技能。","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Ftech-news-daily\u002FSKILL.md",[],[132,133,134,135,136,137],"news","tech","tech news daily","daily","rss","翻译",{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":149,"publishedAt":38},"01M71ATFAEAMQ17M70NQNY7SR8","summarize","Summarize URLs or files with the summarize CLI (web, PDFs, images, audio, YouTube).","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Fsummarize\u002FSKILL.md",[144],{"categoryNo":145,"categoryName":146,"taxonomyType":147,"taxonomyTypeDesc":148},"01JBSEEDCAT000000000000021","资料检索与研究","SCENARIO","使用场景",[140,85,150,151,152,88,107,153,154,155,98,156,111],"Audio","cli","youtube","images","https","files","pdfs",{"skillNo":158,"name":159,"nameZh":6,"description":160,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":161,"categories":162,"keywords":163,"publishedAt":38},"01M71ATDNS3R0M4H936PACQAWZ","sonoscli","Control Sonos speakers (discover\u002Fstatus\u002Fplay\u002Fvolume\u002Fgroup).","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Fsonoscli\u002FSKILL.md",[],[159,164,165,166,111,167,154,168,169,170,171,172],"status","play","go","latest","github","discover","control","cmd","volume"]