Token导航 LogoToken导航TokenDH.com
开发需要联网clawhub未标认证来源可访问clear审计通过

logging-observability记录可观察性

Agent Skill

logging-observability 用于辅助前端页面、组件、样式和交互逻辑开发,适合在 OpenClaw 中需要维护前端项目、生成组件或检查界面实现时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

55,860

周安装

2,375

GitHub Stars

1

下载量

19,570
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:logging-observability(记录可观察性)
来源仓库:https://github.com/wpank/logging-observability
安装命令:
openclaw skills install logging-observability
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install logging-observability

简介

用于构建可观察系统的结构化日志记录、分布式跟踪和指标收集模式。在实施日志基础设施、使用 OpenTelemetry 设置分布式跟踪、设计指标收集(RED/USE 方法)、配置警报和仪表板或审查可观察性实践时使用。涵盖结构化 JSON 日志记录、上下文传播、跟踪采样、Prometheus/Grafana 堆栈、警报设计和 PII/秘密清理。

SKILL.md

name
logging-observability
model
standard
description
Structured logging, distributed tracing, and metrics collection patterns for building observable systems. Use when implementing logging infrastructure, setting up distributed tracing with OpenTelemetry, designing metrics collection (RED/USE methods), configuring alerting and dashboards, or reviewing observability practices. Covers structured JSON logging, context propagation, trace sampling, Prometheus/Grafana stack, alert design, and PII/secret scrubbing.
version
1.0.0

Logging & Observability

Patterns for building observable systems across the three pillars: logs, metrics, and traces.

Three Pillars

PillarPurposeQuestion It AnswersExample
LogsWhat happenedWhy did this request fail?{"level":"error","msg":"payment declined","user_id":"u_82"}
MetricsHow much / how fastIs latency increasing?http_request_duration_seconds{route="/api/orders"} 0.342
TracesRequest flowWhere is the bottleneck?Span: api-gateway → auth → order-service → db

Each pillar is strongest when correlated. Embed trace_id in every log line to jump from a log entry to the full distributed trace.


Structured Logging

Always emit logs as structured JSON — never free-text strings.

Required Fields

FieldPurposeRequired
timestampISO-8601 with millisecondsYes
levelSeverity (DEBUG … FATAL)Yes
serviceOriginating service nameYes
messageHuman-readable descriptionYes
trace_idDistributed trace correlationYes
span_idCurrent span within traceYes
correlation_idBusiness-level correlation (order ID)When applicable
errorStructured error objectOn errors
contextRequest-specific metadataRecommended

Context Enrichment

Attach context at the middleware level so downstream logs inherit automatically:

app.use((req, res, next) => {
  const ctx = {
    trace_id: req.headers['x-trace-id'] || crypto.randomUUID(),
    request_id: crypto.randomUUID(),
    user_id: req.user?.id,
    method: req.method,
    path: req.path,
  };
  asyncLocalStorage.run(ctx, () => next());
});

Library Recommendations

LibraryLanguageStrengthsPerf
PinoNode.jsFastest Node logger, low overheadExcellent
structlogPythonComposable processors, context bindingGood
zerologGoZero-allocation JSON loggingExcellent
zapGoHigh performance, typed fieldsExcellent
tracingRustSpans + events, async-awareExcellent

Choose a logger that outputs structured JSON natively. Avoid loggers requiring post-processing.


Log Levels

LevelWhen to UseExample
FATALApp cannot continue, process will exitDatabase connection pool exhausted
ERROROperation failed, needs attentionPayment charge failed: CARD_DECLINED
WARNUnexpected but recoverableRetry 2/3 for upstream timeout
INFONormal business eventsOrder ORD-1234 placed successfully
DEBUGDeveloper troubleshootingCache miss for key user:82:preferences
TRACEVery fine-grained (rarely in prod)Entering validateAddress with payload

Rules: Production default = INFO and above. If you log an ERROR, someone should act on it. Every FATAL should trigger an alert.


Distributed Tracing

OpenTelemetry Setup

Always prefer OpenTelemetry over vendor-specific SDKs:

import { NodeSDK } from '@opentelemetry/sdk-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';

