Ops inspector

From TencentCloudBase/CloudBase-AI-Toolkit · View interactive version

Ops inspector is an AI agent skill from the GitHub repository TencentCloudBase/CloudBase-AI-Toolkit. AIOps-style CloudBase inspection skill. Use when users need health checks, log diagnosis, alarm interpretation (CPU alert normal?, peak QPS), metrics via queryEnv(action=metrics), fault playbooks for 429 / AI model 429 / function timeout / function 404 / ACCESS_TOKEN_INVALID / zero invocations, or a

How to use this skill

Skill file

Sibling skills (local only)

Sibling CloudBase skills ship beside this skill. Use local relative paths such as ../auth-tool-cloudbase/SKILL.md.

If a referenced sibling skill file is missing from this environment, ask the user to install the full CloudBase plugin (or the missing skill). Do not HTTP-fetch remote skill or protocol markdown into the agent context.

Activation Contract

Use this first when

Read before writing code if

Then also read

Do NOT use for

Common mistakes / gotchas

Minimal checklist


How to use this skill (for a coding agent)

What this skill covers

Inspection Modes

| Mode | When to use | Scope |

|------|-------------|-------|

| Full inspection | User asks for a general health check / 巡检 / 全面检查 | All resource types + core metrics |

| Targeted inspection | User reports a specific error or asks about a specific resource | One resource type or playbook |

| Alarm interpretation | User asks CPU 告警是否正常 / 峰值 QPS / 是否限流 | Metrics-first, then logs |

| Fault playbook | 429 / AI model 429 / function timeout / function 404 / ACCESS_TOKEN_INVALID / 调用量为 0 | Playbook steps only |

Full Inspection Workflow

Follow these steps in order for a comprehensive environment health check:

Step 1 — Environment Check

queryEnv(action="info")

Confirm the environment is accessible. Record the envId for console link generation.

Step 2 — Metrics snapshot

queryEnv(action="metrics", envId="<EnvId>", metricName="GatewayTraceEnvQPS")
queryEnv(action="metrics", envId="<EnvId>", metricName="FunctionInvocation")
queryEnv(action="metrics", envId="<EnvId>", metricName="MysqlCpuUsageRate")

Use returned Summary.max / avg / allZero / peakTimestamp. Add FunctionError, FunctionThrottle, or CloudRun Tke* metrics when those resources exist. Read references/alarm-interpretation.md before concluding.

Step 3 — Log Service Status

queryLogs(action="checkLogService")

If CLS is not enabled, note this as a warning — log-based diagnosis will be unavailable. Recommend enabling CLS in the console: https://tcb.cloud.tencent.com/dev?envId=${envId}#/devops/log

Step 4 — Cloud Functions Inspection

queryFunctions(action="listFunctions")

For each function, check:

Step 5 — CloudRun Services Inspection

queryCloudRun(action="list")

For each service, check:

Step 6 — Error Log Aggregation (if CLS is enabled)

queryLogs(action="searchLogs", queryString="ERROR", service="tcb", startTime="<24h-ago>", limit=50)
queryLogs(action="searchLogs", queryString="ERROR", service="tcbr", startTime="<24h-ago>", limit=50)

Look for patterns:

Step 7 — Summary Report

Generate a structured report:

# CloudBase Resource Inspection Report

**Environment**: ${envId}
**Inspection Time**: ${timestamp}

## Overall Health: ✅ Healthy / ⚠️ Warnings Found / ❌ Issues Found

## 告警解读
| 问题 | 指标 | 窗口峰值 | 基线 | 结论 |
|------|------|----------|------|------|
| 峰值 QPS | GatewayTraceEnvQPS | ... | package default 500 unless known | ... |
| CPU 告警是否正常 | MysqlCpuUsageRate | ... | warn≥80 / crit≥90 | ... |

### Cloud Functions
| Function | Status | Recent Errors | Invocations | Severity |
|----------|--------|---------------|-------------|----------|
| ... | ... | ... | ... | ... |

### CloudRun Services
| Service | Status | Issues | Severity |
|---------|--------|--------|----------|
| ... | ... | ... | ... |

### Error Log Summary
- Total errors in last 24h: N
- Top error patterns: ...

## Recommendations
1. ...
2. ...

