

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 连接 Splunk
<a name="connecting-telemetry-sources-connecting-splunk"></a>

## 内置，单向集成
<a name="built-in-1-way-integration"></a>

目前， AWS DevOps Agent 通过内置的单向集成支持 Splunk 用户，可实现以下功能：
+ **自动触发调查**-可以将 Splunk 事件配置为通过代理 webhook 触发 AWS DevOps AWS DevOps 代理事件解决调查。
+ **遥测内省**- AWS DevOps 代理可以在通过每个提供商的远程 MCP 服务器调查问题时反省 Splunk 遥测数据。

## 先决条件
<a name="prerequisites"></a>

### 获取 Splunk API 代币
<a name="getting-a-splunk-api-token"></a>

你需要一个 MCP 网址和令牌才能连接 Splunk。

### Splunk 管理员步骤
<a name="splunk-administrator-steps"></a>

您的 Splunk 管理员需要执行以下步骤：
+ 启用 [REST API 访问权限](https://docs.splunk.com/Documentation/SplunkCloud/latest/RESTTUT/RESTandCloud)
+ 在部署时@@ [启用令牌身份验证](https://help.splunk.com/en/splunk-cloud-platform/administer/manage-users-and-security/9.2.2406/authenticate-into-the-splunk-platform-with-tokens/enable-or-disable-token-authentication)。
+ 创建新角色 “mcp\$1user”，新角色不需要具备任何能力。
+ 将角色 “mcp\$1user” 分配给部署中有权使用 MCP 服务器的所有用户。
+ 如果用户无权自己创建令牌，则为受众群体为 “mcp” 的授权用户创建令牌，并设置适当的到期时间。

### Splunk 用户步骤
<a name="splunk-user-steps"></a>

Splunk 用户需要执行以下步骤：
+ 从 Splunk 管理员那里获取适当的令牌，或者如果他们有权限，则自己创建一个。代币的受众必须是 “mcp”。

## 信息载入
<a name="onboarding"></a>

### 第 1 步：Connect
<a name="step-1-connect"></a>

使用账户访问凭证与您的 Splunk 远程 MCP 端点建立连接

#### 配置
<a name="configuration"></a>

1. 转到 “**能力提供者**” 页面（可从侧面导航栏访问）

1. **在 “**遥测” 下的 “**可用**提供商” 部分中找到 **Splunk**，然后单击** “注册”**

1. 输入您的 Splunk MCP 服务器详细信息：
   + **服务器名称**-唯一标识符（例如 my-splunk-server）
   + **端点 URL**-您的 Splunk MCP 服务器端点：

`https://<YOUR_SPLUNK_DEPLOYMENT_NAME>.api.scs.splunk.com/<YOUR_SPLUNK_DEPLOYMENT_NAME>/mcp/v1/`
+ **描述**-可选的服务器描述
+ **令牌名称**-用于身份验证的不记名令牌的名称：`my-splunk-token`
+ **令牌值**用于身份验证的持有者令牌值

### 步骤 2：启用
<a name="step-2-enable"></a>

在特定的代理空间中激活 Splunk 并配置适当的作用域

#### 配置
<a name="configuration"></a>

1. 在座席空间页面上，选择一个座席空间，然后按查看详情（如果您尚未创建座席空间，请参阅[创建代理空间](getting-started-with-aws-devops-agent-creating-an-agent-space.md)）

1. 选择 “权能” 选项卡

1. 向下滚动到 “遥测” 部分

1. 按添加

1. 选择 Splunk

1. 下一步

1. 查看并按保存

1. 复制 Webhook 网址和 API 密钥

### 步骤 3：配置 Webhook
<a name="step-3-configure-webhooks"></a>

使用 Webhook 网址和 API 密钥，您可以将 Splunk 配置为发送事件以触发调查，例如从警报中触发调查。

为确保 DevOps 代理可以使用发送的事件，请确保传输到 webhook 的数据与下面指定的数据架构相匹配。 DevOps 代理可以忽略与此架构不匹配的事件。

设置方法和标题

```
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer <Token>",
    },
```

将正文作为 JSON 字符串发送。

```
{
    eventType: 'incident';
    incidentId: string;
    action: 'created' | 'updated' | 'closed' | 'resolved';
    priority: "CRITICAL" | "HIGH" | "MEDIUM" | "LOW" | "MINIMAL";
    title: string;
    description?: string;
    timestamp?: string;
    service?: string;
    // The original event generated by service is attached here.
    data?: object;
}
```

使用 [https://help.splunk.com/en/Splunk splunk-enterprise/alert-and-respond/alerting-manual/9.4/configure-alert-actions/use-发送 webhook a-webhook-alert-action](https://help.splunk.com/en/splunk-enterprise/alert-and-respond/alerting-manual/9.4/configure-alert-actions/use-a-webhook-alert-action)（注意选择不授权，改用自定义标题选项）

### 了解更多：
<a name="learn-more"></a>
+ Splunk 的 MCP 服务器文档：[https://help.splunk.com/en/splunk-cloud-platform/-platform/ mcp-server-for-splunk](https://help.splunk.com/en/splunk-cloud-platform/mcp-server-for-splunk-platform/about-mcp-server-for-splunk-platform)-splunk-platform about-mcp-server-for
+ Splunk 云平台 REST API 的访问要求和限制：[https://docs.splunk.com/Documentation/SplunkCloud/latest/RESTTUT/RESTandCloud](https://docs.splunk.com/Documentation/SplunkCloud/latest/RESTTUT/RESTandCloud)
+ 在 Splunk 云平台中管理身份验证令牌：[https://help.splunk.com/en/splunk-cloud-platform/administer/manage-users-and-security/9.3.2411/authenticate-into-the-splunk-platform-with-tokens/manage](https://help.splunk.com/en/splunk-cloud-platform/administer/manage-users-and-security/9.3.2411/authenticate-into-the-splunk-platform-with-tokens/manage-or-delete-authentication-tokens)-or-delete-authentication-tokens 
+ 使用 Splunk Web 创建和管理角色：[https://docs.splunk.com/Documentation/SplunkCloud/latest/Security/Addandeditroles](https://docs.splunk.com/Documentation/SplunkCloud/latest/Security/Addandeditroles)

## 移除
<a name="removal"></a>

遥测源在两个级别上连接，分别是代理空间级别和账户级别。要将其完全删除，必须先将其从所有使用它的代理空间中移除，然后才能将其取消注册。

### 步骤 1：从代理空间中移除
<a name="step-1-remove-from-agent-space"></a>

1. 在座席空间页面上，选择一个座席空间，然后按查看详情

1. 选择 “权能” 选项卡

1. 向下滚动到 “遥测” 部分

1. 选择 Splunk

1. 按移除

### 第 2 步：注销账号
<a name="step-2-deregister-from-account"></a>

1. 转到 “**能力提供者**” 页面（可从侧面导航栏访问）

1. 滚动到 “**当前注册**” 部分。

1. 检查代理空间计数是否为零（如果不是，请在其他代理空间中重复上述步骤 1） 

1. 按 Splunk 旁边的 “取消注册”