infrahub-analyzing-data

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Overview

概述

Expert guidance for interactive data analysis against a live Infrahub instance. This skill uses the Infrahub MCP server to query, correlate, and reason over infrastructure data on demand — answering operational questions that span multiple node types and relationships.
Use this skill for any question of the form "what does Infrahub currently know about X, and how does it relate to Y?"
Typical question patterns:
  • Compliance — "Are all devices following the naming convention?"
  • Service impact — "Which services are hosted on devices in this rack?"
  • Maintenance windows — "Which devices are currently in a maintenance window, and what depends on them?"
  • Drift detection — "Which realized devices differ from their topology design?"
  • Capacity — "Which racks are over 80% full?"
  • Change impact — "What BGP sessions, services, and IPs depend on this prefix?"
  • Inventory gaps — "Which devices have no platform or OS version recorded?"
For automated, pipeline-enforced checks that block proposed changes, see
../infrahub-managing-checks/SKILL.md
. For repeatable scheduled reports exported as artifacts, see
../infrahub-managing-transforms/SKILL.md
.
针对实时 Infrahub 实例进行交互式数据分析的 专家指南。此 skill 使用 Infrahub MCP server 按需查询、关联并推理 基础设施数据——回答横跨多个 node type 和 relationship 的运维问题。
对于以下形式的问题,请使用此 skill: “Infrahub 当前对 X 了解多少, 以及它与 Y 有何关系?”
典型问题模式:
  • 合规性 — “所有设备是否都遵循命名约定?”
  • 服务影响 — “哪些服务托管在此机架中的设备上?”
  • 维护窗口 — “哪些设备当前处于维护窗口中,以及哪些内容依赖它们?”
  • 漂移检测 — “哪些 realized devices 与其 topology design 存在差异?”
  • 容量 — “哪些机架的容量使用率超过 80%?”
  • 变更影响 — “此 prefix 依赖哪些 BGP sessions、services 和 IPs?”
  • 资产清单缺口 — “哪些设备未记录 platform 或 OS version?”
对于能够阻止拟议变更的自动化、由 pipeline 强制执行的检查,请参阅
../infrahub-managing-checks/SKILL.md
。 对于以 artifact 形式导出的可重复定时报告,请参阅
../infrahub-managing-transforms/SKILL.md
。

Project Context

项目上下文

This skill runs in a forked subagent context and has no visibility into the parent conversation. The user's question MUST be passed via arguments.
  • If invoked with arguments (e.g.,
    /infrahub:analyzing-data Which devices have no platform assigned?
    ), treat the arguments as the question to answer.
  • If invoked with no arguments, do not guess, do not use any example question from this file, and do not proceed. Return immediately with:
    Error: No question was passed to
    infrahub-analyzing-data
    . This skill runs in a forked context and requires the user's question as args. Re-invoke with the question, e.g.
    Skill(skill="infrahub-analyzing-data", args="<the user's question>")
    .
此 skill 运行在 forked subagent context 中,无法查看 父对话。用户的问题必须通过 arguments 传递。
  • 如果带参数调用(例如
    /infrahub:analyzing-data Which devices have no platform assigned?
    ), 则应将这些参数视为需要回答的问题。
  • 如果调用时没有参数,不要猜测,不要使用本文件中的任何 示例问题,也不要继续执行。立即返回:
    Error: 未向
    infrahub-analyzing-data
    传入问题。此 skill 运行在 forked context 中,要求将用户的问题作为 args 传入。请携带 问题重新调用,例如
    Skill(skill="infrahub-analyzing-data", args="<the user's question>")
    。

When to Use