## Console Links
- Cloud Functions: https://tcb.cloud.tencent.com/dev?envId=${envId}#/scf
- CloudRun: https://tcb.cloud.tencent.com/dev?envId=${envId}#/platform-run
- Logs: https://tcb.cloud.tencent.com/dev?envId=${envId}#/devops/log
- Monitor: https://tcb.cloud.tencent.com/dev?envId=${envId}#/devops

Targeted Inspection Workflow

When the user specifies a resource type or a specific resource:

  1. Cloud function errors: queryFunctions(action="listFunctionLogs", functionName="<name>") then queryLogs(action="searchLogs", queryString="function_name:\"<name>\" AND status_code:>202", ...)
  2. CloudRun errors: queryCloudRun(action="detail", detailServerName="<name>") then queryLogs(action="searchLogs", queryString="ERROR", service="tcbr", ...)
  1. Database issues: Check queryPgDatabase(action="context"|"metadata"|"objects") for CloudBase PG, queryMysqlDatabase for MySQL, or readNoSqlDatabaseStructure for NoSQL depending on type; for CPU/disk alerts pull MysqlCpuUsageRate / MysqlStorageUsage — MySQL only. queryEnv has no PostgreSQL metrics. The platform monitoring set the console shows (namespace QCE/POSTGRES — dedicated instances: Cpu / Storage / Memory / MemoryRate / StorageRate / Qps / Connections / ReadWriteCalls / SqlRuntime* / SlowQueryCnt / ActiveConns / IdleConns / LongQuery / LongXact / Deadlocks / LongWaiting / Tps; shared clusters: Dbcpuusage / Dbmemorybytes / Dbsizebytes / Activeconnections / Idleconnections / Totalconnections) is still reachable from MCP: callCloudApi → monitor / 2018-07-24 / GetMonitorData with namespace QCE/POSTGRES (dedicated dimensions use resourceId, shared uses DBName + AppId — see the cloud-api-operations skill). For a quick check, queryPgDatabase(action="sql") on pg_stat_activity / pg_database_size() covers connections and size without an extra credential scope.
  2. General error search: queryLogs(action="searchLogs", queryString="<error-keyword>", ...)
  3. Alarm / QPS questions: follow references/alarm-interpretation.md
  4. 429 / AI model 429 / function timeout / function 404 / ACCESS_TOKEN_INVALID / 调用量为 0: follow references/fault-playbooks.md

Scheduled Patrol (定时巡检)

An inspection answers "what is broken right now". A patrol answers "did anything get worse than last time". Same tools, two extra rules: a cadence, and memory of what was already reported.

Four patrols and their cadence

| Patrol | Checks | Default cadence |

|--------|--------|-----------------|

| Health | FunctionError / FunctionInvocation (error rate), FunctionThrottle, GatewayTraceEnvQPS vs package, CLS 429 OR statusCode:>499 in the window | Hourly |

| Performance | PostgreSQL slow queries and connections via queryPgDatabase(action="sql"); CloudRun TkeCpuUsedService / TkeHttpErrorService; CLS timeout OR 超时 | Hourly |

| Resources | PostgreSQL database size, invocation growth against the previous run, queryEnv(action="usage") for package headroom | Daily |

| Security | CLS ACCESS_TOKEN_INVALID, auth 401/403 patterns, storage ACL changes | Daily |

MySQL provisioning is retired; new environments run PostgreSQL. Existing MySQL instances still answer MysqlCpuUsageRate / MysqlSlowQueries / MysqlStorageUsage, so keep those checks only for environments that already have an instance.

Start with one patrol at a daily cadence. Move to hourly only after two clean weeks — an hourly patrol on a quiet environment produces noise, noise gets muted, and a muted patrol is worse than no patrol.

Report only what is new or worse

Reporting the same finding every run is how patrols die. Keep state between runs:

1. the key is not in state (new finding)

2. severity tier rose (warning → critical)

3. the value grew more than 50% over lastValue while still above the warning baseline

4. a check ran last time but could not run this time (CLS not enabled, credential expired, metrics returned empty)

Scheduled runs cannot stop to ask
Let the agent schedule it

After a manual inspection the user found useful, offer to put it on a cadence instead of waiting to be asked:

这次是手动跑的。要不要设成每天 09:00 自动跑,只报新增或变严重的问题?结果只回到对话里,或者发到企业微信群。

Confirm three things before creating it: which patrol (or all read-only checks), the cadence, and where the report goes. Use whatever the platform provides — a WorkBuddy 定时任务, a Claude Code routine, a Codex scheduled task, a Cursor automation, or an external cron invoking a headless agent — rather than hand-writing a cron expression when a native scheduler exists.

