Token导航 LogoToken导航TokenDH.com
开发external-servicegithub未标认证来源可访问许可证需确认审计通过

nestjs-lgtm-metricsNestjs LGTM 指标

Agent Skill

nestjs-lgtm-metrics 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

188

周安装

8

GitHub Stars

公开资料未说明

下载量

66
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:nestjs-lgtm-metrics(Nestjs LGTM 指标)
来源仓库:https://github.com/cmglezpdev/custom-skills
仓库路径:skills/nestjs-lgtm-metrics
安装命令:
npx skills add https://github.com/cmglezpdev/custom-skills --skill nestjs-lgtm-metrics
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/cmglezpdev/custom-skills --skill nestjs-lgtm-metrics

简介

nestjs-lgtm-metrics 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更或协作事项进行整理。
  • 通过 npx skills add 命令从指定仓库安装,需结合原始 README 核验具体用法。
  • 安装前建议确认权限范围、维护状态及是否会触发联网、命令执行或文件读写操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

NestJS Application Metrics via OpenTelemetry

What This Skill Covers

This skill adds application-level metrics to a NestJS app using the OpenTelemetry SDK, pushing them through an OTel Collector into Prometheus. It is organized in progressive stages, from foundational to advanced.

Scope boundary: This skill covers metrics only. Not logging, not tracing. Infrastructure metrics (container resources, host stats, database server stats, Redis server stats) come from their respective exporters and community Grafana dashboards. This skill covers what those exporters cannot see: request-level behavior, business events, runtime internals, and domain-specific KPIs as observed from inside your application.

Prerequisites

  • NestJS application
  • OpenTelemetry Collector running and reachable from the app
  • Prometheus configured as an export target from the Collector
  • Grafana connected to Prometheus as a data source

Architecture

NestJS App (OTel SDK) ──OTLP/gRPC──▶ OTel Collector ──remote_write──▶ Prometheus ──▶ Grafana

The app never exposes a /metrics endpoint. It pushes metrics to the Collector via OTLP. The Collector handles export to Prometheus (via prometheusremotewrite exporter or a Prometheus scrape on the Collector itself).

Read references/otel-setup.md before writing any application metric code. It covers the SDK bootstrap, Collector pipeline config, and how to verify the pipeline is working end to end.

Implementation Stages

Each stage builds on the previous. Read the corresponding reference file for full implementation code.


Stage 1: Foundation (Day 1, any app)

Read: references/stage-1-foundation.md

Non-negotiable. Every NestJS app in production needs these from the start.

What you get:

  1. HTTP RED metrics (Rate, Errors, Duration) via a global interceptor

- http_request_duration_seconds histogram, labeled by method, route, status_code - http_requests_total counter, labeled by method, route, status_code - http_requests_in_flight up/down counter

  1. Node.js runtime metrics (what V8/libuv expose that no infra exporter can see)

- nodejs_eventloop_lag_seconds histogram (not just mean. percentiles matter) - nodejs_active_handles_total observable gauge - nodejs_active_requests_total observable gauge - GC duration, heap size, external memory via @opentelemetry/host-metrics

  1. Health and readiness probe metrics

- app_health_check_duration_seconds histogram by check_name - app_health_check_status gauge (1=healthy, 0=unhealthy) by check_name

Why these first: HTTP RED gives you the ability to detect problems. Runtime metrics tell you whether the Node.js process itself is degraded. Health checks close the loop with your orchestrator. Together they answer: "Is the app working? How fast? For whom is it failing?"

Histogram bucket strategy: Use explicit bucket boundaries initially: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10]. Tune after you have real traffic data. Do not over-bucket. More buckets = more time series = more Prometheus storage cost.


Stage 2: Application Intelligence (Week 1-2, pre-launch)

Read: references/stage-2-app-intelligence.md

These metrics expose application behavior that sits between raw HTTP and business logic.

What you get:

  1. Database query metrics from the app's perspective

- app_db_query_duration_seconds histogram by operation (select, insert, update, delete), entity - app_db_query_errors_total counter by operation, error_type - app_db_connection_pool_wait_seconds histogram - Why this matters: postgres-exporter sees server-side query time. Your app sees ORM overhead + pool wait + serialization + network. The gap between these two is where bugs hide.

  1. Redis operation metrics from the app's perspective

