CostGraph Agent

CostGraph offers a lightweight agent that runs on your VM and collects VM Process Level observability agent, collects system metrics, computes process-level resource recommendations (CPU, memory), and exports results in Prometheus-compatible formats.

Prerequisites

  • Linux System: Ensure you have a Linux system with systemd support.
  • API Key: Obtain an API key from the CostGraph dashboard.
  • Access: Ensure you have root or sudo access to install the service.
  • Prometheus: Ensure you have a Prometheus server running.

Installation Steps

1

Download Agent

Download the CostGraph agent binary for your system architecture:
curl -Lo costgraph-agent https://costgraph-agent-bin.s3.us-east-1.amazonaws.com/v0.0.7/costgraph-agent_0.0.7_linux_amd64.tar.gz
2

Install Binary

Install the binary to the system path:
tar -xzf costgraph-agent && mv costgraph-agent /usr/local/bin/costgraph-agent
3

Create Configuration Directory

Create the configuration directory:
sudo mkdir -p /etc/costgraph-agent
4

Create Configuration File

Create the configuration file with your settings:
sudo tee /etc/costgraph-agent/conf.yaml <<'EOF'
api_key: "your-api-key-here"
prometheus:
  enabled: true
  url: "https://your-prometheus-endpoint"
  write_path: "/api/v1/write"
  timeout: 10s
  interval: 60s
  tlsInsecure: false
  labels:
    env: "production"
expected_utilisation:
  cpu: 60
  memory: 75
EOF
5

Create Systemd Service

Create the systemd service file:
sudo tee /etc/systemd/system/costgraph-agent.service <<'EOF'
[Unit]
Description=CostGraph Agent
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/costgraph-agent -conf /etc/costgraph-agent/conf.yaml
Restart=always
[Install]
WantedBy=multi-user.target
EOF
This will run the agent as the current user(modify as needed).
6

Enable and Start Service

Enable and start the CostGraph agent service:
sudo systemctl daemon-reload
sudo systemctl enable --now costgraph-agent

Configuration

Configuration File

The agent configuration is stored in /etc/costgraph-agent/conf.yaml:
prometheus:
  api_key: "your-api-key-here"
  enabled: true
  url: "https://your-prometheus-endpoint"
  write_path: "/api/v1/write"
  timeout: 10s
  interval: 60s
  tlsInsecure: false
  labels:
    env: "production"
expected_utilisation:
  cpu: 60
  memory: 75

Configuration Options

OptionDescriptionDefault
api_keyYour CostGraph API keyRequired
prometheus.enabledEnable Prometheus metrics exporttrue
prometheus.urlPrometheus server endpointRequired
prometheus.write_pathPrometheus write API path"/api/v1/write"
prometheus.timeoutRequest timeout10s
prometheus.intervalMetrics collection interval60s
prometheus.tlsInsecureSkip TLS verificationfalse
prometheus.labelsAdditional labels for metrics{}
expected_utilisation.cpuExpected CPU utilization %60
expected_utilisation.memoryExpected memory utilization %75

Verification

1

Check Service Status

Verify the service is running:
sudo systemctl status costgraph-agent
2

Check Logs

View service logs:
sudo journalctl -u costgraph-agent -f