Instana MCP服务器

Instana MCP服务器是一个桥梁,连接客户端与Instana REST API,将用户查询转换为API请求并将响应格式化为结构化数据,用于实时获取可观测性数据。

  • by instana
  • Python
  • 本地部署
  • 28 星标
  • 更新于
在 GitHub 查看 instana/mcp-instana

使用说明

目录

IBM Instana的MCP服务器

Instana MCP服务器允许与Instana可观测性平台进行交互,有助于将实时可观测性数据直接提取到开发工作流程中。

它充当客户端(如人工智能代理或自定义工具)与Instana REST API之间的桥梁,将用户查询转换为Instana API请求和格式/将API响应汇总为结构化格式。

架构图

graph LR
    subgraph "Application Host Process"
        MH[MCP Host]
        MSI[Instana MCP Server]
        MST[ProductA MCP Server]
        MSC[ProductB MCP Server]

        MH <--> MSI
        MH <--> MSC
        MH <--> MST
    end

    subgraph "Remote Service"
        II[Instana Instance]
        TI[ProductA Instance]
        CI[ProductB Instance]

        MSI <--> II
        MST <--> TI
        MSC <--> CI
    end

    subgraph "LLM"
        L[LLM]
        MH <--> L
    end

工作流程图

让我们举一个简单的例子。假设您使用的是MCP主机,它可以是Claude Desktop、VSCode或其他一些主机,并且它连接到Instana的MCP服务器。在这里,我将要求Instana MCP服务器向我显示一些警报。事情是这样的:

  • MCP客户端从Instana MCP服务器获取可用工具列表。
  • 您的查询将与工具描述一起发送给LLM。
  • LLM分析可用的工具并决定使用哪种工具。在这种情况下,与获取instana警报和应用程序相关的一些工具将返回给instana MCP客户端。
  • 客户端通过Instana MCP服务器执行所选工具,因为工具在服务器中。
  • 结果(最新警报)将发送回LLM。
  • LLM制定了一个自然语言响应。
  • 将向您显示响应。
sequenceDiagram
    participant User
    participant ChatBot as MCP Host
    participant MCPClient as MCP Client
    participant MCPServer as Instana MCP Server
    participant LLM
    participant Instana as Instana Instance

    ChatBot->>MCPClient: Load available tools from MCP Server
    MCPClient->>MCPServer: Request available tool list
    MCPServer->>MCPClient: Return list of available tools
    User->>ChatBot: Ask "Show me the latest alerts from Instana for application robot-shop"
    ChatBot->>MCPClient: Forward query
    MCPClient->>LLM: Send query and tool description
    LLM->>MCPClient: Select appropriate tool(s) for Instana alert query
    MCPClient->>MCPServer: Execute selected tool(s)
    MCPServer->>Instana: Retrieve alerts for application robot-shop
    MCPServer->>MCPClient: Send alerts of Instana result
    MCPClient->>LLM: Forward alerts of Instana
    LLM->>ChatBot: Generate natural language response for Instana alerts
    ChatBot->>User: Show Instana alert response

先决条件

安装Instana Python SDK

pip install instana-client

配置MCP主机

这里我们使用Claud Desktop作为示例。基于配置Claude桌面https://modelcontextprotocol.io/quickstart/user.对于 claude_desktop_config.json,它位于macOS和Windows的不同位置,如下所示:

  • macOS:~/库/应用程序支持/Claude/Claude_desktop_config json
  • Windows:%APPDATA%\Claude\Claude_desktop_config.json
{
  "mcpServers": {
    "Instana Tools": {
      "command": "/path/to/.local/bin/uv",
      "args": [
        "run",
        "--with",
        "mcp[cli]",
        "mcp",
        "run",
        "/path/to/mcp_server.py"
      ],
      "env": {
        "INSTANA_BASE_URL": "<INSTANA_BASE_URL>",
        "INSTANA_API_TOKEN": "<INSTANA_API_TOKEN>"
      }
    }
  }
}

运行和测试

使用Claude Desktop进行测试

重新启动Claud Desktop后,您现在可以在Claud Desktop中运行查询。

get me all endpoints from Instana

使用llm客户端进行测试

您还可以使用llm客户端对其进行测试。

请更新 mcp-instana.json 文件[mcpclient](/mcp-instana.json),通过给出本地目录的路径。