使用场景

  • Answering operational questions interactively via natural language
  • Cross-referencing two or more node types to find relationships or gaps
  • Investigating the blast radius of a change before executing it
  • Auditing data quality across the inventory
  • Producing one-time or on-demand reports for stakeholders
  • Exploring schema structure and data before writing a generator or check
  • 通过自然语言交互式回答运维问题
  • 交叉引用两个或更多 node types,以查找 relationships 或 gaps
  • 在执行变更前调查其影响范围
  • 审计整个 inventory 的数据质量
  • 面向利益相关者生成一次性或按需报告
  • 在编写 generator 或 check 前探索 schema 结构和数据

How It Works

工作原理

The Infrahub MCP server exposes tools that let Claude query Infrahub data directly. The typical workflow:
  1. Query — use MCP tools to fetch current state from Infrahub
  2. Correlate — join, diff, or filter the data against a policy or second dataset
  3. Reason — identify gaps, anomalies, or relationships
  4. Report — surface findings with context and remediation hints
Infrahub MCP server 提供了一组工具,使 Claude 可以直接查询 Infrahub 数据。典型工作流如下:
  1. 查询 — 使用 MCP tools 从 Infrahub 获取当前状态
  2. 关联 — 对数据进行 join、diff 或 filter,并与 policy 或第二个 dataset 对照
  3. 推理 — 识别 gaps、anomalies 或 relationships
  4. 报告 — 结合上下文呈现发现,并给出修复建议

Rule Categories

规则类别

PriorityCategoryPrefixDescription
CRITICALMCP Tools
mcp-
Available Infrahub MCP tools, invocation patterns, response structure
CRITICALQuery Patterns
query-
GraphQL structures for fetching, filtering, and traversing relationships
HIGHCorrelation
correlation-
Joining, diffing, and reasoning over data from multiple queries
HIGHReporting Output
reporting-
Presenting findings: summaries, tables, per-object detail, remediation hints
MEDIUMApproach Selection
approach-
When to use MCP analysis vs InfrahubCheck vs Transform
优先级类别前缀描述
CRITICALMCP 工具
mcp-
可用的 Infrahub MCP tools、调用模式和响应结构
CRITICAL查询模式
query-
用于获取、筛选和遍历 relationships 的 GraphQL 结构
HIGH数据关联
correlation-
对多个查询的数据执行 join、diff 和推理
HIGH报告输出
reporting-
呈现发现:摘要、表格、单对象详情和修复建议
MEDIUM方法选择
approach-
何时使用 MCP 分析、InfrahubCheck 或 Transform

MCP Server Basics

MCP server 基础

When the Infrahub MCP server (v1.1.7) is connected, Claude can call these tools.
Read:
  • mcp__infrahub__get_nodes
    — List nodes of a kind with filtering/pagination (preferred typed read)
  • mcp__infrahub__search_nodes
    — Find nodes of a kind by partial substring
  • mcp__infrahub__get_schema
    — Discover schema kinds and their filters
  • mcp__infrahub__query_graphql
    — Execute a read-only GraphQL query
  • mcp__infrahub__get_session_info
    — Report the active session branch and instance address
Write (branch-isolated — land on an auto-created
mcp/session-*
branch, never the default branch):
  • mcp__infrahub__node_upsert
    — Create or update an object
  • mcp__infrahub__node_delete
    — Delete an object
  • mcp__infrahub__mutate_graphql
    — Run a GraphQL mutation for complex writes
  • mcp__infrahub__propose_changes
    — Open a Proposed Change for human review
  • mcp__infrahub__reset_session_branch
    — Reset or switch the active session branch
Full per-tool signatures (parameters, examples, response shapes) and the branch model are in rules/mcp-tools.md — read that before invoking any of these.
graphql
undefined
连接 Infrahub MCP server(v1.1.7)后,Claude 可以调用以下工具。
读取:
  • mcp__infrahub__get_nodes
    — 列出指定 kind 的 nodes,支持 filtering/pagination(首选的类型化读取方式)
  • mcp__infrahub__search_nodes
    — 通过部分 substring 查找指定 kind 的 nodes
  • mcp__infrahub__get_schema
    — 发现 schema kinds 及其 filters
  • mcp__infrahub__query_graphql
    — 执行只读 GraphQL 查询
  • mcp__infrahub__get_session_info
    — 报告当前 session branch 和 instance address