const sdk = new NodeSDK({
  serviceName: 'order-service',
  traceExporter: new OTLPTraceExporter({
    url: 'http://otel-collector:4318/v1/traces',
  }),
  instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();

Span Creation

const tracer = trace.getTracer('order-service');

async function processOrder(order: Order) {
  return tracer.startActiveSpan('processOrder', async (span) => {
    try {
      span.setAttribute('order.id', order.id);
      span.setAttribute('order.total_cents', order.totalCents);
      await validateInventory(order);
      await chargePayment(order);
      span.setStatus({ code: SpanStatusCode.OK });
    } catch (err) {
      span.setStatus({ code: SpanStatusCode.ERROR, message: err.message });
      span.recordException(err);
      throw err;
    } finally {
      span.end();
    }
  });
}

Context Propagation

  • Use W3C Trace Context (traceparent header) — default in OTel
  • Propagate across HTTP, gRPC, and message queues
  • For async workers: serialise traceparent into the job payload

Trace Sampling

StrategyUse When
Always OnLow-traffic services, debugging
Probabilistic (N%)General production use
Rate-limited (N/sec)High-throughput services
Tail-basedWhen you need all error traces

Always sample 100% of error traces regardless of strategy.


Metrics Collection

RED Method (Request-Driven)

Monitor these three for every service endpoint:

MetricWhat It MeasuresPrometheus Example
RateRequests/secrate(http_requests_total[5m])
ErrorsFailed request ratiorate(http_requests_total{status=~"5.."}[5m])
DurationResponse timehistogram_quantile(0.99, http_request_duration_seconds)

USE Method (Resource-Driven)

For infrastructure components (CPU, memory, disk, network):

MetricWhat It MeasuresExample
Utilization% resource busyCPU usage at 78%
SaturationWork queued/waiting12 requests queued in thread pool
ErrorsError events on resource3 disk I/O errors in last minute

Monitoring Stack

ToolCategoryBest For
PrometheusMetricsPull-based metrics, alerting rules
GrafanaVisualisationDashboards for metrics, logs, traces
JaegerTracingDistributed trace visualisation
LokiLogsLog aggregation (pairs with Grafana)
OpenTelemetryCollectionVendor-neutral telemetry collection

Recommendation: Start with OTel Collector → Prometheus + Grafana + Loki + Jaeger. Migrate to SaaS only when operational overhead justifies cost.


Alert Design

Severity Levels

SeverityResponse TimeExample
P1ImmediateService fully down, data loss
P2< 30 minError rate > 5%, latency p99 > 5s
P3Business hoursDisk > 80%, cert expiring in 7 days
P4Best effortNon-critical deprecation warning

Alert Fatigue Prevention

  • Alert on symptoms, not causes — "error rate > 5%" not "pod restarted"
  • Multi-window, multi-burn-rate — catch both sudden spikes and slow burns
  • Require runbook links — every alert must link to diagnosis and remediation
  • Review monthly — delete or tune alerts that never fire or always fire
  • Group related alerts — use inhibition rules to suppress child alerts
  • Set appropriate thresholds — if alert fires daily and is ignored, raise threshold or delete

Dashboard Patterns

Overview Dashboard ("War Room")

  • Total requests/sec across all services
  • Global error rate (%) with trendline
  • p50 / p95 / p99 latency
  • Active alerts count by severity
  • Deployment markers overlaid on graphs

Service Dashboard (Per-Service)

  • RED metrics for each endpoint
  • Dependency health (upstream/downstream success rates)
  • Resource utilisation (CPU, memory, connections)
  • Top errors table with count and last seen

Observability Checklist

Every service must have:

  • [ ] Structured JSON logging with consistent schema
  • [ ] Correlation / trace IDs propagated on all requests
  • [ ] RED metrics exposed for every external endpoint
  • [ ] Health check endpoints (/healthz and /readyz)
  • [ ] Distributed tracing with OpenTelemetry
  • [ ] Dashboards for RED metrics and resource utilisation
  • [ ] Alerts for error rate, latency, and saturation with runbook links
  • [ ] Log level configurable at runtime without redeployment
  • [ ] PII scrubbing verified and tested
  • [ ] Retention policies defined for logs, metrics, and traces

Anti-Patterns

Anti-PatternProblemFix
Logging PIIPrivacy/compliance violationMask or exclude PII; use token references
Excessive loggingStorage costs balloon, signal drownsLog business events, not data flow
Unstructured logsCannot query or alert on fieldsUse structured JSON with consistent schema
String interpolationBreaks structured fields, injection riskPass fields as metadata, not in message
Missing correlation IDsCannot trace across servicesGenerate and propagate trace_id everywhere
Alert stormsOn-call fatigue, real issues buriedUse grouping, inhibition, deduplication
Metrics with high cardinalityPrometheus OOM, dashboard timeoutsNever use user ID or request ID as label

NEVER Do

  1. NEVER log passwords, tokens, API keys, or secrets — even at DEBUG level
  2. NEVER use console.log / print in production — use a structured logger
  3. NEVER use user IDs, emails, or request IDs as metric labels — cardinality will explode
  4. NEVER create alerts without a runbook link — unactionable alerts erode trust
  5. NEVER rely on logs alone — you need metrics and traces for full observability
  6. NEVER log request/response bodies by default — opt-in only, with PII redaction
  7. NEVER ignore log volume — set budgets and alert when a service exceeds daily quota
  8. NEVER skip context propagation in async flows — broken traces are worse than no traces

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

88.84%
按下载量换算17,386

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

未展示

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills