Catalog
pydantic/logfire-infrastructure

pydantic

logfire-infrastructure

Monitor hosts, Docker containers, Kubernetes clusters, database/queue/cache servers, and cloud-provider metrics with Pydantic Logfire — no application code required. Use this skill whenever the user asks to "monitor my host/server/VM", "monitor my Docker containers", "monitor my Kubernetes cluster", "send infrastructure metrics to Logfire", "watch my database/Postgres/Redis/MongoDB/Kafka", "collect cloud metrics" (AWS/GCP), or mentions the OpenTelemetry Collector in the context of Logfire. This is infrastructure only — for instrumenting APPLICATION CODE (traces, logs, AI/agent spans) use the logfire-instrumentation skill instead.

v1.0LATEST
NewUpdated Oct 13, 2026

Monitor Infrastructure with Logfire

Do not use this skill for application-level traces, logs, or AI/agent spans — that's logfire-instrumentation. The two compose: a full setup often runs both.

How This Works

The OpenTelemetry Collector ships host, container, cluster, and infrastructure-service metrics to Logfire with no application code changes — Logfire is a fully compliant OTel backend and ingests standard OTLP traces, logs, and metrics from it (one narrow exception noted in the collector reference), so the Collector is the entire mechanism. This is optional and is an advanced tool: if the user only wants their app's own traces, logfire-instrumentation's language SDKs are enough on their own.

Step 1: Authenticate and Select the Exact Project

Do not open, read, or run any infrastructure config file (docker-compose.yml, a Kubernetes manifest, or similar) until whoami confirms you're authenticated to the right project — nothing about this step requires knowing what's being monitored. Auth is also the one step that can block on a human (browser sign-in), so starting it first means that wait begins on turn one, not after Step 2's detection work.

Use Authenticate and Select the Exact Project to derive the CLI target from the supplied Logfire URL and run its target-aware whoami check with a verified CLI path — for JS/TS projects without uv, use the external-prefix npm fallback instead of plain npx, which can execute a repository-local binary. Skip to Step 2 if that already reports the right project and resolved --region or --base-url target; otherwise, continue through the full authentication and project-selection sequence there, including its safe handoff for the write credential created by projects use.

Step 2: Identify What to Monitor

Detect the infrastructure actually in play, don't assume:

  • Host/VM: monitoring the machine itself (CPU, memory, disk, network, load).
  • Docker: read docker-compose.yml / Dockerfiles for running containers.
  • Kubernetes: look for manifests, a kubeconfig, or kubectl context.
  • Database/queue/cache servers: read docker-compose.yml / pyproject.toml / package.json for Postgres, MySQL, Redis, MongoDB, Kafka, RabbitMQ, Nginx, Apache, Elasticsearch, or Memcached.
  • Cloud provider: GCP or AWS metrics (Cloud Monitoring, CloudWatch, ECS), when the user names the provider or the app clearly runs there.

More than one can apply at once — a single Collector can run multiple receivers in parallel pipelines.

Step 3: Configure the Collector

Follow the collector reference for the receiver(s) identified in Step 2 — it covers the shared exporter setup, then a dedicated section per source: host metrics, Docker, Kubernetes, database/queue/cache servers, and cloud-provider metrics, each with the exact receiver name, a working config, and the caveats that actually bite (Docker socket permissions, API version pinning, host.docker.internal vs localhost, IAM permissions, ADOT vs. Contrib collector images).

Set the same service & resource metadata conventions the collector reference describes — host.name, service.name, service.instance.id — so data groups correctly across the Hosts, Kubernetes, and Metrics pages.

Before starting or restarting the Collector, validate the config file — a receiver typo or bad indentation should surface as a validation error, not a Collector that starts, logs nothing useful, and silently drops the pipeline:

otelcol-contrib validate --config=collector-config.yaml
# or, for the core (non-Contrib) distribution: otelcol validate --config=...

If neither binary is on PATH, inspect the running Collector container (for example with kubectl exec) or use the deployment-specific validation command from the image entrypoint, systemd unit, or Helm chart. docker compose config or kubectl get pod <name> -o yaml can show the command when it is explicitly configured.

Step 4: Verify

Wiring a receiver isn't done when the Collector starts cleanly — confirm the data actually reached the right page for the right host/container/cluster, not just that something arrived. Never report a metric as "arrived" without having queried for it in this same session — a plausible-sounding summary that wasn't checked is worse than saying you couldn't verify.

  1. Restart the Collector after any config change (having validated it, above).
  2. Query for the exact resource you configured, not just any data on the page. If a Logfire MCP server or API is connected in this session, query for the specific host.name / container / cluster you set in Step 3 within the last few minutes — a query that returns zero rows for that exact identifier means it didn't land, even if the page shows data from something else. Otherwise, open the specific product page — Hosts, Docker, or Kubernetes — or the Metrics explorer for database/queue/cache/cloud sources, and look for that same exact identifier.
  3. If nothing appears, check in order: the exporter endpoint/region and write token, that the receiver is in an active pipeline (not defined but never referenced under service.pipelines), and that resource attributes (host.name, service.name) are set — the reference's own Verify section has the full troubleshooting path.
  4. Fix and re-check until the specific source is visible, not just "some" data.

