agentleFS
jars-demojars-demo/jars-skills/skills/monitoring/SKILL.md

monitoring

Skill0 starsChanged 32 days agoMITView on GitHub

Adding application monitoring, metrics, and alerting: instruments the app with Prometheus/OpenTelemetry, exposes /health and /metrics endpoints, defines alert rules for error rate and latency p99, wires up a Grafana dashboard, and never leaks internal topology through public probes. Use when you want to add monitoring, set up Prometheus, add a health check endpoint, instrument my app, set up Grafana, add alerts, track error rate or latency, or make my service observable.

16 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use authentication, database and 5 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MicrosoftSkill

    authentication

    Wire this in whenever the app uses or connects to data — records, a database, entities, per-user data, row-level security — or when the user wants sign-in, accounts, login, or protected pages. Rayfin data is always accessed as an authenticated user, so **data implies auth**; only a static page over public data skips it. The starter ships as a no-auth "hello world" that previews with no backend, and the full Fabric auth scaffolding is already in the project — this skill wires it in: AuthProvider + bootstrapAuth in main.tsx, the route guard in App.tsx, the sign-in page, sign-out, and the env/deploy requirement. Triggers: auth, authentication, sign in, sign-in, login, log in, sign out, logout, account, user, identity, protect route, require login, gated page, data, database, records, per-user, row-level security, who is the current user, Fabric auth, Entra.

    Also in 3 projects that use this

  • mijunriSkill

    database

    数据库脚本与操作规范。脚本放在 db_scripts 目录,遵循查询优化、事务、安全等实践。

    Also in 3 projects that use this

  • klauswgSkill

    performance

    Optimize web performance for faster loading and better user experience. Use when asked to "speed up my site", "optimize performance", "reduce load time", "fix slow loading", "improve page speed", or "performance audit".

    Also in 4 projects that use this

  • mrgoonieSkill

    devops

    Deploy to Cloudflare (Workers, R2, D1), Docker, GCP (Cloud Run, GKE), Kubernetes (kubectl, Helm). Use for serverless, containers, CI/CD, GitOps, security audit.

    Also in 3 projects that use this

  • AnthropicSkill

    documentation

    Write and maintain technical documentation. Trigger with "write docs for", "document this", "create a README", "write a runbook", "onboarding guide", or when the user needs help with any form of technical writing — API docs, architecture docs, or operational runbooks.

    Also in 4 projects that use this

  • NVIDIASkill

    testing

    Run Python and Rust tests for physicsnemo-curator using uv + pytest with coverage reporting via pytest-cov, and cargo-nextest for Rust tests. Includes benchmark workflows with pytest-benchmark and criterion.

    Also in 6 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. 0 are common, 7 are distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Add application monitoring, metrics, and alerting to a service.

    line 8
  2. Very specific:

    Check whether a /health or /metrics endpoint already exists.

    line 13
  3. Very specific:

    Look for a docker-compose.yml or Kubernetes manifests — if present, Prometheus and Grafana can be added there.

    line 14
  4. Distinctive:

    Add a lightweight health check endpoint that:

    line 20
  5. Distinctive:

    Never exposes hostnames, passwords, internal IPs, or stack traces in the response body.

    line 25
  6. Very specific:

    Add a prometheus.yml scrape config or update the existing one:

    line 83
  7. Very specific:

    If using Docker Compose, add a prometheus service and mount the config:

    line 95
  8. Very specific:

    Create alerts.yml and reference it from prometheus.yml:

    line 108
  9. Very specific:

    Add a grafana service to Compose (or deploy separately):

    line 148
  10. Distinctive:

    Start the service and hit a few endpoints.

    line 184
  11. Very specific:

    Never expose /metrics publicly.

    line 193
  12. Distinctive:

    Never use the health endpoint to expose internal connection strings or secrets.

    line 194
  13. Distinctive:

    Prefer histograms over averages for latency.

    line 196
  14. Distinctive:

    If the project already has a monitoring setup, extend it rather than replacing it.

    line 199

“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

monitoring

Add application monitoring, metrics, and alerting to a service.

1. Read the service first

  1. Identify the runtime (Node.js, Python, Go, Java, etc.) and existing dependencies.
  2. Check whether a /health or /metrics endpoint already exists.
  3. Look for a docker-compose.yml or Kubernetes manifests — if present, Prometheus and Grafana can be added there.
  4. Note the HTTP framework so you wire the middleware in the right place.

2. Add a /health endpoint

Add a lightweight health check endpoint that:

  • Returns 200 OK with {"status": "ok"} when the service is healthy.
  • Returns 503 Service Unavailable when a required dependency (database, cache) is down.
  • Checks only dependencies whose failure would stop the service from serving requests.
  • Never exposes hostnames, passwords, internal IPs, or stack traces in the response body.
