Skip to main content
The CostGraph Agent is a daemon that runs on your virtual machines and continuously reports resource usage to CostGraph. It collects:
  • Host metrics — CPU, memory, disk, and network utilization for the machine.
  • Container metrics and inventory — when a Docker or containerd runtime is present.
These stream to CostGraph, where they power:
  • VM inventory and cost — every host and its attached disks, with compute and storage cost attributed per VM, plus live utilization and status.
  • Rightsizing recommendations — resize suggestions from observed CPU and memory usage, including cheaper instance types across cloud providers.
  • Idle detection — VMs with consistently low CPU, memory, network, and disk activity are flagged to terminate.
  • Container and process insight — per-container metrics and the top processes driving usage on each host.
  • Cost anomalies — unusual spend or utilization changes surfaced automatically.

Prerequisites

  • A Linux host e.g Debian, Ubuntu, RHEL, Amazon Linux, Alpine etc (amd64 or arm64).
  • An API key from the CostGraph platform.

Installation

Pipe the installer to sh with your API key on the sh side of the pipe:
curl -sSL https://setup.costgraph.ai/install.sh | COSTGRAPH_API_KEY="bl_..." sh
Or download, inspect, then run:
curl -sSL https://setup.costgraph.ai/install.sh -o install.sh
chmod +x install.sh
COSTGRAPH_API_KEY="bl_..." ./install.sh
The installer detects your init system and registers the agent as a systemd or OpenRC service that starts on boot. It supports Debian, Ubuntu, RHEL, Amazon Linux, and Alpine, and installs the latest stable release by default. Your API key is stored in /etc/default/costgraph-agent (systemd) or /etc/conf.d/costgraph-agent (OpenRC).Pin a specific release with COSTGRAPH_AGENT_VERSION — see the changelog for available versions.Manage the service the usual way:
sudo systemctl status costgraph-agent
sudo journalctl -u costgraph-agent -f
macOS support via Homebrew is coming soon. For now, install on a Linux host using one of the methods above.

Verify

Once it’s running, your host appears in the CostGraph platform. CostGraph agent host view in the platform

Configuration

The agent is configured entirely through command-line flags and the COSTGRAPH_API_KEY environment variable.
# API key via flag
costgraph-agent --api-key <your-api-key>

# or via environment variable
export COSTGRAPH_API_KEY=<your-api-key>
costgraph-agent
When you install with the script or Ansible, your API key is written to /etc/default/costgraph-agent and loaded by the service automatically.
--api-key
string
required
API key used to authenticate with CostGraph. Can also be set with the COSTGRAPH_API_KEY environment variable, which takes precedence over the flag.
--metrics-port
number
default:"9101"
Port the agent exposes its own Prometheus metrics on, at /metrics.
--state-dir
string
default:"/var/lib/costgraph-agent"
Directory for durable agent state, including the on-disk remote-write queue.
--remote-write-max-in-memory-blocks
number
default:"128"
Maximum number of remote-write blocks buffered in memory before they spill to the on-disk queue.
--remote-write-max-pending-bytes
number
default:"5368709120"
Maximum size of the on-disk remote-write queue in bytes (5 GiB) before backpressure is applied.
--log-level
string
default:"info"
Log verbosity. One of debug, info, warn, or error.
--version
boolean
Prints the agent version and exits.

Changing flags for the managed service

The install script runs costgraph-agent as a systemd (or OpenRC) service with no extra flags. To change a flag for the managed service on a systemd host, add a drop-in:
sudo systemctl edit costgraph-agent
[Service]
ExecStart=
ExecStart=/usr/local/bin/costgraph-agent --state-dir /opt/var/lib/costgraph-agent
sudo systemctl restart costgraph-agent
The first empty ExecStart= clears the original command so your override fully replaces it.