Skip to main content

Systemd Deployment

Run infrasagent as a managed systemd service on bare-metal or VM hosts.

note

There is no hosted install script. Build from source or copy the binary out of the published image, then follow the manual steps below. That is the supported path.

# Copy the binary out of the image
docker create --name sagent-tmp ghcr.io/infrasagedev/sagent:latest
docker cp sagent-tmp:/app/sagent /usr/local/bin/sagent
docker rm sagent-tmp

Manual install

1. Download the binary

ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
VERSION=$(curl -s https://api.github.com/repos/infrasage/infrasagent/releases/latest \
| grep tag_name | cut -d'"' -f4)

curl -Lo /usr/local/bin/infrasagent \
"https://github.com/infrasage/infrasagent/releases/download/${VERSION}/infrasagent-linux-${ARCH}"
chmod +x /usr/local/bin/infrasagent

2. Create the config

mkdir -p /etc/infrasagent

cat > /etc/infrasagent/agent.yaml <<'EOF'
agent:
name: "${HOSTNAME}-agent"
mode: agent

api:
listen: "0.0.0.0:8080"

sources:
otlp_in:
type: otlp
grpc:
listen: "0.0.0.0:4317"
http:
listen: "0.0.0.0:4318"

host_metrics:
type: hostmetrics
collection_interval: 15s
scrapers: [cpu, memory, disk, network, load, processes]

journal:
type: journald

processors:
batch_main:
type: batch
timeout: 5s
max_size: 10000
sources: [otlp_in, host_metrics, journal]

sinks:
infrasage:
type: otlp
endpoint: "https://api.infrasage.dev"
protocol: http
auth_header: "Bearer ${INFRASAGE_API_KEY}"
sources: [batch_main]
EOF

3. Create the systemd unit

cat > /etc/systemd/system/infrasagent.service <<'EOF'
[Unit]
Description=InfraSage Agent
After=network-online.target
Wants=network-online.target
StartLimitIntervalSec=60
StartLimitBurst=5

[Service]
Type=simple
User=infrasagent
Group=infrasagent
ExecStart=/usr/local/bin/infrasagent -config /etc/infrasagent/agent.yaml
Restart=on-failure
RestartSec=5s

EnvironmentFile=-/etc/infrasagent/env

# Security hardening
ProtectSystem=full
PrivateTmp=true
NoNewPrivileges=true
AmbientCapabilities=CAP_NET_BIND_SERVICE

# Resource limits
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
EOF

4. Create the environment file

cat > /etc/infrasagent/env <<EOF
INFRASAGE_API_KEY=<YOUR_API_KEY>
EOF
chmod 600 /etc/infrasagent/env

5. Create the service user

useradd --system --no-create-home --shell /sbin/nologin infrasagent
chown -R infrasagent:infrasagent /etc/infrasagent

6. Enable and start

systemctl daemon-reload
systemctl enable infrasagent
systemctl start infrasagent
systemctl status infrasagent

Operations

# View logs
journalctl -u infrasagent -f

# Reload config without restart
systemctl kill -s HUP infrasagent

# Check health
curl http://localhost:8080/health

# View pipeline metrics
curl http://localhost:8080/metrics | grep records_exported

Upgrading

# Download new binary
curl -Lo /usr/local/bin/infrasagent \
"https://github.com/infrasage/infrasagent/releases/download/v1.x.y/infrasagent-linux-amd64"
chmod +x /usr/local/bin/infrasagent

# Restart the service
systemctl restart infrasagent