Close with a final report built from what you just confirmed — org/project/region from whoami, which receiver(s) are active, and the exact host/container/cluster identifier you verified — not a template. Include a direct link to the relevant view (/hosts, /docker, /kubernetes, or /metrics, based on the source) using the project's URL from whoami, so the user can see their own source arrive without having to ask where to look. A report with a placeholder in it means a step above was skipped, not finished.

References

Files2
2 files · 10.6 KB

Select a file to preview

Overall Score

87/100

Grade

A

Excellent

Grades are signals, not a certification. Always review a skill yourself before use.

Safety

86

Quality

89

Clarity

87

Completeness

85

Summary

This skill guides agents through setting up infrastructure monitoring with the OpenTelemetry Collector, which ships host, container, Kubernetes, and database/service metrics to Pydantic Logfire without requiring application code changes. It covers authentication, detection of what infrastructure exists, Collector configuration with proper validation, and verification that metrics actually arrive in the correct Logfire views.

Static Analysis Findings

1 finding

Patterns detected by deterministic static analysis before AI scoring. Hover over any finding code for detailed information and remediation guidance.

Command Injection
SEC-011Dynamic Shell Eval

Shell eval/exec of dynamic content

SKILL.mdexec`

Detected Capabilities

file read (docker-compose.yml, Dockerfile, Kubernetes manifests, config files)shell execution (validate Collector config, check Collector status, kubectl/docker commands)environment variable access (LOGFIRE_TOKEN, OTEL_RESOURCE_ATTRIBUTES, HOST_NAME)configuration file creation (collector-config.yaml)API/HTTP requests (implicit via OTLP exporter to Logfire endpoint)

Trigger Keywords

Phrases that agents use to match this skill to user intent.

monitor host metricsdocker container monitoringkubernetes cluster monitoringinfrastructure metrics logfireotel collector setupdatabase metrics watchcloud provider metrics

Risk Signals

INFO

Shell eval/exec of dynamic content (otelcol-contrib validate --config=collector-config.yaml with dynamic config)

SKILL.md, Step 3, validation command
INFO

Environment variable substitution in Collector config (${env:LOGFIRE_TOKEN}, ${env:NAME})

references/collector/host-and-infra-metrics.md, exporter section
WARNING

Docker socket access (mount /var/run/docker.sock, often as root)

references/collector/host-and-infra-metrics.md, Docker section
INFO

IAM/credential requirements for cloud providers (service accounts, CloudWatch permissions)

references/collector/host-and-infra-metrics.md, cloud section
INFO

Kubernetes API access via kubeconfig

SKILL.md, Step 2

Referenced Domains

External domains referenced in skill content, detected by static analysis.

pydantic.dev

Use Cases

  • Monitor host/VM CPU, memory, disk, and network metrics
  • Collect Docker container performance metrics
  • Monitor Kubernetes cluster state and per-pod metrics
  • Watch database/cache/queue server metrics (PostgreSQL, Redis, MongoDB, Kafka, etc.)
  • Collect cloud provider metrics from AWS CloudWatch or GCP Cloud Monitoring
  • Set up OpenTelemetry Collector infrastructure monitoring pipeline to Logfire

Quality Notes

  • Excellent scope boundaries — skill explicitly separates infrastructure monitoring from app instrumentation via logfire-instrumentation skill
  • Strong verification discipline — Step 4 emphasizes checking actual data arrival with specific resource identifiers, not just 'something arrived'
  • Comprehensive receiver reference covering 10+ infrastructure sources with working YAML configs and caveats (API version pinning, socket permissions, resource attributes)
  • Good credential handling guidance — uses ${env:NAME} substitution, refers to auth.md for token handoff, advises against hardcoding
  • Clear sequencing — authentication first (blocks on human input if needed), then detection, then config, then verify
  • Well-documented edge cases (host.docker.internal vs localhost, Summary type metrics not ingested, resource attribute requirements)
  • Actionable troubleshooting in Verify section (check exporter endpoint, receiver in active pipeline, resource attributes)
  • Direct link generation to project-specific Logfire views improves user feedback loop
Model: claude-haiku-4-5-20251001Analyzed: Oct 13, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Use pydantic/logfire-infrastructure in your dev environment

Command Palette

Search for a command to run...