然后在mcpclient文件夹下运行以下命令:

cd mcpclient
streamlit run mcpclient.py

现在,您可以通过以下方式在浏览器中查看Streamlit应用程序http://localhost:8501.

您可以在查询框中进行查询。

使用GitHub Copilot进行测试

有关GitHub Copilot与VScode的集成,请参阅此链接https://code.visualstudio.com/docs/copilot/setup.

以下是GitHub Copilot响应的示例:

特性

  • []应用程序
    • []应用程序指标
      • []应用程序指标
      • []端点指标
      • []服务指标
      • []数据指标
    • [x] 应用资源
      • [x] 应用程序
      • [x] 服务项目
      • [x] 端点
    • [x] 应用程序警报配置
      • [x] 获取所有智能警报配置
      • [x] 获取智能警报配置
      • [x] 获取智能警报配置版本
      • [x] 创建智能警报配置
      • [x] 更新智能警报配置
      • [x] 删除智能警报配置
      • [x] 重新计算智能警报配置基线
      • [x] 启用应用程序警报配置
      • [x] 禁用智能警报配置
      • [x] 还原智能警报配置
  • []基础设施
    • [x] 基础设施分析
    • [x] 获取可用指标
    • []获取基础设施实体
    • [x] 使用聚合指标获取分组实体
    • [x] 获取可用实体类型
    • [x] 基础架构目录
      • [x] 通过插件ID获取有效载荷密钥
      • [x] 获取基础架构目录指标
      • [x] 获取基础架构目录插件
      • [x] 获取具有自定义指标的基础架构目录插件
      • [x] 获取基础结构目录搜索字段
      • [x] 获取具有自定义指标的基础架构目录搜索字段
      • [x] 获取标签目录
      • [x] 获取标签目录全部
    • []基础设施资源
      • [x] 监控状态
      • []快照有效负载
      • []搜索快照
      • [x] 快照详细信息
      • [x] 多个快照详细信息
      • [x] 软件版本
    • [x] 基础结构拓扑
      • [x] 获取快照主机
      • [x] 获取拓扑

工具

工具 类别 描述
get_application_metrics 应用程序指标 获取应用程序指标
get_endpoints_metrics 应用程序指标 获取端点指标
get_services_metrics 应用程序指标 获取服务指标
get_application_data_metrics_v2 应用程序指标 获取应用程序数据指标
get_applications 应用程序资源 获取应用程序
get_application_services 应用程序资源 获取应用程序/服务
get_application_endpoints 应用程序资源 获取端点
get_services 应用程序资源 获取服务
get_monitoring_state 基础设施资源 受监控的主机数量
get_plugin_payload 基础架构资源 获取快照的有效负载
get_snapshots 基础架构资源 搜索快照
post_snapshots 基础架构资源 获取多个快照的快照详细信息
get_snapshot 基础架构资源 获取快照详细信息
software_versions 基础设施资源 获取已安装的软件
get_available_payload_keys_by_plugin_id 基础架构目录 按插件ID获取有效载荷密钥
get_infrastructure_catalog_metrics 基础架构目录 获取基础架构目录指标
get_infrastructure_catalog_plugins 基础结构目录 获取基础结构目录插件
get_infrastructure_catalog_plugins_with_custom_metrics 基础架构目录 获取具有自定义指标的基础架构目录插件
get_infrastructure_catalog_search_fields 基础结构目录 获取基础结构目录搜索字段
get_tag_catalog 基础架构目录 获取标签目录
get_tag_catalog_all 基础架构目录 获取标签目录全部
get_related_hosts 基础架构拓扑 获取相关主机
get_topology 基础结构拓扑 获取拓扑
get_available_metrics 基础设施分析 获取可用指标
get_entities 基础设施分析 获取基础设施实体
get_aggregated_entity_groups 基础架构分析 使用聚合指标获取分组实体
get_available_plugins 基础结构分析 获取可用的实体类型
get_application_alert_configs 应用程序警报配置 获取所有智能警报配置
find_application_alert_config 应用程序警报配置 获取智能警报配置
find_application_alert_config_versions 应用程序警报配置 获取智能警报配置版本
create_application_alert_config 应用程序警报配置 创建智能警报配置
update_application_alert_config 应用程序警报配置 更新智能警报配置
delete_application_alert_config 应用程序警报配置 删除智能警报配置
update_application_historic_baseline 应用程序警报配置 重新计算智能警报配置基线
enable_application_alert_config 应用警报配置 启用应用警报配置
disable_application_alert_config 应用程序警报配置 禁用智能警报配置
restore_application_alert_config 应用程序警报配置 还原智能警报配置

