DocsDiscoveryAgent-based Discovery

Agent-based Discovery

Install a lightweight agent on each host to push processes, connections, installed software, containers and certificates to AsPeekIt, request on-demand scans and follow the status of every scan.


Overview

Agent-based discovery inverts the usual model: instead of AsPeekIt connecting to your infrastructure, a lightweight agent installed on each host collects local data and pushes it to the AsPeekIt API. It fits networks AsPeekIt cannot reach directly (behind NAT, at the edge, segmented) and gives the deepest view of a host: processes, connections, installed software, containers and certificates. Agents belong to an agent zone; the zone has no connection configuration and its Run Now button shows "Agent Push", because data only arrives when the agents report.

The Agents Page

Open Agents in the Discovery section of the sidebar (/dashboard/discovery/agents, managers and admins). The page lists the agents with their status, host, version and Last Seen time, the Recent scans panel, the API keys and enrollment tokens, and the actions Scan now / Scan all (see below) and Reset certificate (admins).

Agents with status, version and mTLS certificate

What the Agent Collects

Each collection (every collection_interval_seconds, default 300) runs the collectors enabled in the features block of agent.yaml:

  • System: hostname, operating system, kernel, architecture, CPU, memory, disks (used for the disk_usage health check) and uptime
  • Processes: running processes with their command line (secrets redacted), user and resource usage
  • Network: interfaces and addresses, listening sockets and active TCP connections with the owning process. The sockets of the agent itself and of its child processes (reports, command polling, Trivy image scans) are left out, so the agent talking to AsPeekIt never appears as a dependency of the host
  • Installed software: Linux packages (dpkg, rpm, apk), Windows programs and hotfixes, language packages (PyPI, npm, Composer, RubyGems, Cargo, Go modules) and web applications (CMS such as WordPress) found on disk
  • Containers: running containers and their images (with digest)
  • Certificates: certificates found on disk, used for the ssl_expiry health check
  • Kernel and reboot state, and file integrity monitoring (FIM) events when enabled
  • Image scan (opt-in, install.sh --image-scan): the images of running containers are scanned with Trivy in client mode against the platform Trivy server (see Container Image Scanning)

Agent Authentication

Every request of an agent carries two HTTP headers: X-Agent-ID (the agent_id, unique across all zones) and X-API-Key (its API key). Keys are stored as SHA-256 hashes. A new agent normally starts with an expiring enrollment token: the installer exchanges it for a per-agent API key (POST /api/v1/agent/enroll/), saved in api_key_file. With mTLS enabled the agent also obtains a client certificate from the platform CA and renews it automatically. See Agent Enrollment & mTLS for the details.

Warning: Treat the API key as a secret. If a key is lost or compromised, revoke it from the Agents page and enroll the agent again; with mTLS, use Reset certificate so the old certificate stops being accepted.

# Headers sent by the agent with every report
curl -X POST https://idp.example.com/api/v1/agent/data/ \
  -H "X-Agent-ID: web-01" \
  -H "X-API-Key: idpk_..." \
  -H "Content-Type: application/json" \
  -d @report.json

Agent Statuses

A sweep every 5 minutes updates the status of every active agent from its Last Seen time (reports, command polls and FIM uploads all refresh it). The thresholds are platform settings, not per zone:

  • Online: the agent has been seen recently. A report brings a stale or offline agent back online.
  • Stale: an online agent not seen for more than AGENT_STALE_AFTER_MINUTES (default 15).
  • Offline: not seen for more than AGENT_OFFLINE_AFTER_MINUTES (default 60), or never seen.
  • Disabled: switched off by an administrator; the sweep never changes it.

Note: Stale and offline agents also turn the agent_liveness health check of their host degraded and critical (see Health Sources), and stalled agents appear on the Blind spots page.

On-demand Scans

Agents report on a fixed schedule (collection_interval_seconds, default 300 seconds). To verify a remediation without waiting for the next cycle, managers and admins can request an immediate scan from the Agents page. Viewers do not see these actions and the API rejects them with 403.

  • Scan now: on an active agent card, requests a full collection and report from that agent. While the request is pending the button shows "Scan requested". At most one scan can be pending per agent; clicking again does not queue a second one.
  • Scan all: in the page header, after a confirmation dialog, requests a scan from every active agent that is currently online. Offline, stale and disabled agents are skipped, and agents with a scan already pending are not requested twice. The notification reports how many agents were requested and how many were already pending.
  • Polling: the agent checks for pending commands every command_poll_seconds (default 60, override with IDP_COMMAND_POLL_SECONDS) with GET /api/v1/agent/commands/. A received scan starts a full collection immediately (never in parallel with a running one), the regular schedule restarts from that moment, and the agent confirms the command with POST /api/v1/agent/commands/ack/.
  • Each poll also updates the agent Last Seen time, so an agent that is polling stays online even between reports.
  • Expiry: a request that the agent has not picked up after 30 minutes (AGENT_COMMAND_EXPIRE_MINUTES) is marked expired; the check runs every 5 minutes, so expiry happens 30 to 35 minutes after the request. A new Scan now can then be requested.
  • Older agents that do not poll keep working as before on their schedule; scan requests sent to them simply expire.