GET /health
200  {"status":"ok","uptime":42}
503  {"status":"degraded","checks":{"db":"unreachable"}}

3. Instrument with metrics

Pick the library that fits the stack:

RuntimeLibrary
Node.jsprom-client
Pythonprometheus-client
Goprometheus/client_golang
Javamicrometer-registry-prometheus
AnyOpenTelemetry SDK (exports to OTLP → Prometheus)

Collect the four golden signals at minimum:

  • Latency — HTTP request duration histogram, labeled by method, route, status_code.
  • Traffic — request counter, same labels.
  • Errors — counter or a ratio derived from the above (5xx / total).
  • Saturation — event-loop lag (Node), thread-pool queue depth (Java), CPU % (Go/Python).

Expose /metrics in Prometheus text format. Protect it behind an internal network rule or a bearer token — never make it public.

// Node.js example (Express + prom-client)
import client from 'prom-client';
client.collectDefaultMetrics();

const httpDuration = new client.Histogram({
  name: 'http_request_duration_seconds',
  help: 'HTTP request duration',
  labelNames: ['method', 'route', 'status_code'],
  buckets: [0.005, 0.01, 0.05, 0.1, 0.5, 1, 5],
});

app.use((req, res, next) => {
  const end = httpDuration.startTimer();
  res.on('finish', () =>
    end({ method: req.method, route: req.route?.path ?? req.path, status_code: res.statusCode })
  );
  next();
});

app.get('/metrics', async (_req, res) => {
  res.set('Content-Type', client.register.contentType);
  res.end(await client.register.metrics());
});

4. Wire up Prometheus

Add a prometheus.yml scrape config or update the existing one:

scrape_configs:
  - job_name: my-service
    scrape_interval: 15s
    static_configs:
      - targets: ['my-service:3000']
    metrics_path: /metrics
    # bearer_token_file: /etc/prometheus/token  # if endpoint is protected

If using Docker Compose, add a prometheus service and mount the config:

prometheus:
  image: prom/prometheus:v2.51.2
  volumes:
    - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
  ports:
    - "9090:9090"

5. Define alert rules

Create alerts.yml and reference it from prometheus.yml:

groups:
  - name: my-service
    rules:
      - alert: HighErrorRate
        expr: |
          rate(http_request_duration_seconds_count{status_code=~"5.."}[5m])
          / rate(http_request_duration_seconds_count[5m]) > 0.05
        for: 2m
        labels:
          severity: warning
        annotations:
          summary: "Error rate above 5 % for 2 minutes"

      - alert: SlowRequests
        expr: |
          histogram_quantile(0.99,
            rate(http_request_duration_seconds_bucket[5m])) > 1
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "p99 latency above 1 s for 5 minutes"

      - alert: ServiceDown
        expr: up{job="my-service"} == 0
        for: 1m
        labels:
          severity: critical
        annotations:
          summary: "my-service is not reachable by Prometheus"

Tune thresholds against real traffic — never copy alert rules blindly without understanding the service's normal behaviour.

6. Add a Grafana dashboard

Add a grafana service to Compose (or deploy separately):

grafana:
  image: grafana/grafana:10.4.2
  environment:
    GF_SECURITY_ADMIN_PASSWORD: "${GRAFANA_ADMIN_PASSWORD}"
  volumes:
    - grafana-data:/var/lib/grafana
  ports:
    - "3001:3000"

Provision the Prometheus datasource automatically:

# grafana/provisioning/datasources/prometheus.yml
apiVersion: 1
datasources:
  - name: Prometheus
    type: prometheus
    url: http://prometheus:9090
    isDefault: true

Recommended dashboard panels:

  • Request rate (RPS) per route
  • Error rate (%) over time
  • p50 / p95 / p99 latency
  • Active connections / saturation gauge
  • Service health (up/down indicator)

Export the dashboard JSON and commit it to grafana/dashboards/ so it is reproducible.

7. Verify

  1. Start the service and hit a few endpoints.
  2. curl http://localhost:<port>/health → 200 {"status":"ok"}.
  3. curl http://localhost:<port>/metrics → Prometheus text with http_request_duration_seconds_* lines.
  4. Open Prometheus → Status → Targets: my-service shows UP.
  5. Open Grafana → confirm the dashboard populates with real data.
  6. Trigger an error (e.g., call a nonexistent route) — verify the 5xx counter increments.

Rules

  • Never expose /metrics publicly. Protect with network policy, mTLS, or a token.
  • Never use the health endpoint to expose internal connection strings or secrets.
  • Instrument at the framework middleware level — not inside every handler.
  • Prefer histograms over averages for latency; averages hide tail-latency problems.
  • Alert on symptoms (high error rate, slow p99) not on causes (high CPU). Cause-based alerts fire too often and lose their meaning.
  • If the project already has a monitoring setup, extend it rather than replacing it.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.