- app_redis_operation_duration_seconds histogram by operation (get, set, del, etc.), key_prefix - app_redis_operation_errors_total counter - app_cache_hit_total / app_cache_miss_total counters by cache_name - Why this matters: redis-exporter sees keyspace_hits/misses globally. Your app knows WHICH cache strategy worked and which didn't.

  1. External API call metrics

- app_external_api_duration_seconds histogram by service, endpoint, status_code - app_external_api_errors_total counter by service, error_type - app_circuit_breaker_state gauge (0=closed, 0.5=half-open, 1=open) by service

  1. Authentication and authorization metrics

- app_auth_attempts_total counter by method (password, oauth, api_key), result (success, failure, locked) - app_auth_token_operations_total counter by operation (issue, refresh, revoke, expire) - app_authorization_denied_total counter by resource, action

  1. Background job / queue metrics (Bull, BullMQ, or similar)

- app_job_duration_seconds histogram by queue, job_type - app_job_completed_total counter by queue, job_type, status (completed, failed, stalled) - app_job_queue_depth gauge by queue - app_job_attempts_total counter by queue, job_type (tracks retry behavior)


Stage 3: Business Metrics (Launch, real users)

Read: references/stage-3-business-metrics.md

Once users arrive, technical metrics aren't enough. You need to observe the business through the same system.

What you get:

  1. User lifecycle events

- app_user_signups_total counter by source, plan - app_user_logins_total counter by method - app_user_actions_total counter by action_type (generic, high-cardinality-safe pattern)

  1. Transaction / conversion metrics

- app_transactions_total counter by type, status - app_transaction_value_total counter (sum of monetary values) by currency - app_conversion_funnel_step_total counter by funnel, step

  1. Feature usage metrics

- app_feature_usage_total counter by feature_name, variant (useful for A/B tests) - app_feature_errors_total counter by feature_name

  1. SLI metrics for SLO tracking

- app_sli_request_availability counter (successful requests / total requests, partitioned) - app_sli_request_latency histogram (tighter buckets around your SLO threshold)

Cardinality warning: Business metrics are where cardinality explosions happen. Never use user_id, session_id, or any unbounded value as an attribute. Use bucketed categories. Read the cardinality section in references/stage-3-business-metrics.md.


Stage 4: Advanced Patterns (Scaled app, mature team)

Read: references/stage-4-advanced.md

For apps serving real traffic at scale, handling complex flows, or needing tight operational control.

What you get:

  1. WebSocket / real-time connection metrics

- app_ws_connections_active gauge by namespace - app_ws_messages_total counter by namespace, direction (in/out), event_type - app_ws_connection_duration_seconds histogram

  1. Rate limiter observability

- app_rate_limit_hits_total counter by limiter, route - app_rate_limit_remaining gauge by limiter (sampled, not per-request)

  1. Multi-tenant metrics

- app_tenant_requests_total counter by tenant_tier (not tenant_id. cardinality.) - app_tenant_resource_usage gauge by tenant_tier, resource_type

  1. Graceful shutdown and lifecycle

- app_shutdown_duration_seconds histogram - app_startup_duration_seconds gauge

  1. Deployment version tracking

- app_info gauge with version, commit_sha, environment attributes for canary analysis


Grafana Dashboard Templates

Import-ready Grafana dashboard JSON files, one per stage. Each uses ${DS_PROMETHEUS} as the data source variable, so Grafana will prompt you to select your Prometheus data source on import.

How to import: Grafana → Dashboards → New → Import → Upload JSON file → Select your Prometheus data source.

TemplatePanelsDescription
templates/stage-1-service-overview.json14Golden signals (stat), request rate by route, error rate, latency percentiles, P99 by route, event loop lag, heap memory, active handles, health check status and duration.
templates/stage-2-dependency-health.json15DB query P95 by operation, pool wait time, DB errors, cache hit ratio by strategy, Redis op latency, Redis errors, external API P95, circuit breaker state, API errors, auth failure rate, token ops, authz denials, queue depth, job duration, job failure rate.
templates/stage-3-business-metrics.json14Signups/revenue/success rate big numbers, signups by source, logins by method, revenue rate, transaction failure rate, funnel step totals, feature usage by variant, feature errors, 30-day SLO availability, SLI latency percentiles, error budget burn rate.
templates/stage-4-operational.json10Running versions table, startup/shutdown duration, active WS connections, WS message throughput, WS connection duration, rate limit rejections by route, remaining tokens, request volume by tenant tier, resource usage by tier.