示例提示

以下是一些示例提示(包含查询和结果),您可以使用这些提示开始使用Instana Observability Platform API:

  • 查询1
Get available plugins for infrastructure monitoring with this payload :   
{ "tagFilterExpression": {
    "type": "EXPRESSION",
    "logicalOperator": "AND",
    "elements": []
  },
  "timeFrame": {   "to": 1743923995000,  "windowSize": 3600000  }}
  • 结果1
The available plugins for infrastructure monitoring are:

kubernetesNode
awsEs
gce
awsMskCluster
availabilityZone
rabbitMq
redis
awsDynamoDb
awsMq
kubernetesDeployment
processingStatisticsMember
phpRuntimePlatform
awsElb
openLDAP
host
hAProxy
kubernetesDaemonSet
kubernetesHorizontalPodAutoscaler
  • 问题2
get me all endpoints from Instana
  • 结果2
The function get_application_endpoints returns a list of endpoints for all services from Instana. The list includes information about each endpoint, such as its ID, label, service ID, and technologies used. The list is paginated, with a page size of 50, and there are 592 total hits.
  • 问题3
give me current monitoring state of the Instana system
  • 结果3
The current monitoring state of the Instana system is:

Has entities: True
Host count: 60
Serverless count: 28
  • 问题4
can you give me the available plugins in Instana.
  • 结果4
The available plugins in Instana are:

Business Activity
Azure Key Vault Managed HSM
Kafka Connect Worker
AWS DocumentDB Instance
AWS RDS
Amazon MQ
vSphere VM
PHP Runtime
AWS ELB
HAProxy
Kafka Connect Cluster
OpenStack Compute Instance
  • 问题5
give me service id of a service tomcat
  • 结果5
The service ID of the service "tomcat" is "536c0b339345616c1b33caf454454d8b8a190d6c".
  • 问题6
can you give me details of the application  perspective with application name zAWSApp
  • 结果6
The application perspective with the name "zAWSApp" has the following details:

Boundary Scope: ALL
Entity Type: APPLICATION
ID: kg8740PtQrK5U7E3Dhz_hQ
Label: zAWSApp
  • 问题7
List 3 Instana catalog plugins
  • 结果7
Here are three Instana catalog plugins:

Business Activity (plugin: businessActivity)
Azure Key Vault Managed HSM (plugin: azureManagedHSM)
Kafka Connect Worker (plugin: kafkaConnectWorker)
  • 问题8
what tags are available for the plugin openTelemetry in Instana
  • 结果8
The available tags for the plugin openTelemetry in Instana are:

metric.tag.direction
otel.attribute.process.executable.path
otel.attribute.process.command_args
otel.attribute.process.runtime.name
otel.attribute.pid
otel.attribute.process.runtime.description
otel.attribute.k8s.cluster.name
otel.attribute.process.executable.name
otel.attribute.host.id
dfq.selftype
otel.attribute.service.namespace
These tags can be used to filter and group data in Instana.
  • 问题9
give all softwares installed in INstana
  • 结果9
The software installed in Instana are:

brotli - 1.1.0
bytes - 3.1.2
icu - 76.1
media-typer - 1.1.0
redis - 7.2.1
Eclipse OpenJ9 VM - 21.0.5
object-inspect - 1.13.4
csv - 3.3.4
bytes - 3.1.2
accepts - 2.0.0
Note that there are 666 items in total, but only 10 are shown in the summary.
  • 问题10
Get Smart Alert Config Versions for 5JkkTu1CTLyz0xetm9Q5Ew
  • 结果10
The Smart Alert Config Versions for 5JkkTu1CTLyz0xetm9Q5Ew are:

DISABLE
RESTORE
DELETE
DISABLE
ENABLE
DISABLE
RESTORE
DELETE
UPDATE
DISABLE
CREATE
These versions were created by different authors, including API and USER, and have different change types, such as DISABLE, RESTORE, DELETE, UPDATE, and CREATE. The created timestamps range from 1724839116701 to 1747045186341.