Logfire Infrastructure
PydanticOfficialPublished by Pydantic
- Skill
- Tool integration
- Cloud and DevOps
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured workflow for monitoring infrastructure components—including hosts, Docker containers, Kubernetes clusters, and various database or cache servers—by configuring the OpenTelemetry Collector to export metrics to Pydantic Logfire. It focuses exclusively on infrastructure-level telemetry, requiring no changes to application code. The process involves authenticating with the correct project, identifying the specific infrastructure to monitor, configuring the appropriate OTel Collector receivers, and verifying that the data is correctly ingested and visible within the Logfire dashboard.
What it does
- Authenticates the agent with the target Logfire project.
- Identifies infrastructure components like hosts, Docker containers, or Kubernetes clusters.
- Provides configuration patterns for the OpenTelemetry Collector to collect infrastructure metrics.
- Ensures proper resource metadata is set for accurate grouping in Logfire.
- Validates Collector configurations before deployment to prevent pipeline failures.
- Verifies that metrics are successfully arriving in the Logfire dashboard for the specific resource.
When to use it
- When you need to monitor host, VM, or server performance metrics.
- When you need visibility into Docker container or Kubernetes cluster health.
- When you need to collect metrics from databases, queues, or cache servers like Postgres, Redis, or Kafka.
- When you need to ingest cloud-provider metrics from AWS or GCP.
- When you are using the OpenTelemetry Collector to centralize infrastructure telemetry.
Advantages
- Requires no modifications to existing application code.
- Provides a unified view of infrastructure health alongside application telemetry.
- Uses standard OpenTelemetry protocols for broad compatibility.
- Includes a verification step to ensure data is actually reaching the dashboard.
Usage examples
- “Monitor my Postgres database and send the metrics to Logfire.”
- The agent will identify the database, configure the appropriate OTel receiver, set up the OTLP exporter with your Logfire token, and verify the metrics appear in the Logfire Metrics explorer.
- “How do I set up monitoring for my Kubernetes cluster in Logfire?”
- The agent will guide you through authenticating to your project, configuring the OTel Collector with Kubernetes receivers, and confirming that cluster metrics are visible on the Kubernetes page.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/pydantic/logfire-infrastructure/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip logfire-infrastructure.zip -d .agents/skills
Documentation by Pydantic
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, orkubectlcontext.Database/queue/cache servers: read
docker-compose.yml/pyproject.toml/package.jsonfor 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.
Restart the Collector after any config change (having validated it, above).
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.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.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
Host, Docker, Kubernetes, database/queue/cache, and cloud-provider metrics via the OTel Collector — receiver configs, IAM/permission caveats, and its own verify loop.
Files
- ATTRIBUTION.mdAdded by AutoGineer861 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md7.1 KiB
- references/collector/host-and-infra-metrics.md9.5 KiB
references/collector/host-and-infra-metrics.md
Host & Infrastructure Metrics (OpenTelemetry Collector)
A large share of useful telemetry — host CPU/memory/disk, Kubernetes cluster
state, and metrics from database/queue/cache servers — comes from
infrastructure, not application code. The OpenTelemetry Collector collects
these and ships them to Logfire over OTLP, with no changes to your app. Logfire
is a fully compliant OpenTelemetry backend and ingests OTLP traces, logs, and
metrics from the Collector — with one metric-type exception: the legacy OTLP
Summary type (superseded by histograms in the OTel spec) is not ingested. If
a receiver's metrics don't show up and its docs say it emits Summary points,
that's why — look for a histogram- or gauge-producing alternative.
Reach for this path whenever the user wants "as much useful data as would be useful," is monitoring a host/VM/cluster, or wants a database/queue/cache server watched. App instrumentation alone never produces this data.
The Collector is optional and is an advanced tool. If the user only wants their app's own traces, the language SDKs (covered in the main skill) are enough.
Send Collector data to Logfire
Point the Collector's OTLP exporter at the exact Logfire origin selected during authentication. The token authenticates the same way as any OTLP client:
exporters:
otlphttp/logfire:
endpoint: '<selected-logfire-origin>'
headers:
Authorization: '${env:LOGFIRE_TOKEN}'Use the project-scoped write token created by the authentication flow's projects use
command. Follow its credential handoff instructions to place only the token value into a gitignored env file, Kubernetes Secret, or the deployment's existing secret manager without printing it. Set that credential as LOGFIRE_TOKEN wherever the Collector runs -- ${env:NAME} is the Collector's own config-substitution syntax, resolved at startup, never hardcoded into the Collector config. Add the exporter to your metrics (and/or logs/traces) pipelines.
Full setup, topologies, and processors: https://pydantic.dev/docs/logfire/guides/otel-collector/otel-collector-overview/
Host metrics → Hosts page
Use the hostmetrics receiver. Each host that ships these metrics appears on the
Hosts page with CPU, memory, load, disk, and network charts.
receivers:
hostmetrics:
collection_interval: 60s
scrapers:
cpu:
metrics:
system.cpu.utilization:
enabled: true
memory:
metrics:
system.memory.utilization:
enabled: true
load:
disk:
filesystem:
include_virtual_filesystems: false
metrics:
system.filesystem.utilization:
enabled: true
network:
processes:
processors:
resourcedetection:
detectors: [env, system]
system:
hostname_sources: [os]
service:
pipelines:
metrics:
receivers: [hostmetrics]
processors: [resourcedetection]
exporters: [otlphttp/logfire]Set host.name (and other host resource attributes) so hosts are identified
correctly. Guide:
https://pydantic.dev/docs/logfire/guides/otel-collector/host-monitoring/
App-only alternative: if you can't run a Collector but the app process should
report its host's metrics, call logfire.instrument_system_metrics() (Python,
needs the system-metrics extra). The Collector hostmetrics receiver is
preferred for true host coverage because it runs per host, independent of any app.
Docker containers → Docker page
Use the docker_stats receiver — Contrib-only, not in the core Collector image (otelcol-contrib, not otelcol) — pointed at the Docker socket, and added to an active metrics pipeline (a receiver defined but never referenced under service.pipelines collects nothing):
receivers:
docker_stats:
endpoint: unix:///var/run/docker.sock
api_version: "1.44" # quoted string -- a bare float like 1.44 is rejected
service:
pipelines:
metrics:
receivers: [docker_stats]
exporters: [otlphttp/logfire]Modern builds of the receiver auto-negotiate the API version; older builds
default to 1.25, too old for current Docker/OrbStack, so pin a recent version
to avoid API-version errors. The collector needs permission to read the socket:
mount /var/run/docker.sock into the container and run it as a user that can
read it (often user: "0:0" in Docker Compose) -- call out that Docker socket
access, especially as root, is effectively root-level control of the host
before doing this.
Group containers under the real host by passing the host name in from the
shell and adding a resourcedetection processor with the env detector to
the pipeline — setting OTEL_RESOURCE_ATTRIBUTES alone does nothing; nothing
reads that environment variable into the actual resource attributes without
it:
# docker-compose.yml
services:
otel-collector:
environment:
OTEL_RESOURCE_ATTRIBUTES: host.name=${HOST_NAME}processors:
resourcedetection:
detectors: [env]
service:
pipelines:
metrics:
receivers: [docker_stats]
processors: [resourcedetection]
exporters: [otlphttp/logfire]HOST_NAME=$(hostname) docker compose upA literal $(hostname) inside a Compose value does not expand -- it has to
come in from the shell.
If the collector runs in a container and the Logfire base URL is a
localhost/LAN address (self-hosted or local dev), reach the host via
host.docker.internal (add extra_hosts: ["host.docker.internal:host-gateway"]
in Compose), not localhost -- inside the container, localhost is the
collector itself. A public cloud Logfire URL needs no change.
Guide: https://pydantic.dev/docs/logfire/observe/docker/
Kubernetes → Kubernetes page
Collect cluster state, per-node/per-pod metrics, and the k8s.* resource
attributes (k8s.cluster.name, k8s.namespace.name, k8s.pod.name,
k8s.deployment.name, ...) that drive the Kubernetes page. The recommended
pattern is two Collectors — a Deployment for cluster-level state
(k8sclusterreceiver) and a DaemonSet for per-node/pod metrics
(kubeletstatsreceiver) — plus the k8sattributesprocessor to stamp the same
k8s.* attributes onto traces from your applications.
Guide: https://pydantic.dev/docs/logfire/guides/otel-collector/kubernetes-monitoring/
Database / queue / cache servers → Metrics & Dashboards
The Collector ships receivers for common infrastructure services. Add the relevant receiver and its metrics become queryable in the Metrics explorer and available for dashboard panels and alerts:
| Service | Receiver | Example metric prefix |
|---|---|---|
| PostgreSQL | postgresql | postgresql.* |
| MySQL | mysql | mysql.* |
| Redis | redis | redis.* |
| MongoDB | mongodb | mongodb.* |
| Kafka | kafkametrics | kafka.* |
| RabbitMQ | rabbitmq | rabbitmq.* |
| Nginx | nginx | nginx.* |
| Apache HTTP | apache | apache.* |
| Elasticsearch | elasticsearch | elasticsearch.* |
| Memcached | memcached | memcached.* |
These receivers live in the OpenTelemetry Collector Contrib distribution. Match
the receiver to the services the project actually depends on (read
pyproject.toml / package.json / docker-compose.yml to detect them), and set
service.instance.id on each so per-instance metrics stay distinct.
Cloud provider metrics → Metrics & Dashboards
GCP: the
googlecloudmonitoringreceiver pulls Cloud Monitoring (formerly Stackdriver) metrics — needs a service account with monitoring read permissions and an explicitmetrics_listof metric names to collect.AWS: the
awsecscontainermetricsreceiver reads ECS task-metadata-endpoint metrics directly, no extra IAM beyond the task role. For broader CloudWatch metrics (RDS, ALB, and other services not on the ECS metadata endpoint), use theawscloudwatchreceiver available in the stock Contrib distribution. Configuremetrics.queries[].statsormetrics.discovery.statsexplicitly (for example,[Average]) so the receiver emits Gauge points; omitted stats produce Summary points. Logfire drops those points at ingest and emits alogfire ingest error; payloads that mix supported and Summary points may be partially ingested. It needscloudwatch:GetMetricData/GetMetricStatistics/ListMetricsIAM permissions.
Full setup, IAM policies, and example ECS/Cloud Run deployments: https://pydantic.dev/docs/logfire/guides/cloud-metrics/
Service & resource metadata
Whatever the source, set resource attributes so data is grouped correctly across
the UI. From the Collector, use the resource/resourcedetection processors. The
OTEL_RESOURCE_ATTRIBUTES variable is consumed only when the resourcedetection
processor includes its env detector:
service.name,service.version,deployment.environment.nameservice.instance.id— per-replica identity (standard dashboards filter on it)host.name— required for the Hosts page to identify a host
Verify
After wiring a receiver + the Logfire exporter, restart the Collector and check
that the corresponding page (Hosts / Kubernetes) or the Metrics explorer shows
the new data within a minute or two. If nothing appears: confirm the exporter
endpoint/region and write token, that the receiver is in an active pipeline, and
that resource attributes (host.name, service.name) are set.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server, Needs Node.js
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Pydantic
- Publisher
- Pydantic (Official)
- Source
- pydantic/skills · skills/logfire-infrastructure · commit 98f591c
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- pydantic/skills
AutoGineer is not affiliated with or endorsed by Pydantic or Pydantic.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download logfire-infrastructure.zip