Each dashboard is standalone. Combine panels across dashboards as your needs evolve. All dashboards include $job and $instance template variables for filtering. Stage 3 additionally includes $funnel and $sli selectors.


Grafana Dashboard Strategy

Read references/grafana-dashboards.md for dashboard panel definitions and provisioning.

Dashboard hierarchy:

  1. Service Overview (Stage 1): RED metrics, runtime health, up/down status. One dashboard per service.
  2. Dependency Health (Stage 2): DB latency, Redis hit rates, external API status. Shows how your app EXPERIENCES its dependencies.
  3. Business Dashboard (Stage 3): Conversion funnels, feature adoption, revenue metrics. Non-engineers should be able to read this.
  4. Operational Dashboard (Stage 4): Rate limits, circuit breakers, tenant resource usage, deployment comparison.

Alert hierarchy (pair with dashboards):

  • Stage 1: Error rate spike, latency P99 breach, event loop lag > 100ms
  • Stage 2: DB query latency drift, cache hit rate drop, external API circuit open
  • Stage 3: Conversion rate drop, signup anomaly
  • Stage 4: Rate limiter saturation, tenant quota breach

Infrastructure Exporters and Community Dashboards

Read: references/infra-exporters.md

Your app metrics (Stages 1-4) show how the application experiences its dependencies. Infrastructure exporters show how those services perform internally. You need both. The gap between them is where most production issues hide.

This reference covers exporter setup (docker-compose), Prometheus scrape config, and community Grafana dashboard IDs for: PostgreSQL, Redis, RabbitMQ, MongoDB, Qdrant, Elasticsearch, Nginx, MinIO, plus node-exporter and cAdvisor for host/container metrics.

Each entry includes the key metrics the exporter provides and, critically, what it does NOT tell you (which your app-level metrics fill).


Common Mistakes to Avoid

  1. High-cardinality attributes: Never use userId, requestId, IP, or full URL path as a metric attribute. Use route patterns. If you need per-user data, that's a log or trace, not a metric.
  2. Metric name collisions: Prefix everything with app_. Infra exporters use node_, pg_, redis_, container_.
  3. Too many buckets: Every unique attribute combination x every bucket = one time series. 10 routes x 5 methods x 11 buckets = 550 series just for HTTP duration. That's fine. 500 routes x 11 buckets = not fine.
  4. Forgetting the MeterProvider: If your OTel SDK setup doesn't register a MeterProvider, all meter.create* calls silently return no-op instruments. Nothing fails, nothing records. Verify by checking the Collector's own metrics or the Prometheus targets page.
  5. Measuring inside try/catch only: Always record duration and count in a finally block so errors are measured too.
  6. Ignoring pool wait time: The time your request spends waiting for a DB connection from the pool is invisible to both your query timer and the postgres-exporter. Instrument it separately.

File Reference

FileWhen to read
references/otel-setup.mdBefore starting. OTel SDK bootstrap and Collector config.
references/stage-1-foundation.mdImplementing foundation metrics. Full code.
references/stage-2-app-intelligence.mdAdding dependency and internal behavior metrics.
references/stage-3-business-metrics.mdAdding business event tracking and SLIs.
references/stage-4-advanced.mdWebSockets, rate limiters, multi-tenancy, lifecycle.
references/infra-exporters.mdExporter setup for Postgres, Redis, RabbitMQ, MongoDB, Qdrant, Elasticsearch, Nginx, MinIO, node-exporter, cAdvisor. Docker-compose, scrape configs, community dashboard IDs.
references/grafana-dashboards.mdApp dashboard structure, alert rules, provisioning.
templates/stage-1-service-overview.jsonImport into Grafana for HTTP RED, runtime, health check panels.
templates/stage-2-dependency-health.jsonImport into Grafana for DB, Redis, external API, auth, job panels.
templates/stage-3-business-metrics.jsonImport into Grafana for signups, revenue, funnels, SLO panels.
templates/stage-4-operational.jsonImport into Grafana for WebSocket, rate limiter, multi-tenant panels.

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

38.56%
按下载量换算25

Claude

29.44%
按下载量换算19

Cursor

17.82%
按下载量换算12

Gemini CLI

10.06%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

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

来源信息

继续浏览同类 Skills