写入(branch 隔离——写入自动创建的
mcp/session-*
branch,绝不写入默认 branch):
  • mcp__infrahub__node_upsert
    — 创建或更新 object
  • mcp__infrahub__node_delete
    — 删除 object
  • mcp__infrahub__mutate_graphql
    — 执行 GraphQL mutation 以完成复杂写入
  • mcp__infrahub__propose_changes
    — 创建一个供人工审查的 Proposed Change
  • mcp__infrahub__reset_session_branch
    — 重置或切换当前 session branch
每个工具的完整签名(参数、示例和响应结构)以及 branch model 位于 rules/mcp-tools.md——调用其中任何工具之前, 请先阅读该文档。
graphql
undefined

Example: find all devices in an active

Example: find all devices in an active

maintenance window

maintenance window

query MaintenanceDevices { MaintenanceWindow(status__value: "active") { edges { node { name { value } start_time { value } end_time { value } devices { edges { node { name { value } role { value } site { node { name { value } } } } } } } } } }
undefined
query MaintenanceDevices { MaintenanceWindow(status__value: "active") { edges { node { name { value } start_time { value } end_time { value } devices { edges { node { name { value } role { value } site { node { name { value } } } } } } } } } }
undefined

Typical Analysis Workflow

典型分析工作流

text
1. Understand the question
   → "Which services depend on devices currently
      in a maintenance window?"

2. Identify the node types involved
   → MaintenanceWindow, DcimDevice, Service
     (or equivalent in your schema)

3. Query current state
   → mcp__infrahub__get_nodes per kind (typed), or
     mcp__infrahub__query_graphql — one query
     per node type, or combined

4. Correlate the data
   → Join across node types, filter, count, diff

5. Report findings
   → Summarize with counts, list affected objects,
     suggest next steps
text
1. Understand the question
   → "Which services depend on devices currently
      in a maintenance window?"

2. Identify the node types involved
   → MaintenanceWindow, DcimDevice, Service
     (or equivalent in your schema)

3. Query current state
   → mcp__infrahub__get_nodes per kind (typed), or
     mcp__infrahub__query_graphql — one query
     per node type, or combined

4. Correlate the data
   → Join across node types, filter, count, diff

5. Report findings
   → Summarize with counts, list affected objects,
     suggest next steps

Supporting References

辅助参考

  • examples.md — Analysis patterns (naming, VLAN, BGP, maintenance, service impact)
  • ../infrahub-common/graphql-queries.md — GraphQL query writing reference
  • ../infrahub-common/infrahub-yml-reference.md — .infrahub.yml project configuration
  • ../infrahub-managing-checks/SKILL.md — Automated pipeline checks (for enforcement)
  • ../infrahub-managing-transforms/SKILL.md — Transforms for scheduled report artifacts
  • ../infrahub-common/rules/workflow-information-priority.md -- Skill content first; how to consult
    docs.infrahub.app
    on a genuine gap (e.g. deleting nodes)
  • rules/ — Individual rules organized by category prefix
  • examples.md — 分析模式 (命名、VLAN、BGP、维护、服务影响)
  • ../infrahub-common/graphql-queries.md — GraphQL 查询编写参考
  • ../infrahub-common/infrahub-yml-reference.md — .infrahub.yml 项目配置
  • ../infrahub-managing-checks/SKILL.md — 自动化 pipeline checks(用于强制执行)
  • ../infrahub-managing-transforms/SKILL.md — 用于定时报告 artifacts 的 Transforms
  • ../infrahub-common/rules/workflow-information-priority.md -- 优先使用 Skill 内容;确有信息缺口时(例如删除 nodes), 查询
    docs.infrahub.app
  • rules/ — 按类别前缀组织的各项规则