What is an Agent?
An agent in Garnet is a lightweight monitoring component that runs on your infrastructure to collect security events and enforce network policies. Agents are the eyes and ears of your security monitoring system, detecting suspicious behavior and network anomalies in real-time.Agent Types
Garnet supports three types of agents, each designed for specific deployment contexts:GitHub Agent
Monitors GitHub Actions workflows and repositories.- Monitor CI/CD pipeline security
- Detect suspicious network activity in build processes
- Track workflow execution patterns
Kubernetes Agent
Monitors Kubernetes clusters, nodes, and workloads.- Cluster-wide security monitoring
- Node-level network policy enforcement
- Container runtime security
Vanilla Agent
Generic agent for standard server environments.- Traditional server monitoring
- Virtual machine security
- Custom deployment scenarios
Agent Structure
Every agent contains core system information and context-specific details:Core Fields
System Information
System Information
- OS: Operating system (e.g., “linux”, “darwin”)
- Arch: CPU architecture (e.g., “amd64”, “arm64”)
- Hostname: Machine hostname
- Version: Agent software version
- IP: Agent IP address (must be valid IPv4 or IPv6)
- MachineID: Unique machine identifier
Context Information
Context Information
Each agent type has specific context requirements:Kubernetes Context:The cluster and node names must follow Kubernetes naming conventions.
Labels
Labels
Labels are key-value pairs for organizing and filtering agents:Example usage:Labels can be used in queries:
Creating an Agent
To register a new agent with Garnet:The
CreateAgent response includes an AgentToken that must be used for all subsequent API calls from that agent. Store this token securely.Listing Agents
Query agents with powerful filtering options:Available Filters
System Filters
- Active: Filter by active status
- OS: Operating system
- Arch: CPU architecture
- Hostname: Machine hostname
- Version: Agent version
- IP: IP address
- MachineID: Machine identifier
Metadata Filters
- Kinds: Agent types (can specify multiple)
- Labels: Key-value label filters
- TimeStart: Filter by creation time start
- TimeEnd: Filter by creation time end
Agent Lifecycle
Registration
- Agent starts and collects system information
- Sends registration request with context details
- Receives agent ID and authentication token
- Receives initial network policy configuration
Heartbeat
Agents must send periodic heartbeats to maintain theirActive status:
The heartbeat updates the agent’s
LastSeen timestamp. Agents that haven’t sent a heartbeat recently are marked as inactive.Updating Agent Information
Agent metadata can be updated as needed:Deregistration
Remove an agent from monitoring:Agent Counts and Statistics
Retrieve aggregate statistics about your agents:AgentsCounts response includes:
- Total: Total number of agents
- Active: Currently active agents
- Inactive: Inactive agents
- CreatedSince: Agents created since specified time (optional)
- At: Timestamp of the count
Network Policy Integration
Agents automatically receive and enforce network policies based on their context. The merged network policy combines:- System-wide global policies
- Project-level global policies
- Context-specific policies (repo, workflow, cluster, or node)
Best Practices
Security
Security
- Store agent tokens securely (never in code or logs)
- Rotate agent tokens periodically
- Use separate agents for different environments
- Apply appropriate labels for access control
Labeling Strategy
Labeling Strategy
- Use consistent label naming conventions
- Include environment (
env), team, and region labels - Add deployment-specific labels (cluster, namespace, etc.)
- Use labels for organizing and filtering in queries
Monitoring
Monitoring
- Monitor agent heartbeat status
- Track agent version distribution
- Alert on inactive agents
- Review agent counts regularly
Maintenance
Maintenance
- Keep agent software up-to-date
- Remove decommissioned agents promptly
- Validate context information accuracy
- Review and update labels as infrastructure changes
Error Handling
Common Errors
ErrAgentNotFound (types/agent.go:34)
types/agent.go:31)
types/agent.go:232)
Related Concepts
- Events - Security events detected by agents
- Issues - Aggregated security concerns from events
- Network Policies - Rules enforced by agents
