Enabling the API
The GraphQL API must be enabled in your Vector configuration:Configuration Options
Enable or disable the GraphQL API server.
The IP address and port to bind the API server to.
Enable the GraphQL Playground web interface for interactive API exploration.
Accessing the API
GraphQL Playground
Whenplayground is enabled, navigate to the API address in your browser:
- Interactive query editor
- Auto-completion
- Schema documentation
- Query history
GraphQL Endpoint
The GraphQL endpoint is available at:Example Query (curl)
API Schema
Vector’s GraphQL API exposes three main operation types:Queries
Queries retrieve current state and information:health- Check if the API is reachablecomponents- List all configured componentshostMetrics- Get host system metrics (CPU, memory, disk, network)
Mutations
Currently, Vector’s API is read-only. Mutations are not supported.
Subscriptions
Subscriptions provide real-time streaming data:heartbeat- Periodic timestamp updatesuptime- Vector uptime metricscomponentAdded- Component addition eventscomponentRemoved- Component removal eventsreceivedEventsTotal- Total received events metricssentEventsTotal- Total sent events metricsoutputEventsThroughput- Real-time throughput metrics
Core Queries
Health Check
Check if Vector’s API is responding:List Components
Retrieve all configured sources, transforms, and sinks:Host Metrics
Query host system metrics:Host metrics require the
sources-host_metrics feature to be enabled at compile time.Subscriptions
Heartbeat
Receive periodic heartbeat updates:interval- Milliseconds between updates (10-60000, default: 1000)
Uptime
Monitor Vector’s uptime:Component Metrics
Stream real-time component throughput:Output Throughput
Monitor output event throughput:Filtering and Sorting
Filter Components
Filter components by ID or type:Sort Components
Sort by component key or kind:COMPONENT_KEY- Sort by component IDCOMPONENT_KIND- Sort by type (source, transform, sink)
ASC- AscendingDESC- Descending
Pagination
Use Relay-style cursor pagination:first- Number of items to returnafter- Cursor to start fromlast- Number of items from the endbefore- Cursor to end at
Using with Tools
Vector Top
Thevector top command uses the GraphQL API to display a real-time dashboard:
Vector Tap
Thevector tap command uses the API to sample component outputs:
Client Libraries
Use any GraphQL client library: JavaScript/TypeScript:Security Considerations
SSH Tunnel Example
Troubleshooting
API Not Responding
Check if the API is enabled:- Verify
api.enabled: truein configuration - Check the
api.addressbinding - Ensure Vector is running:
systemctl status vector - Check logs:
journalctl -u vector -f
Connection Timeout
If the API times out:- Check firewall rules:
sudo iptables -L - Verify the port is listening:
netstat -tlnp | grep 8686 - Check for network connectivity
Playground Not Loading
If the playground doesn’t load:- Verify
api.playground: true - Try the endpoint directly:
/graphqlinstead of/playground - Check browser console for errors
- Clear browser cache
Next Steps
GraphQL Reference
Detailed schema reference for all queries and subscriptions
CLI Top Command
Monitor Vector with the built-in dashboard
Monitoring
Set up comprehensive monitoring for Vector