Example Experiments
This article provides examples for creating experiments from your command line (CLI) and Azure portal parameter examples for various experiments. You can copy and paste the following commands into the CLI or Azure portal, and edit them for your specific resources.
Here's an example of where you would copy and paste the Azure portal parameter into:
To save one of the "experiment.json" examples shown below, simply type nano experiment.json into your Cloud Shell, copy and paste any of the below experiment examples, save it (ctrl+o), exit nano (ctrl+x) and run the following command:
az rest --method put --uri https://management.azure.com/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment?api-version=2024-01-01
Note
This is the generic command you would use to create any experiment from the Azure CLI
Note
Make sure your experiment has permission to operate on ALL resources within the experiment. These examples exclusively use System-assigned managed identity, but we also support User-assigned managed identity. For more information, see Experiment permissions. These experiments will NOT run without granting the experiment permission to run on the target resources.
View all available role assignments here to determine which permissions are required for your target resources.
Azure Kubernetes Service (AKS) - Network Delay
Experiment Description This experiment delays network communication by 200ms
{
"identity": {
"type": "SystemAssigned",
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_network_delay_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network latency",
"branches": [
{
"name": "AKS network latency",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"delay\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"delay\":{\"latency\":\"200ms\",\"correlation\":\"100\",\"jitter\":\"0ms\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) - Pod Failure
Experiment Description This experiment takes down all pods in the cluster for 10 minutes.
{
"identity": {
"type": "SystemAssigned",
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_pod_fail_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS pod kill",
"branches": [
{
"name": "AKS pod kill",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"pod-failure\",\"mode\":\"all\",\"duration\":\"600s\",\"selector\":{\"namespaces\":[\"autoinstrumentationdemo\"]}}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:podChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) - Memory Stress
Experiment Description This experiment stresses the memory of 4 AKS pods to 95% for 10 minutes.
{
"identity": {
"type": "SystemAssigned",
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_memory_stress_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS memory stress",
"branches": [
{
"name": "AKS memory stress",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT10M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"mode\":\"all\",\"selector\":{\"namespaces\":[\"autoinstrumentationdemo\"]},\"stressors\":{\"memory\":{\"workers\":4,\"size\":\"95%\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:stressChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) - CPU Stress
Experiment Description This experiment stresses the CPU of four pods in the AKS cluster to 95%.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_memory_stress_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS CPU stress",
"branches": [
{
"name": "AKS CPU stress",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT10M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"mode\":\"all\",\"selector\":{\"namespaces\":[\"autoinstrumentationdemo\"]},\"stressors\":{\"cpu\":{\"workers\":4,\"load\":95}}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:stressChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) - Network Emulation
Experiment Description This experiment applies a network emulation to all pods in the specified namespace, adding a latency of 100ms and a packet loss of 0.1% for 5 minutes.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_network_emulation_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network emulation",
"branches": [
{
"name": "AKS network emulation",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"netem\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"netem\":{\"latency\":\"100ms\",\"loss\":\"0.1\",\"correlation\":\"25\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) - Network Partition
Experiment Description This experiment partitions the network for all pods in the specified namespace, simulating a network split in the 'to' direction for 5 minutes.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_partition_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network partition",
"branches": [
{
"name": "AKS network partition",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"partition\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"partition\":{\"direction\":\"to\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) - Network Bandwidth Limitation
Experiment Description This experiment limits the network bandwidth for all pods in the specified namespace to 1mbps, with additional parameters for limit, buffer, peak rate, and burst for 5 minutes.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_bandwidth_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network bandwidth",
"branches": [
{
"name": "AKS network bandwidth",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"bandwidth\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"bandwidth\":{\"rate\":\"1mbps\",\"limit\":\"50mb\",\"buffer\":\"10kb\",\"peakrate\":\"1mbps\",\"minburst\":\"0\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) - Network Packet Re-order
Experiment Description This experiment reorders network packets for all pods in the specified namespace, with a gap of 5 packets and a reorder percentage of 25% for 5 minutes.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_reorder_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network reorder",
"branches": [
{
"name": "AKS network reorder",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"reorder\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"reorder\":{\"gap\":\"5\",\"reorder\":\"25\",\"correlation\":\"50\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) - Network Packet Loss
Experiment Description This experiment simulates a packet loss of 10% for all pods in the specified namespace for 5 minutes.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_loss_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network loss",
"branches": [
{
"name": "AKS network loss",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"loss\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"loss\":{\"loss\":\"10\",\"correlation\":\"25\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) - Network Packet Duplication
Experiment Description This experiment duplicates 50% of the network packets for all pods in the specified namespace for 5 minutes.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_duplicate_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network duplicate",
"branches": [
{
"name": "AKS network duplicate",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"duplicate\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"duplicate\":{\"duplicate\":\"50\",\"correlation\":\"50\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) - Network Packet Corruption
Experiment Description This experiment corrupts 50% of the network packets for all pods in the specified namespace for 5 minutes.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_corrupt_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network corrupt",
"branches": [
{
"name": "AKS network corrupt",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"corrupt\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"corrupt\":{\"corrupt\":\"50\",\"correlation\":\"50\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Load Test - Start/Stop Load Test (With Delay)
Experiment Description This experiment starts an existing Azure load test, then waits for 10 minutes using the "delay" action before stopping the load test.
{
"identity": {
"type": "SystemAssigned",
},
"tags": {},
"location": "eastus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/nikhilLoadTest/providers/microsoft.loadtestservice/loadtests/Nikhil-Demo-Load-Test/providers/Microsoft.Chaos/targets/microsoft-azureloadtest",
"type": "ChaosTarget"
}
],
"id": "66e5124c-12db-4f7e-8549-7299c5828bff"
},
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/builddemo/providers/microsoft.loadtestservice/loadtests/Nikhil-Demo-Load-Test/providers/Microsoft.Chaos/targets/microsoft-azureloadtest",
"type": "ChaosTarget"
}
],
"id": "9dc23b43-81ca-42c3-beae-3fe8ac80c30b"
}
],
"steps": [
{
"name": "Step 1 - Start Load Test",
"branches": [
{
"name": "Branch 1",
"actions": [
{
"selectorId": "66e5124c-12db-4f7e-8549-7299c5828bff",
"type": "discrete",
"parameters": [
{
"key": "testId",
"value": "ae24e6z9-d88d-4752-8552-c73e8a9adebc"
}
],
"name": "urn:csci:microsoft:azureLoadTest:start/1.0"
},
{
"type": "delay",
"duration": "PT10M",
"name": "urn:csci:microsoft:chaosStudio:TimedDelay/1.0"
}
]
}
]
},
{
"name": "Step 2 - End Load test",
"branches": [
{
"name": "Branch 1",
"actions": [
{
"selectorId": "9dc23b43-81ca-42c3-beae-3fe8ac80c30b",
"type": "discrete",
"parameters": [
{
"key": "testId",
"value": "ae24e6z9-d88d-4752-8552-c73e8a9adebc"
}
],
"name": "urn:csci:microsoft:azureLoadTest:stop/1.0"
}
]
}
]
}
]
}
}
}