cx-infra
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInfrastructure Resources Skill
基础设施资源Skill
Use this skill to discover and inspect infrastructure resources — what exists, whether it
is healthy, and what its raw data contains.
使用此Skill可发现和检查基础设施资源——包括资源的存在情况、健康状态以及原始数据内容。
CLI Commands
CLI命令
| Command | Purpose | Key flags |
|---|---|---|
| List available resource types (category/type pairs) | - |
| List resources of one category/type | |
| Daily health samples for one resource, oldest first | - |
| Raw resource document as JSON | - |
- All commands are read-only and support /
-o jsonfor structured output.-o agents - Multi-profile fan-out applies to and
typesonly. Repeatliston those to compare fleets across accounts.-p <profile>andhealth-historytake a resource id, which is scoped to one team, so they reject more than oneraw-data— run them once per profile instead.-p - is repeatable across different keys; allowed keys are
--scope,service,environment(e.g.team). Multiple keys combine with AND — a resource must match all of them. Each key accepts a single value and may be given at most once; repeating one (e.g.--scope environment=prod --scope service=checkout) is rejected. To cover several values for one key, run one query per value and combine the results.--scope service=a --scope service=b - Pagination: /
--start-rowdefine a row window (--end-rowis exclusive); the default is the first 100 rows, and omitting only--end-rowgives 100 rows from--end-row. Page through large fleets in windows (0-100, 100-200, …).--start-rownever pages for you — fleets can run to hundreds of thousands of resources, so it returns one window and reports the total.list - The window cannot reach past row 10,000. The API rejects any request whose
exceeds 10,000, so paging cannot enumerate a fleet larger than that even though
start-row + rowsreports its true size. In any case, narrow withtotal_countor--name-filterand page within each subset rather than trying to walk the whole list.--scope - wraps its rows in an envelope (
list,total_count,returned_count) — the other subcommands return bare arrays.resourcesis the fleet-wide match count, always present and independent of the window, so use it as the stop condition: keep paging whiletotal_count, subject to the 10,000-row ceiling above.start_row + returned_count < total_count - Pass resource IDs exactly as returned by (quote them — they contain
listand:); the CLI percent-encodes them for you.=
| 命令 | 用途 | 关键参数 |
|---|---|---|
| 列出可用的资源类型(分类/类型对) | - |
| 列出某一分类/类型的资源 | |
| 单个资源的每日健康样本,按从旧到新排序 | - |
| 以JSON格式返回原始资源文档 | - |
- 所有命令均为只读,并支持使用/
-o json输出结构化结果。-o agents - 多配置文件扩展仅适用于和
types命令。在这些命令中重复使用list可跨账户比较资源集群。-p <profile>和health-history需要资源ID,而资源ID属于单个团队,因此这些命令拒绝多个raw-data参数——请针对每个配置文件单独运行。-p - 可针对不同键重复使用;允许的键包括
--scope、service、environment(例如team)。多个键通过逻辑与组合——资源必须匹配所有键。每个键仅接受单个值,且最多可使用一次;重复使用同一键(例如--scope environment=prod --scope service=checkout)会被拒绝。若要针对同一键的多个值进行查询,请为每个值单独运行一次查询并合并结果。--scope service=a --scope service=b - 分页:/
--start-row定义行窗口(--end-row为排他);默认返回前100行,仅省略--end-row时将从--end-row开始返回100行。请按窗口(0-100、100-200……)遍历大型资源集群。--start-row命令不会自动分页——资源集群可能多达数十万个资源,因此它仅返回一个窗口并报告总数。list - 窗口不能超过第10000行。若超过10000,API会拒绝请求,因此即使
start-row + rows报告了真实的集群大小,分页也无法枚举超过10000行的集群。无论如何,请使用total_count或--name-filter缩小范围,并在每个子集中进行分页,而非尝试遍历整个列表。--scope - 命令的结果会封装在一个信封结构中(包含
list、total_count、returned_count)——其他子命令返回的是裸数组。resources是集群范围内匹配的总数,始终存在且与窗口无关,因此请将其作为停止条件:当total_count时继续分页,但需遵守上述10000行的上限。start_row + returned_count < total_count - 请严格按照命令返回的格式传递资源ID(需加引号——它们包含
list和:);CLI会自动对其进行百分号编码。=
Inspection Workflow
检查工作流
Three steps, and only because each one supplies an input the next one requires:
gives the mandatory /, gives the .
Answering "is healthy?" is these three calls — nothing more.
types--category--typelistresource_idweb-server-1-
Discover what exists — categories and types are dynamic, so never guess:bash
cx infra resources types -o json -
List resources of that category/type, narrowing with name and scope filters:bash
cx infra resources list --category Hosts --type EC2_Instances \ --name-filter web --scope environment=prod -o json -
Inspect one resource using afrom step 2. Statuses are
resource_id,Healthy, orCritical, one sample per day, oldest first:Unmonitoredbashcx infra resources health-history "1001234:host_id=i-abc123" -o jsonis the alternative to this step, not a follow-on — use it instead when you need source-specific detail rather than health.raw-data
分为三个步骤,每个步骤的输出作为下一个步骤的输入:命令提供必填的/参数,命令提供。回答「是否健康?」只需以下三次调用——无需其他操作。
types--category--typelistresource_idweb-server-1-
发现现有资源——分类和类型是动态的,请勿猜测:bash
cx infra resources types -o json -
列出该分类/类型的资源,可通过名称和范围过滤器缩小范围:bash
cx infra resources list --category Hosts --type EC2_Instances \ --name-filter web --scope environment=prod -o json -
使用步骤2中获取的检查单个资源。状态包括
resource_id、Healthy或Critical,每天一个样本,按从旧到新排序:Unmonitoredbashcx infra resources health-history "1001234:host_id=i-abc123" -o json是此步骤的替代方案,而非后续步骤——当你需要特定来源的详细信息而非健康状态时,请使用该命令。raw-data
Examples
示例
Just the ids and names
仅获取ID和名称
bash
undefinedbash
undefinedRows live under .resources — list
returns an envelope
list结果行位于.resources下——list
命令返回信封结构
listcx infra resources list --category Hosts --type EC2_Instances -o json
| jq '[.resources[] | {resource_id, name}]'
| jq '[.resources[] | {resource_id, name}]'
undefinedcx infra resources list --category Hosts --type EC2_Instances -o json
| jq '[.resources[] | {resource_id, name}]'
| jq '[.resources[] | {resource_id, name}]'
undefinedCheck fleet size, and whether one window covered it
检查集群大小,以及当前窗口是否覆盖所有资源
bash
cx infra resources list --category Hosts --type EC2_Instances -o json \
| jq '{total_count, returned_count}'bash
cx infra resources list --category Hosts --type EC2_Instances -o json \
| jq '{total_count, returned_count}'Next window, if there is one
如果存在下一个窗口
cx infra resources list --category Hosts --type EC2_Instances
--start-row 100 --end-row 200 -o json
--start-row 100 --end-row 200 -o json
undefinedcx infra resources list --category Hosts --type EC2_Instances
--start-row 100 --end-row 200 -o json
--start-row 100 --end-row 200 -o json
undefinedFind when a resource went critical
查找资源何时变为严重状态
bash
undefinedbash
undefinedhealth-history returns a bare array, so no .resources here
health-history返回裸数组,因此这里没有.resources
cx infra resources health-history "1001234:host_id=i-abc123" -o json
| jq '[.[] | select(.status == "Critical")]'
| jq '[.[] | select(.status == "Critical")]'
undefinedcx infra resources health-history "1001234:host_id=i-abc123" -o json
| jq '[.[] | select(.status == "Critical")]'
| jq '[.[] | select(.status == "Critical")]'
undefinedRead the raw resource document
读取原始资源文档
bash
undefinedbash
undefinedSource-specific detail: tags, instance metadata, configuration
特定来源的详细信息:标签、实例元数据、配置
cx infra resources raw-data "1001234:host_id=i-abc123" -o json
undefinedcx infra resources raw-data "1001234:host_id=i-abc123" -o json
undefinedKey Principles
核心原则
- Discover before listing — and
--categoryare required; always start from--type.cx infra resources types - Quote resource IDs and pass them verbatim — they embed ,
:, and|; the CLI handles URL encoding.= - Scope keys are a fixed set (,
service,environment) — unknown keys are rejected client-side before any request is made.team - A missing raw document is not an error — exits 0 and emits an empty result on stdout:
raw-datain[],jsonin[0]:, andagentsin text. Only the noteNo raw data found.goes to stderr. Parse the empty stdout result as a cleanly absent document, not a failure — and do not expect stdout to be blank.no raw data for this resource - Use with
-o jsonfor filtering; usejqfor token-efficient output in agent contexts.-o agents - Multi-profile fan-out is for and
typesonly — repeatinglisttags each row with its profile so fleets can be compared across accounts. The row window applies per profile, so-p <profile>adds alistbreakdown — page each profile against its owncounts_by_profile, not the aggregate.total_countandhealth-historyerror on a secondraw-data.-p - A resource id never crosses profiles — it embeds the team id
(), so an id from one account cannot resolve in another. When a multi-profile
1001234:host_id=…turns up something worth inspecting, note itslistfield and query that single profile for its health or raw data.profile - Infra health is its own concept — the /
Healthy/Criticalstatuses are computed by the infrastructure domain and are not the same as Service Catalog health. Correlate them with telemetry signals; do not treat them as interchangeable.Unmonitored - never leaves this skill — pass it only to
resource_idandhealth-history. For every other command, pivot on the resourceraw-dataor thenamescope value.service
- 先发现再列出——和
--category为必填参数;请始终从--type命令开始。cx infra resources types - 为资源ID添加引号并按原样传递——它们包含、
:和|;CLI会处理URL编码。= - 范围键是固定集合(、
service、environment)——未知键会在客户端被拒绝,不会发送任何请求。team - 缺少原始文档并非错误——命令会返回0退出码,并在标准输出中输出空结果:
raw-data格式为json,[]格式为agents,文本格式为[0]:。只有No raw data found.的提示会输出到标准错误。请将标准输出的空结果视为文档不存在,而非失败——且不要期望标准输出为空。no raw data for this resource - 结合和
-o json进行过滤;在Agent环境中使用jq以实现高效的令牌输出。-o agents - 多配置文件扩展仅适用于和
types命令——重复使用list会为每行添加配置文件标签,以便跨账户比较资源集群。行窗口针对每个配置文件生效,因此-p <profile>命令会添加list细分——请针对每个配置文件的counts_by_profile进行分页,而非聚合总数。total_count和health-history命令在使用第二个raw-data参数时会报错。-p - 资源ID不会跨配置文件——它包含团队ID(),因此一个账户的ID无法在另一个账户中解析。当多配置文件的
1001234:host_id=…命令找到需要检查的资源时,请记录其list字段,并针对该单个配置文件查询其健康状态或原始数据。profile - 基础设施健康是独立概念——/
Healthy/Critical状态由基础设施域计算得出,与服务目录健康状态不同。请将它们与遥测信号关联;不要将它们视为可互换的。Unmonitored - 仅在本Skill内使用——仅将其传递给
resource_id和health-history命令。对于所有其他命令,请基于资源raw-data或name范围值进行转换。service
Related Skills
相关技能
Bridge to these skills using the resource name or the service scope
value — never the resource id, which only this skill understands:
- —
cx-telemetry-queryingdiscovers which log/span fields contain the resource name;cx search-fields "<name>" -s valuequeries the service's telemetry. Correlate acx logs "filter $l.subsystemname == '<service>'"health day with error logs or CPU metrics.Critical - —
cx-alertsfinds alert definitions matching the resource or its service by substring.cx alerts list --name "<name-or-service>" - —
cx-dashboardsandcx dashboards search "<name-or-service> ..."find dashboards semantically; pair withcx dashboards query-search --description "..."to thensearch-fields -s valuethe exact field holding the resource name.query-search --field
请使用资源名称或服务范围值连接到以下技能——切勿使用资源ID,因为只有本Skill能识别资源ID:
- ——
cx-telemetry-querying可发现哪些日志/跨度字段包含资源名称;cx search-fields "<name>" -s value可查询该服务的遥测数据。将cx logs "filter $l.subsystemname == '<service>'"健康状态的日期与错误日志或CPU指标关联。Critical - ——
cx-alerts可查找与资源或其服务名称匹配的警报定义(按子字符串匹配)。cx alerts list --name "<name-or-service>" - ——
cx-dashboards和cx dashboards search "<name-or-service> ..."可按语义查找仪表板;结合cx dashboards query-search --description "..."可使用search-fields -s value查询包含资源名称的精确字段。query-search --field