> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/resilience-testing/chaos-engineering/chaos-experiments/create-experiments.md).

# Create Experiments

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* [What is a chaos experiment?](/resilience-testing/chaos-engineering/new-to-chaos-engineering/key-concepts.md)
* [What are chaos faults?](/resilience-testing/chaos-engineering/chaos-experiments/index.md)
* [What are resilience probes?](/resilience-testing/chaos-engineering/use-chaos-engineering/probes/index.md)

### Steps to create an experiment <a href="#steps-to-create-an-experiment" id="steps-to-create-an-experiment"></a>

#### Create Environment <a href="#create-environment" id="create-environment"></a>

Before you create an experiment, you need an environment where you have to [enable a chaos infrastructure](/resilience-testing/chaos-engineering/use-chaos-engineering/infrastructure/infrastructures.md). Therefore, create an environment.

{% hint style="info" %}
**NOTE**

To edit or delete the environment, select the **`⋮`** icon against the name of the environment.

<img src="/files/BUEEeOAucy4vQ4pbO5gh" alt="" data-size="original">
{% endhint %}

#### Create an Infrastructure <a href="#create-an-infrastructure" id="create-an-infrastructure"></a>

After creating your environment, create an infrastructure within it. The chaos experiment is executed within this infrastructure.

### Create Chaos Experiment <a href="#create-chaos-experiment" id="create-chaos-experiment"></a>

You can add one or more chaos faults to a chaos experiment and execute it.

Different ways of building a chaos experiment are described below.

* [**Blank Canvas**](#using-blank-canvas) - Lets you build the experiment from scratch, adding the specific faults you want.
* [**Templates from ChaosHubs**](#using-templates-from-chaoshubs) - Lets you preview and select and experiment from pre-curated experiment templates available in [ChaosHubs](/resilience-testing/chaos-engineering/use-chaos-engineering/chaoshub.md).
* [**Upload YAML**](#upload-yaml) - Lets you upload an experiment manifest YAML file.

These options are explained below.

**Using Blank Canvas**

1. On the **Experiment Builder** tab, click **Add** to add a fault to the experiment.

   ![Experiment Builder tab with Add button](/files/UnUvYHmgkTgfOuVd8UMk)
2. Select the fault you want to add to the experiment.

   ![Select Faults](/files/ASUBCCM0Ed8AEGzyJt6g)
3. For each fault, tune the properties. The properties will vary depending on the faults.
   * To tune each fault:
     * **Specify the target application (only for pod-level Kubernetes faults):** This allows the corresponding pods of the application to be targeted.
       * **App Namespace**: The namespace where your application/services is housed. This is where chaos is injected.
       * **App Kind** or **App Label**: Choose between the type of application or the label associated with it.
         * **App Kind**: This describes the type of your target application. Choose between "deployment", "statefulset", "daemonset", "deploymentconfig" or "rollout".
         * **App Label**: Label associated with the target service. For example, "nginx" app can have the label as "app=nginx".

           ![target app](/files/1UZeRuu53nPir3BYFiDL)
     * **Tune fault parameters:** Each fault has a set of common parameters, like **chaos duration** and **ramp time**, and unique parameters that you can customize as needed.
     * **Tune Fault Weightage**: Set the weight for the fault, which determines its importance relative to other faults in the experiment. This weight is used to calculate the experiment's resilience score.

       ![Tune Fault](/files/JJkhro0dcIHBehHPDDon)
     * **Add chaos probes:** On the **Probes** tab, add [resilience probes](/resilience-testing/chaos-engineering/use-chaos-engineering/probes/use-probe.md) to automate the chaos hypothesis checks for a fault during the experiment execution. Probes are declarative checks that validate specific criteria, that help determine if an experiment **passed**.

       ![resilience probe](/files/XFYK8ryV1Gowxgmbt9cs)
     * You can configure [Advanced Settings](/resilience-testing/chaos-engineering/chaos-experiments/advance-configuration-options.md) if required.

**Using Templates from ChaosHubs**

1. Select an experiment template from a [ChaosHub](/resilience-testing/chaos-engineering/use-chaos-engineering/chaoshub.md).
   * Choose **Experiment Type** to see the available ChaosHubs.
   * Select a template to preview the faults included.

     ![Fault Templates](/files/AlOmwIl10XhLOAVpsNbC)

{% hint style="info" %}
**NOTE**

You can edit the template to add more faults or update the existing faults.
{% endhint %}

**Upload YAML**

1. Upload an experiment manifest YAML file to create the experiment.

{% hint style="info" %}
**NOTE**

You can edit the experiment to update the existing faults or add more.
{% endhint %}

After constructing the chaos experiment using one of the three options, save the experiment.

![Save experiment options](/files/FeKdxSh1QNZ2ketkg2bC)

* Click **Save** to save the experiment to the Chaos Experiments page. You can add it to a [ChaosHub](/resilience-testing/3.0/chaos-testing/chaoshub.md) later.
* Select **Add Experiment to ChaosHub** to save this experiment as a template in a selected [ChaosHub](/resilience-testing/3.0/chaos-testing/chaoshub.md).

### Create Experiment as a Pipeline <a href="#create-experiment-as-a-pipeline" id="create-experiment-as-a-pipeline"></a>

1. Go to **Chaos** module and select **Pipelines** and click **+Create a Pipeline**.

   ![](/files/4DjEA6kwzWkUVr48rZzW)
2. Provide a name, and click **Start**.

   ![](/files/n6g3I95FcuJNNOxuP0zj)
3. Click the **+** (the stage type), and select **Custom Stage**.

   ![](/files/SNDYHRaSEvZSOVQyw1GZ)
4. Provide a name for the stage, and click **Set Up Stage**.

   ![](/files/uMopEBWGtv1MUhHV9FBu)
5. Click **Add Step** and choose the **Add Step** option.

   ![](/files/BwSTxyFENTh4nae9eblc)
6. Choose **Chaos** from the Step Library.

   ![](/files/Bied1iXJG5WqDaHVLbO0)
7. Provide a name, select the chaos experiment.

   ![](/files/a44CM2ZPYTiNYkOAmIvM)
8. Choose from the list of chaos experiments, and click **Add to Pipeline**.

   ![](/files/uaQ12Fcydr7j4QJxjo1M)
9. Click **Apply Changes**.

   ![](/files/x87DsjYbHTa1CbQ8YYgH)
10. Click **Save**.

    ![](/files/OJVusSz5i3zt1uon6rCG)

For more information, go to [Pipeline concepts](/continuous-integration/new-to-harness-ci/key-concepts.md) and [Pipeline Modeling Overview](/continuous-delivery/troubleshooting-and-resources/resources/new-user/cd-pipeline-modeling-overview.md).

### Next Steps <a href="#next-steps" id="next-steps"></a>

* [Advanced Configurations](/resilience-testing/chaos-engineering/chaos-experiments/advance-configuration-options.md)
* [Edit or Update Experiment](/resilience-testing/chaos-engineering/chaos-experiments/edit-chaos-experiment.md)