Note: Polling only runs when the agent runs as a service (daemon mode), not with -once, -output or -dry-run.

Scan Status

Every report an agent sends is recorded as a scan, so you can tell a host that is clean from a host whose scan failed or has not been matched yet. The Recent scans panel at the top of the Agents page lists the latest scans across all agents (10 per page, most recent first) with the host, the time (hover for the exact date), the trigger, the collection outcome, the matching status and the CVE findings it produced. Expand a row to see the outcome of every collector: scope, status, duration and number of items collected.

  • Collection outcome: ok when every collector that ran succeeded (skipped collectors do not count), failed when all of them failed, partial when some failed or returned partial data, unknown for older agents that do not report per-collector coverage. A report whose processing fails on the server is recorded as failed for both collection and matching.
  • Matching status: CVE matching is not run per report but by the hourly match_cves_to_assets task. A new scan is pending until the next run starts, running while that run evaluates it, then done, or failed if the run raised an error. A run that stops early (time budget exhausted) or is skipped because another run holds the lock puts its scans back to pending: the following run finalizes them.
  • Findings: once matching is done the row shows "+N new / −M resolved", the CVE findings detected and resolved by that matching run on the agent's host, containers and applications. With reports every few minutes one run usually finalizes several scans of the same agent: only the most recent one receives the counts, the older ones show +0 / −0, so the same finding is never counted twice. Until matching is done the column shows "—".
  • Trigger: On demand when the agent received a Scan now request after its previous scan, Scheduled otherwise.
  • Refresh: the panel refreshes every 60 seconds while one of the visible scans is pending or running.
  • Retention: scans older than AGENT_SCAN_RETENTION_DAYS (default 30, 0 keeps them forever) are deleted by a daily task.
  • Agent version: each agent card shows the version the agent reports (or Unknown version). When AGENT_LATEST_VERSION is set (for example 1.6.0), agents running an older version show an Update available badge; trailing zeros are ignored, so 1.6 equals 1.6.0. Versions that cannot be parsed (such as dev builds) and an empty AGENT_LATEST_VERSION never show the badge.
  • Last Seen: besides reports and command polling, every security findings (FIM) upload also refreshes the agent Last Seen time, and a stale agent goes back online.

Note: Scan status is read-only: GET /api/v1/agent/scans/ (filters agent, environment, matching_status, collection_status, trigger) is available to every authenticated user.

Dependency Detection from Agent Data

Every report includes the active TCP connections of the host. For each outbound connection AsPeekIt looks for an asset that owns the remote IP address (any asset in the inventory, not only other agent hosts) and records a dependency from the host to that asset, typed by the remote port (for example 5432 → database, 6379 → cache, 443 → api) and marked with discovery_method agent_connection_tracking. Loopback addresses are ignored.

  • Long-lived connections are seen again on every report and keep their dependency active
  • A connection-tracked dependency not seen again for DEPENDENCY_CONNECTION_TTL_HOURS (default 24) is deactivated by the hourly expire-connection-dependencies task, so transient sessions and one-off clients leave the map; 0 or less disables the expiry
  • An expired dependency seen again in a later report becomes active again
  • Inactive dependencies not seen for 7 days are deleted by the daily purge-stale-dependencies task

Installation and Setup

The agent is a single Go binary for Linux and Windows, installed as a service by agent/deploy/install.sh (systemd) or install.ps1 (Windows service). Its configuration is a YAML file (agent.yaml) with backend_url, agent_id, the enrollment token or API key, collection_interval_seconds and the features flags. Step-by-step instructions are in Agent Installation (Linux), Agent Installation (Windows), Agent Configuration and Agent Enrollment & mTLS.

Tips and Best Practices

Follow these recommendations for agent-based discovery.

  • Deploy agents on the servers that host databases, queues and application backends: their connections give the richest dependency data
  • Use configuration management (Ansible, Puppet, GPO…) to roll out the agent at scale, with one enrollment token per batch
  • Keep agent_id stable and unique: it identifies the host across reports and zones
  • Check the Blind spots page for hosts without an agent and the Agents page for stale or offline agents
  • Combine agents with cloud, vSphere or network discovery: a VM is covered by the agent host with the same short name (Blind spots), and cross-zone deduplication can merge an agent host with the network-scan or SNMP asset of the same machine, or with its Azure VM (see /docs/assets/deduplication)