cx-infra
Query Coralogix infrastructure resources with the `cx infra` CLI: resource types, filterable attributes, resource lists, health, raw data and configuration changes. Use when the user asks to "show resource types", "list infrastructure resources", "what resources of this kind are monitored", "is this resource healthy", "why is this resource critical", "which health policy is failing", "when did this resource go critical", "get raw resource data", "find resources by name", "filter resources by service or environment", "critical hosts in a region", "what can I filter resources by", "resources in this cluster or namespace", "which resources changed recently", "what changed in this resource", "configuration drift", "did anything change before the incident", "what was this config last week", or wants to explore infrastructure resources.
coralogix · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add coralogix/cx-cli --skill cx-infra技能说明
name: cx-infra
description: >
Query Coralogix infrastructure resources with the cx infra CLI: resource
types, filterable attributes, resource lists, health, raw data and
configuration changes. Use when the user asks to "show resource types",
"list infrastructure resources", "what resources of this kind are monitored",
"is this resource healthy", "why is this resource critical",
"which health policy is failing", "when did this resource go critical",
"get raw resource data", "find resources by name",
"filter resources by service or environment", "critical hosts in a region",
"what can I filter resources by", "resources in this cluster or namespace",
"which resources changed recently", "what changed in this resource",
"configuration drift", "did anything change before the incident",
"what was this config last week", or wants to explore infrastructure resources.
metadata:
version: "0.2.0"
Infrastructure Resources
All commands live under cx infra resources and are read-only. Run
cx infra resources <command> --help for flags.
"Infrastructure monitoring is not enabled for this team" means the team has no infrastructure data. Stop and say so. Do not retry or change filters.
A stderr line starting warning: ... could not verify that infrastructure monitoring is enabled is informational: the enablement check itself failed and
the command still ran.
| Command | Answers |
|---|---|
types | which (category, type) pairs exist |
filters | which attributes can be filtered on, and their accepted values |
list | which resources match, with their health policies |
health-history | daily health per resource, oldest first |
raw-data | the raw resource document, now or at a past time |
config-changes | which resources changed configuration in a window |
config-diff | what changed, field by field |
Resource ids
- Take them from
list(resource_id) and pass them as-is, quoted. health-history,config-changesandconfig-difftake up to 100 ids per call. Pass them all in one call, not one call each. Over 100, the CLI refuses. Split into batches.- An id belongs to one team, so the id commands refuse more than one
-p. Onlytypes,filtersandlistfan out across profiles. From a multi-profilelist, use the row'sprofileto pick the one to query. - Ids mean nothing outside this skill. To reach other skills, use the resource
nameor itsServicevalue.
Finding resources
filtersfirst. Attribute names and values differ per type, so never guess. Per attribute:kind(stringis free text,statusa fixed set),values(the accepted set) andwildcard(whether*works).listwith the filters:- Every
--match-allmust match, at least one--match-anymust match, and the two groups are ANDed.--match-all OS=linux --match-any Health=Critical --match-any Region=eu-west-1meansOS=linux AND (Health=Critical OR Region=eu-west-1). - Commas give one attribute several values. In
--match-anyany one matches. In--match-allall must, which only makes sense for wildcards:--match-all 'Name=*alert*,*processing*'. - Name an attribute once, in one flag. A repeat is refused.
--categoryand--typeare plain filters, not requirements, and are not attributes (no--match-all Category=...). At least one filter or scope flag is required.- Exact values are case-sensitive (
OS=linux, notOS=Linux). Wildcards are not. Quote wildcards so the shell leaves*alone. --name-filterand--scope(service,environment,team) are legacy flags. They need both--categoryand--type, and cannot mix with--match-*.--match-all 'Name=*web*'does what--name-filter webdoes.
- Every
- Zero rows is an answer. Don't retry. A wrong attribute or value is refused with the accepted ones listed.
list -o json is an envelope: {total_count, returned_count, resources}.
The other commands return plain arrays or objects.
- It returns one window, rows 0 to 100 by default (
--start-row, and--end-rowwhich is exclusive). Keep paging whilestart_row + returned_count < total_count. - A window cannot pass row 10,000. For bigger results, narrow the query.
- With several profiles, each one pages against its own
total_count(seecounts_by_profile).
Health
listrows carryhealth_policies: [{id, name, status}]withstatusone ofhealthy,criticalorpending(not evaluated yet). A critical policy says why a resource is critical. No extra call needed.health-historyreturns[{resource_id, health_history: [{timestamp, status}]}]withstatusone ofHealthy,CriticalorUnmonitored. The two sets of statuses have different casing.- Ids that don't parse, and repeats, are dropped. A shorter answer is normal and stderr gives the count. Returned ids are normalized, so they may not string-match the ones sent.
- Infra health is not Service Catalog health. Correlate it with telemetry rather than treating the two as the same.
cx infra resources list --match-all Health=Critical -o json \
| jq '.resources[] | {name, failing: [.health_policies[] | select(.status == "critical") | .name]}'
cx infra resources health-history "1001234:host_id=i-abc" "1001234:host_id=i-def" -o json \
| jq '.[] | {resource_id, critical: [.health_history[] | select(.status == "Critical") | .timestamp]}'
Raw data
raw-data -o json returns {version_timestamp, raw_data}.
--timestamp(now-7dor ISO-8601) gets the newest version at or before that time.version_timestampsays whi