microsoft/skills

azure-monitor-ingestion-java

用 Java LogsIngestionClient 写入自定义表

  • SKILL.md 已保存
  • 中文用法已整理
  • 安装与运行未实测
先判断是否解决你的问题

azure-monitor-ingestion-java 是什么?

azure-monitor-ingestion-java 使用 Java LogsIngestionClient 将自定义记录写入 Azure Monitor。调用前需有 DCE endpoint、DCR ID、stream 和匹配的 Java 日志模型;它与用 OpenTelemetry 上报 traces 或自动采集应用请求的路线不同。

中文说明由本站依据来源整理;英文原文保留在页面下方。

适合用在

  • Java 服务需要把现有业务事件、审计记录或设备日志送入 DCR 路由的 Log Analytics 表。
  • 需要用同步或异步客户端上传,并检查批次中的部分失败。
按客户端选择安装入口

怎么接入你的 Agent?

  1. 定位完整 Skill 目录

    打开本项目来源,核对 SKILL.md 及其引用的脚本和资料。

  2. 交给你正在用的 Agent

    在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。

  3. 确认识别,再做具体任务

    让 Agent 回报安装目录和识别到的名称 azure-monitor-ingestion-java,然后按本页使用示例提供材料。

展开并复制给 Codex 的安装指令
发送给 Codex

安装并检查 azure-monitor-ingestion-java

请在 Codex 的当前工作环境中安装并检查 azure-monitor-ingestion-java 这个 Skill。

项目身份:microsoft/skills / azure-monitor-ingestion-java
来源:https://github.com/microsoft/skills/blob/f03ec5392f7a0f3aca12af47477e92f1edf7b44c/.github/plugins/azure-sdk-java/skills/azure-monitor-ingestion-java/SKILL.md
已定位的源文件:.github/plugins/azure-sdk-java/skills/azure-monitor-ingestion-java/SKILL.md

1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。
准备输入,再按步骤执行

装好以后,具体怎么用?

准备哪些材料

  • 添加 com.azure:azure-monitor-ingestion,准备 DCE endpoint、DCR rule ID、stream name、目标表 schema 和具备相应权限的 TokenCredential。
  • Java 记录类的属性、getter、时间字段和序列化形式要符合 DCR 的列定义;不能只凭 POJO 能编译推断服务端接受。

会得到什么

  • Maven 依赖与客户端选择、DCR 到 Java 字段映射、上传错误处理和写入后查询验证方案。

实际使用顺序

  1. 从 DCR 中核对 stream 与目标表映射,并确认使用的是 immutable rule ID 和对应区域的 DCE endpoint。
  2. 复用 LogsIngestionClient 或按响应式应用选择 LogsIngestionAsyncClient;按合理批次调用 upload(ruleId, streamName, logs),大批量才调整并发度。
  3. 配置 LogsUploadOptions 的错误消费者来保留失败记录和响应异常;对 HTTP 403 检查身份与写入权限,对 404 回查 endpoint、DCR ID 和 stream。
  4. 调用完成后用 Logs Query 查目标表中的一条已知记录,核对字段、时间与目标资源。
使用示例

从一个具体任务开始

本站根据源文件编写的使用示例,未在本站实际运行。示例中的文件由你提供。

安装并识别 Skill 后发送

复制一个具体任务

教学任务:使用 azure-monitor-ingestion-java,为 Java Worker 上传一条自定义审计日志。先确认 DCE、DCR immutable ID、stream、目标 schema 和 TokenCredential 权限;检查日志模型字段及时间戳能否序列化,再给出 LogsIngestionClient 上传、partial failure 记录与写后查询步骤。不要称示例代码已经通过编译或上传。
预期结果

预期得到字段与 DCR 一致、包含失败处理的上传任务方案。此教学任务没有构建 Java 项目、访问 Azure 或发送记录。

使用前先看这些限制

使用条件与边界

  • 源文中的依赖版本 1.2.11 是该 Skill 快照里的示例,不代表当前 Maven Central 最新版本;新项目要核对当前发行信息。
  • 源文提到多种内置表与自定义表,但能否使用取决于 DCR stream、转换和目标表配置;不能仅凭表名推断已开通或具备写权限。
针对这个 Skill 的疑问

常见问题

上传调用成功就表示日志能在表里查到吗?

还需要用目标工作区查询实际记录,确认路由、schema、时间字段和摄取延迟。上传 API 调用结果与最终可查询性是两个检查点。

需要核对时再展开原文

来源原文与资料状态

源文件
已保存 SKILL.md,抓取于 2026-11-16T12:36:35.145Z
中文使用说明
已针对下方源文件版本整理用途、用法和常见问题
安装与任务测试
本站未执行安装或任务测试
来源复核
本页中文用法已对照保存版本的完整 SKILL.md 阅读整理
展开 SKILL.md 原文、章节与历史收录资料

