Agent Troubleshooting
Diagnose common AsPeekIt agent issues: statuses, authentication and enrollment errors, certificates, connectivity and logs.
Agent Statuses
Every agent card on the Agents page (Discovery section) shows one of four statuses. A periodic backend task derives them from last_seen, which is refreshed by every report and by the lightweight command poll (every command_poll_seconds, default 60).
- online: the agent reported or polled recently.
- stale: no contact for more than AGENT_STALE_AFTER_MINUTES (default 15, about three missed cycles at the default 300-second interval).
- offline: no contact for more than AGENT_OFFLINE_AFTER_MINUTES (default 60), or never seen.
- disabled: disabled from its card (power button). A disabled agent is refused with 401 "Agent is disabled" and its status is never changed by the task; Enable sets it back to offline until it reports.
Note: The thresholds are backend settings that apply to every agent; there is no per-agent threshold. Stale and offline transitions are also recorded as agent liveness in the health history of the host.

Checking Agent Logs
The log is the first place to look. Every line carries a prefix such as [main], [sender], [mtls] or [fim].
- "[main] Data sent successfully": the report was accepted.
- "[main] Send error: ...": the report failed after the retries (retry_count, default 3, with retry_delay_seconds between them); the HTTP status and the backend message follow.
- Set log_level: debug (or IDP_LOG_LEVEL=debug) and restart for more detail.
- Run one collection without sending to check the configuration: idp-agent -config /etc/idp-agent/agent.yaml -once -dry-run (or -output report.json to see the payload).
# Linux (systemd journal)
sudo journalctl -u idp-agent -f
sudo journalctl -u idp-agent --since "10 min ago" --no-pager
# macOS
sudo tail -f /var/log/idp-agent/agent.log
# Windows (PowerShell)
Get-Content C:\ProgramData\idp-agent\agent.log -Tail 50 -WaitAuthentication Errors (401 / 403)
The backend message in the log tells the cause:
- "Invalid API key": the key does not exist. Check for truncation or whitespace; a lost key cannot be recovered, create a new one.
- "API key expired or inactive": the key was revoked or has expired.
- "Auto-registration with environment keys is disabled; enroll the agent with an enrollment token": a zone key cannot register a new agent_id while AGENT_ALLOW_ENV_KEY_ENROLLMENT=false. Use an enrollment token.
- "This agent has its own API key; environment-wide keys cannot authenticate it": the agent received a dedicated key (from enrollment, from its first certificate, or created on its card). On the host the key is in api_key_file or in mtls.dir/api-key; put it back or create a new dedicated key.
- "API key does not match agent": a dedicated key used with a different agent_id or zone.
- 403 "agent_id is already registered in a different discovery zone": use a key of that zone or a different agent_id.
- 403 "Discovery zone is inactive": the zone of the key was deactivated.
- "Agent is disabled": enable it from its card.
- "A verified client certificate is required", "No client certificate is registered for this agent", "Client certificate does not match the agent": AGENT_REQUIRE_MTLS is on and the agent did not present the certificate bound to it. See below.
Certificate Problems
With the automatic mTLS the agent logs every certificate step with the [mtls] prefix:
- "Certificate request refused (403)": the agent already has a bound certificate and did not present it (lost, or expired). An admin resets the certificate from the agent card (Reset), then the agent gets a new one at its next check (at start and every 6 hours; restart it to retry at once).
- "Backend has no certificate endpoint (404); running without mTLS": the backend is older than the feature; the agent keeps working without a certificate.
- "mtls_url ... is not https, using backend_url": AGENT_MTLS_URL must be an https:// URL.
- 503 "The platform CA is unavailable; retry later." in the log: the backend cannot decrypt the CA private key (AGENT_CA_ENCRYPTION_KEY or SECRET_KEY changed).
- TLS handshake failures towards the mTLS host: the reverse proxy does not trust the platform CA; regenerate its options with manage.py agent_ca --traefik-options.
Note: See Automatic Agent mTLS (/docs/agent/mtls) for the full flow.
Connectivity
The agent only opens outbound connections: to backend_url, to the mTLS endpoint returned by the backend (when configured), to the local Docker daemon and, with the image scan, to the platform trivy-server. It listens on no port.
- backend_url must be the platform URL without /api (the agent appends /api/v1/agent/...).
- Proxies: the agent honours HTTPS_PROXY / HTTP_PROXY / NO_PROXY of its environment (set them in a systemd drop-in on Linux).
- Private CA or TLS inspection: set tls_ca_file (or IDP_TLS_CA_FILE) to the CA bundle. tls_skip_verify disables verification and logs a warning: never use it in production.
- 413 on reports: the body exceeds AGENT_MAX_DECOMPRESSED_BYTES (default 32 MiB) on the backend, or a reverse proxy limit.
# Reachability and key check from the host
curl -s https://idp.example.com/api/v1/agent/health/ \
-H "X-Agent-ID: web-01" -H "X-API-Key: idpk_..."
# {"status": "ok", "service": "idp-backend", "agent_id": "web-01", "authenticated": true}Agent Shows as Stale or Offline
When the service is running but the card is stale or offline:
- Look for "Send error" lines and for [sender] retry messages in the log.
- Check the agent clock (NTP) and DNS resolution of the platform host.
- Use "Scan now" on the card: the agent picks the command up within command_poll_seconds and reports immediately; "Scan requested" stays on the card until it does.
- A collection that takes very long (large hosts, slow rpm queries) delays the report: check "[main] Collection complete in ..." in the log.
Restarting the Agent
Restart the service after changing the configuration:
# Linux
sudo systemctl restart idp-agent
# macOS
sudo launchctl kickstart -k system/com.idp.agent
# Windows (PowerShell)
Restart-Service idp-agent