Service Intercepts allow developers to route traffic from a running service in an environment directly to their workspace for debugging and testing. When a service is intercepted, all incoming traffic is redirected to the workspace instead of the original service.
Traffic flows to service in environment
Traffic flows to workspace instead
From your workspace, you activate an intercept for a specific service running in an environment (e.g., api-service)
All incoming requests to the service are automatically redirected to your workspace. The original service is bypassed completely.
Handle requests directly in your workspace with your local code changes. Set breakpoints, inspect variables, and test fixes in real-time with live traffic.
When you're done debugging, disable the intercept and traffic automatically flows back to the original service in the environment.
Prerequisite
You must first connect to an environment using kl env connect before you can intercept services. Service intercepts only work within a connected environment.
Use the kl intercept start command from within your workspace to intercept a service running in the connected environment.
Run the command without arguments to see a list of available services in the connected environment and select one interactively using fuzzy-find.
kl intercept start
This will display all services in the environment and let you select using arrow keys and search. You'll then be prompted to configure port mappings.
If you know the service name, you can intercept it directly:
kl intercept start api-server
kl intercept start backend-api
kl i s api-server # Using aliases
When you start an intercept, you need to map service ports to your workspace ports. For example, if the service runs on port 8080, you might map it to port 3000 in your workspace where your local development server is running.
Example Mapping:
8080 → Workspace port 30009090 → Workspace port 9090 (same port)View all active service intercepts in the connected environment:
kl intercept list
kl i ls # Using aliases
Output shows:
Get detailed status information about a specific service intercept:
kl intercept status api-server
kl i st api-server # Using aliases
Detailed information includes:
Stop intercepting a service and restore normal traffic routing. You can use interactive mode or specify the service name directly:
kl intercept stop # Interactive selection
kl intercept stop api-server # Stop specific service
kl i sp api-server # Using aliases
After stopping, traffic will automatically route back to the original service in the environment within ~30 seconds.
Intercept a service to debug issues using real incoming requests from other services or external clients. Set breakpoints and inspect variables with actual production-like data.
Test new API endpoints or modifications by intercepting the service and handling requests from dependent services without deploying changes to the environment.
Develop new features locally while staying integrated with other running services in the environment. Your workspace receives real requests from other services.
Profile and optimize your service by intercepting it and analyzing performance with real traffic patterns and load from the environment.
Reproduce bugs that only occur with specific service interactions or data by intercepting traffic and iterating on fixes in real-time.
Safe Testing Environment
Service intercepts let you safely test and debug with live traffic without affecting the actual service running in the environment. Stop the intercept anytime to restore normal operation.