图像监控
- 作者仓库星标 38
- 许可证 MIT
- 作者更新于 实时读取
- 作者仓库 builder-skills
- 领域
- 通用
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 94 / 100 · 已通过审计
- 作者 / 版本 / 许可
- @kazdenc · MIT
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- Windows
- 底层运行要求
- 无特殊要求
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: monitor
description: Set up monitoring with error tracking, alerts, dashboards, and SLOs for production applications.…
category: 通用
runtime: 无特殊运行时
---
# monitor 输出预览
## PART A: 任务判断
- 适用问题:通用任务拆解、检查和交付。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“The Four Pillars / 1. Errors / 2. Performance”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于通用任务拆解、检查和交付,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“The Four Pillars / 1. Errors / 2. Performance”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文出现了 `/api` 这类斜杠命令;如果你的 Agent 支持命令触发,优先用命令开场,再补充目标和边界。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件。
先用一个小任务确认它会围绕“The Four Pillars / 1. Errors / 2. Performance”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: monitor
description: Set up monitoring with error tracking, alerts, dashboards, and SLOs for production applications.…
category: 通用
source: kazdenc/builder-skills
---
# monitor
## 什么时候使用
- 把通用方向的常用动作沉淀成 Agent 可调用的技能 适合处理通用任务拆解、检查、交付和复盘,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代的步骤;通常不需要额外…
- 面向通用任务拆解、检查和交付,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「The Four Pillars / 1. Errors / 2. Performance」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "monitor" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> The Four Pillars / 1. Errors / 2. Performance
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> 无特殊运行时 | 读取文件、写入/修改文件 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Production Monitoring Setup
Set up monitoring for a production application. If a target is provided, scope recommendations to that service or feature. Cover all four pillars, then configure health checks, alerts, SLOs, and dashboards.
The Four Pillars
Monitor all four. Missing any one creates a blind spot.
1. Errors
Track unhandled exceptions, failed API calls, and client-side errors. Don't wait for users to report them.
| What to capture | How |
|---|---|
| Unhandled exceptions (server) | Global error handler reports to error tracking service. Include stack trace and request context. |
| Unhandled exceptions (client) | window.onerror and onunhandledrejection wired to error tracking. |
| Failed API calls | Log 4xx and 5xx responses with request path, status, and duration. |
| Client-side errors | React error boundaries catch render failures. Report with component tree. |
Tool examples: Sentry (full stack, source maps, release tracking), LogRocket (session replay + error context).
2. Performance
Measure response times and user experience. Use percentiles, not averages.
| Metric | Target | How to measure |
|---|---|---|
| API response time (p50) | < 200ms | Server-side timing middleware. |
| API response time (p95) | < 500ms | Same middleware, track percentile distribution. |
| API response time (p99) | < 1000ms | Same middleware. If p99 spikes, investigate outlier queries. |
| Largest Contentful Paint | < 2.5s | Real User Monitoring (RUM) or Lighthouse CI. |
| First Input Delay | < 100ms | RUM. |
| Cumulative Layout Shift | < 0.1 | RUM or Lighthouse CI. |
Tool examples: Vercel Analytics (zero-config for Next.js), Speedlify (self-hosted Lighthouse tracking).
3. Availability
Know when your service is down before your users do.
| What to check | Frequency | Alert if |
|---|---|---|
| Health check endpoint | Every 30s | Two consecutive failures. |
| SSL certificate expiry | Daily | Less than 14 days remaining. |
| DNS resolution | Every 5m | Resolution fails or returns unexpected IP. |
| Key third-party services | Every 1m | Dependency returns errors for > 2 minutes. |
Tool examples: Better Uptime (status pages + incident management), Checkly (synthetic monitoring with Playwright).
4. Business Metrics
Technical metrics alone don't tell you if the product works.
| Metric | Why it matters |
|---|---|
| Signups per hour/day | Detects registration flow breakage immediately. |
| Conversion rate | Drop signals checkout or onboarding issues. |
| Key feature usage | Confirms new features are actually being used. |
| Error rate per user action | Ties technical errors to user impact. |
Tool examples: PostHog (open-source product analytics, feature flags, session replay), Mixpanel (funnel and retention analysis).
Health Check Endpoint
Create a /api/health endpoint that verifies real connectivity, not just "the server is running."
// app/api/health/route.ts
import { NextResponse } from 'next/server'
export async function GET() {
const checks: Record<string, 'ok' | 'fail'> = {}
// Check database connectivity
try {
await db.query('SELECT 1')
checks.database = 'ok'
} catch {
checks.database = 'fail'
}
// Check external services (cache, queue, etc.)
try {
await redis.ping()
checks.cache = 'ok'
} catch {
checks.cache = 'fail'
}
const allHealthy = Object.values(checks).every((s) => s === 'ok')
return NextResponse.json(
{ status: allHealthy ? 'healthy' : 'degraded', checks },
{ status: allHealthy ? 200 : 503 },
)
}
Adapt the checks to the actual services in the stack. Return 503 if any check fails so load balancers and uptime monitors detect it.
Alerting Strategy
Alert on actionable signals only. Noisy alerts get ignored.
| Signal | Severity | Notification channel | Response time |
|---|---|---|---|
| Health check down (2+ consecutive) | Critical | PagerDuty / phone call | < 15 minutes |
| Error rate > 5% of requests | Critical | Slack #incidents + PagerDuty | < 15 minutes |
| Error rate > 1% of requests | Warning | Slack #alerts | < 1 hour |
| p95 response time > 1s | Warning | Slack #alerts | < 1 hour |
| SSL cert expiry < 14 days | Info | Slack #ops | < 1 day |
| Disk usage > 80% | Warning | Slack #ops | < 4 hours |
| Deploy completed | Info | Slack #deploys | No response needed |
Rules for good alerting:
- Don't alert on single transient errors. Use thresholds and windows (e.g., "error rate > 5% over 5 minutes").
- Every alert must have a clear owner and a documented first-response action.
- Review alert fatigue monthly. If an alert fires > 3 times without action, fix it or remove it.
SLOs (Service Level Objectives)
Define SLOs for key services. SLOs set expectations; SLIs measure them.
| Service | SLI (what you measure) | SLO (target) | Error budget |
|---|---|---|---|
| API availability | % of requests returning non-5xx | 99.9% | 8.7 hours downtime / year |
| API latency | p95 response time | < 500ms | 5% of requests can exceed |
| Web vitals (LCP) | p75 LCP across all pages | < 2.5s | 25% of page loads can exceed |
| Data pipeline freshness | Time since last successful sync | < 15 minutes | 4 allowed SLO violations / month |
How to use error budgets:
- When the budget is healthy, ship fast and take calculated risks.
- When the budget is low, freeze non-critical deploys and focus on reliability.
- Track budget burn rate weekly. A sudden spike means something broke.
Dashboard Essentials
Build a team dashboard with these panels. Keep it to one screen.
| Panel | What it shows | Why |
|---|---|---|
| Error rate (last 24h) | Errors per minute, with deploy markers | Correlate errors with deploys instantly. |
| Latency trends (last 24h) | p50, p95, p99 lines on one chart | Spot gradual degradation before it becomes critical. |
| Active users (real-time) | Current connected / active users | Context for error rates. 10 errors with 10 users is worse than 10 errors with 10,000. |
| Uptime status | Green/red for each monitored endpoint | Glanceable health. |
| Deploy history | Last 10 deploys with timestamp and author | Quick reference for "what changed?" |
| SLO burn rate | Error budget remaining for the period | Know when to slow down. |
Incident Response
Use severity levels to set expectations and escalation.
| Level | Definition | Example | Response expectation |
|---|---|---|---|
| SEV1 | Service down or major data loss. Most users affected. | API returning 500 for all requests. Payment processing broken. | All hands. Respond in < 15 min. Communicate status every 30 min. |
| SEV2 | Significant degradation. Some users affected. | Slow response times. One region down. Feature broken for subset of users. | On-call responds in < 30 min. Hourly status updates. |
| SEV3 | Minor issue. Workaround exists. | Non-critical feature broken. Cosmetic bug in production. | Address within business hours. No status page update needed. |
For every incident:
- Acknowledge the alert and declare severity.
- Open an incident channel (or thread) for coordination.
- Mitigate first, investigate second. Get the service back up, then find root cause.
- Write a brief post-incident review: what happened, why, and what will prevent recurrence.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核