Menu
Choose a product
Viewing: v0.52.x
Find another version
Scroll for more
Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Documentation
Grafana k6
Testing guides
Injecting faults with xk6-disruptor
xk6-disruptor first steps
Open source
xk6-disruptor first steps
xk6-disruptor is an extension that adds fault injection capabilities to k6.
It provides a Javascript API to inject faults such as errors and delays into HTTP and gRPC requests served by selected Kubernetes Pods or Services.
JavaScript
import { ServiceDisruptor } from 'k6/x/disruptor';
export default function () {
// Create a new disruptor that targets a service
const disruptor = new ServiceDisruptor('app-service', 'app-namespace');
// Disrupt the targets by injecting delays and faults into HTTP request for 30 seconds
const fault = {
averageDelay: '500ms',
errorRate: 0.1,
errorCode: 500,
};
disruptor.injectHTTPFaults(fault, '30s');
}Next steps
Explore the fault injection API
Visit the interactive demo environment.
Learn the basics of using the disruptor in your test project:
Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video

Performance testing and observability in Grafana Cloud
Optimize user experiences with Grafana Cloud. Learn real-time insights, performance testing with k6, and continuous validation with Synthetic Monitoring.
Events

User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.