.github/plugins/azure-sdk-java/skills/azure-monitor-ingestion-java/SKILL.md · 抓取时间 2026-11-16T12:36:35.145Z

以下保留源文件的 description、章节及摘录,供核对中文说明;完整文件通过上方链接打开。

抓取成功不代表已完成安装或任务测试。

来源 description(原文)

Azure Monitor Ingestion SDK for Java. Send custom logs to Azure Monitor via Data Collection Rules (DCR) and Data Collection Endpoints (DCE). Triggers: "LogsIngestionClient java", "azure monitor ingestion java", "custom logs java", "DCR java", "data collection rule java".

查看源文件章节 / Source sections
  • 原文:Azure Monitor Ingestion SDK for Java
  • 安装 / Installation
  • 前置条件 / Prerequisites
  • 原文:Environment Variables
  • 原文:Client Creation
  • 原文:Synchronous Client
  • 原文:Asynchronous Client
  • 原文:Key Concepts
  • 原文:Core Operations
  • 原文:Upload Custom Logs
  • 原文:Upload with Concurrency
  • 原文:Upload with Error Handling
  • 原文:Async Upload with Reactor
  • 原文:Log Entry Model Example
  • 原文:Error Handling
  • 原文:Best Practices
  • 原文:Querying Uploaded Logs
  • 原文:Reference Links
原文:Azure Monitor Ingestion SDK for Java

Client library for sending custom logs to Azure Monitor using the Logs Ingestion API via Data Collection Rules.

安装 / Installation

```xml <dependency> <groupId>com.azure</groupId> <artifactId>azure-monitor-ingestion</artifactId> <version>1.2.11</version> </dependency> ``` Or use Azure SDK BOM: ```xml <dependencyManagement> <dependencies> <dependency> <groupId>com.azure</groupId> <artifactId>azure-sdk-bom</artifactId> <version>{bom_version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>com.azure</groupId> <artifactId>azure-monitor-ingestion</artifactId> </dependency> </dependencies> ```

前置条件 / Prerequisites

- Data Collection Endpoint (DCE) - Data Collection Rule (DCR) - Log Analytics workspace - Target table (custom or built-in: CommonSecurityLog, SecurityEvents, Syslog, WindowsEvents)

原文:Environment Variables

```bash DATA_COLLECTION_ENDPOINT=https://<dce-name>.<region>.ingest.monitor.azure.com # Required for all auth methods DATA_COLLECTION_RULE_ID=dcr-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # Required for log upload routing STREAM_NAME=Custom-MyTable_CL # Required for the target DCR stream AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production ```

原文:Synchronous Client

```java import com.azure.core.credential.TokenCredential; import com.azure.identity.AzureIdentityEnvVars; import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.identity.ManagedIdentityCredentialBuilder; import com.azure.monitor.ingestion.LogsIngestionClient; import com.azure.monitor.ingestion.LogsIngestionClientBuilder; // Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential> TokenCredential credential = new DefaultAzureCredentialBuilder() .requireEnvVars(AzureIdentityEnvVars.AZURE_TOKEN_CREDENTIALS) .build(); // Or use a specific credential directly in production: // See https://learn.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable#credential-classes // TokenCredential credential = new ManagedIdentityCredentialBuilder().build(); LogsIngestionClient client = new LogsIngestionClientBuilder() .endpoint("<data-collection-endpoint>") .credential(credential) .buildClient(); ```

原文:Asynchronous Client

```java import com.azure.monitor.ingestion.LogsIngestionAsyncClient; LogsIngestionAsyncClient asyncClient = new LogsIngestionClientBuilder() .endpoint("<data-collection-endpoint>") .credential(credential) .buildAsyncClient(); ```

文件 SHA256:edc52c6adc3d7503cfce4bee6fca0357f98f003b3555b4b2867daace43210f5f

仓库许可证记录:MIT;skill-declaration-captured-not-interpreted,查看来源。

SKILL.md原文description · 2026-11-16T12:36:35.145Z

Azure Monitor Ingestion SDK for Java. Send custom logs to Azure Monitor via Data Collection Rules (DCR) and Data Collection Endpoints (DCE). Triggers: "LogsIngestionClient java", "azure monitor ingestion java", "custom logs java", "DCR java", "data collection rule java".

查看历史简介来源

历史收录数据

来源仓库microsoft/skills
Skill源路径.github/plugins/azure-sdk-java/skills/azure-monitor-ingestion-java/SKILL.md

安装前请让使用的Agent先读取这个SKILL.md及其所在目录,确认依赖和所需权限。此页不生成未经来源验证的安装命令。

返回 Skills 目录,按任务继续筛选 · MCP与Skills教程与资源