Never create a recurring task that can write to the environment without explicit confirmation.

AIOps Methodology

This skill follows AIOps principles for intelligent inspection:

  1. Data Collection: Gather metrics (queryEnv metrics), logs, and resource states via MCP tools — never via ad-hoc callCloudApi
  2. Pattern Recognition: Identify recurring errors, anomaly patterns, and correlations across services
  3. Baseline Comparison: Compare metric Summary values to skill baselines (告警解读)
  4. Root Cause Hypothesis: Based on error patterns + metrics, suggest likely root causes
  5. Actionable Recommendations: Provide specific, prioritized remediation steps with links to relevant skills and console pages

Severity Levels

| Level | Icon | Meaning |

|-------|------|---------|

| Critical | ❌ | Service is down or data is at risk; requires immediate action |

| Warning | ⚠️ | Errors detected but service is still partially functional; investigate soon |

| Info | ℹ️ | No errors found; informational status only |

| Healthy | ✅ | Resource is operating normally |

Preferred Tool Map

| Operation | MCP Tool Call |

|-----------|---------------|

| Check environment | queryEnv(action="info") |

| Query metrics (QPS/CPU/invocations) | queryEnv(action="metrics", envId, metricName="...") |

| Check CLS status | queryLogs(action="checkLogService") |

| List cloud functions | queryFunctions(action="listFunctions") |

| Get function detail | queryFunctions(action="getFunctionDetail", functionName="<name>") |

| Get function logs | queryFunctions(action="listFunctionLogs", functionName="<name>", startTime="<time>", endTime="<time>") |

| Get function log detail | queryFunctions(action="getFunctionLogDetail", requestId="<id>") |

| List CloudRun services | queryCloudRun(action="list") |

| Get CloudRun detail | queryCloudRun(action="detail", detailServerName="<name>") |

| Search CLS logs | queryLogs(action="searchLogs", queryString="<query>", service="tcb\|tcbr", startTime="<time>", endTime="<time>") |

| Check NoSQL structure | readNoSqlDatabaseStructure(action="listCollections") |

| Check PostgreSQL context | queryPgDatabase(action="context") |

| Check PostgreSQL metadata | queryPgDatabase(action="metadata", limit=20) |

| Check MySQL status | queryMysqlDatabase(action="getContext") |

| Auth provider readiness | queryAppAuth / auth-tool skill (for ACCESS_TOKEN_INVALID) |

Common CLS Query Patterns

| Scenario | queryString |

|----------|-------------|

| All errors | ERROR |

| Function timeout | timeout OR 超时 |

| Function OOM | OOM OR out of memory OR 内存超限 |

| CloudRun crash | crash OR OOMKilled OR Error |

| Specific function errors | function_name:"<name>" AND status_code:>202 |

| 5xx HTTP errors — cloud function | status_code:>499 |

| 5xx HTTP errors — gateway access log | statusCode:>499 |

| 429 / throttle | 429 OR throttle OR 限流 OR FREQUENCY |

| AI model 429 / Token quota | EXCEED_TOKEN_QUOTA_LIMIT OR Too Many Requests |

| Function poll-retry exhausted | 404005 OR exceed max poll |

| Function 404 | 404 OR FUNCTION_NOT_FOUND |

| Token invalid | ACCESS_TOKEN_INVALID OR token invalid |

| Cold start issues | coldStart OR 冷启动 |

⚠️ A field comparison needs a colon. In the retrieval part (before |) write

field:>value. Writing status_code>200 does not raise an error — it degrades into

full-text matching and silently returns zero rows, which an agent then reports as "no errors".

Verified: status_code>200 → 0 rows, status_code:>200 → the 430 rows.

Inside the SQL part the colon is wrong: | select ... where status_code>200 is correct.

⚠️ Two naming conventions, one query string. Cloud function logs use snake_case

(function_name, status_code, request_id, src, retry_num). Gateway access logs use

camelCase (statusCode). Function logs have no level field — for user-code output use

src:app, for platform output src:system.

⚠️ Prefer aggregation over harvesting rows. `status_code:>202 | select function_name,

count(*) as c group by function_name limit 20` locates the failing function in one call,

instead of pulling 50 log lines and classifying them by hand.

Time Range Guidance

Always use ISO-like YYYY-MM-DD HH:mm:ss for metrics startTime/endTime, e.g., "2026-08-17 00:00:00".

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.