> 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/continuous-delivery/use-continuous-delivery/verify-deployments/cv-concepts/templates.md).

# Create and Use a Monitored Service Template in a Verify Step

Create a monitored service template and use it in an AI Verify (v1) step

{% hint style="info" %}
This feature is in Beta[^1] and requires enablement. [View all early access features.](/release-notes/features.md)

{% @harness-feature-flag-access/request-feature-flag-access module="continuous-delivery" pagePath="continuous-delivery/use-continuous-delivery/verify-deployments/cv-concepts/templates" featureFlags="%5B%7B%22name%22%3A%22Monitored%20service%20template%20as%20runtime%20input%22%2C%22key%22%3A%22CV\_MONITORED\_SERVICE\_TEMPLATIZATION%22%2C%22status%22%3A%22BETA%22%2C%22description%22%3A%22Lets%20you%20select%20a%20monitored%20service%20template%20as%20a%20runtime%20input%20on%20the%20AI%20Verify%20(v1)%20step%20when%20you%20run%20the%20pipeline.%22%7D%5D" %}
{% endhint %}

A monitored service in Harness is a combination of a Harness service and an environment. The service can be any workload you want to monitor, including a microservice. Environments represent deployment targets such as QA, production, or any other target where the workload runs. Connect a monitored service to change sources and health sources to monitor service health.

This topic shows you how to create a monitored service, then select a monitored service template in an AI Verify (v1) step as a fixed value or a runtime input.

***

## What you will learn from this topic

* How to [create a monitored service](#create-a-monitored-service) for Continuous Verification
* How to choose [Default or Template](#configure-the-monitored-service-template-in-an-ai-verify-v1-step) for the AI Verify (v1) step
* How to select a [fixed](#select-a-fixed-monitored-service-template) or [runtime](#select-a-monitored-service-template-during-runtime) monitored service template
* How to apply [advanced template patterns](#advanced-use-cases) across multiple AI Verify (v1) steps

***

## Before you begin

* **Harness delegate**: Install a delegate that can reach Harness, your health source, and your change source. Go to [Get started with delegates](https://developer.harness.io/docs/platform/delegates/delegate/delegate-concepts/delegate-overview) to install and configure a delegate.
* **Organization and project**: Create an organization and project if you do not already have them. Go to [Create organizations and projects](https://developer.harness.io/docs/platform/organizations-and-projects/create-an-organization) to set them up.
* **Continuous Verification basics**: Know how AI Verify (v1) and monitored services fit into verification. Go to [Verification Overview](/continuous-delivery/use-continuous-delivery/verify-deployments/verify-deployments-with-the-verify-step.md) to review Continuous Verification concepts.
* **Pipeline edit access**: View and Create/Edit permissions on Pipelines so you can add or edit an AI Verify (v1) step. Go to [RBAC in Harness](https://developer.harness.io/docs/platform/role-based-access-control/rbac-in-harness) to configure roles.

{% hint style="info" %}
**GitX support for monitored services**

Harness supports storing monitored services in Git using GitX (bi-directional sync). This feature is behind the feature flag `CDS_CV_MS_GITX`. Go to [Store monitored services in Git](https://developer.harness.io/docs/platform/git-experience/gitx-monitored-services) to learn how to configure GitX.

Note the following limitations for default monitored services:

* **Name and identifier are immutable.** Harness automatically sets the name and identifier to a combination of the service name and environment name. This naming convention supports dynamically monitored service selection at the time of step execution.
* **The YAML view is not available** for default monitored services.
* **Auto-resource creation is not supported** via GitX. You cannot use GitX to automatically create new monitored service resources.

GitX is fully supported for template-monitored services.
{% endhint %}

***

## Create a monitored service

A monitored service is a logical entity that combines a Harness service and environment. The service can be a microservice or any other monitored workload. Environments represent your deployment targets, such as QA, production, and so on.

Perform the following steps to create a monitored service:

1. In your Harness project, go to **Continuous Delivery** -> **Monitored Services** -> **+ New Monitored Service**.

   ![Navigate to the new monitored services page](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-cf53cec677f5c50e36d360aa6e35073990c57a97%2Fmonitored-service-template-cd.png?alt=media)

   The **Create new monitored service** page appears.
2. In the **Overview** section, define a service and environment for the application you want to monitor.
   * In **Service**, do one of the following:
     * If the service that you want to monitor exists, select it.
     * If you want to create a service, select **Add New**, enter the following information, then select **Save**.
       * **Name**: Enter a name for the service. For example, `sample_service`.
       * **Description** (optional)
       * **Tag** (optional)
   * In **Environment**, do one of the following:
     * If the environment that you want to monitor exists, select it.
     * If you want to create an environment, select **Add New**, enter the following information, then select **Save**.
       * **Name**: Enter a name for the environment.
       * **Description** (optional)
       * **Tag** (optional)
       * **Environment Type**: Select **Production** or **Non-Production**.

Harness automatically populates the **Monitored Service Name** field by combining the service and environment names. This field is not editable.

After you create the monitored service, edit it to add a health source. A monitored service can include more than health sources, but health sources alone are enough for verification. You can therefore create a monitored service template that includes only the required health sources. Go to [Monitored service templates](https://developer.harness.io/docs/service-reliability-management/monitored-services/monitored-service-template-quickstart) to review the SRM template workflow.

***

## Configure the monitored service template in an AI Verify (v1) step

You can configure the monitored service template in the AI Verify (v1) step. Under **Monitored Service** -> **Monitored Service Type**, select **Default** or **Template**.

* **Default**: The AI Verify (v1) step automatically selects the monitored service that matches the stage's service and environment. If Harness does not find a matching monitored service, the step is skipped.

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p><strong>Autocreate a monitored service</strong></p><p>When <strong>Monitored Service Type</strong> is <strong>Default</strong>, you can use <strong>Click to autocreate a monitored service</strong>. This option simplifies setup when the Deploy stage uses a fixed service and environment. The AI Verify (v1) step checks whether a matching monitored service exists. If it does not, the step offers to create one. You can then add health sources and finish the monitored service configuration.</p></div>
* **Template**: Specify the monitored service template to use for verification as a fixed value or as a runtime input.

To select a monitored service template, select **Template** under **Monitored Service** -> **Monitored Service Type** on the AI Verify (v1) step configuration page. The template input can be a fixed value or a runtime input.

### Select a fixed monitored service template

Perform the following steps to select a fixed monitored service template:

1. Select Template input as a fixed value.
2. **Select Template**.
3. On the **Templates** -> **Monitored Service Templates** page, select a template.
4. Select the **Version Label**.
5. Select **Use Template**.

   ![Select a monitored service template as a fixed value](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-c250260b863696082c8c6919f8e09e9226426502%2Fselect-template-fixed-value.png?alt=media)

### Select a monitored service template during runtime

Selecting a monitored service template at runtime requires the `CV_MONITORED_SERVICE_TEMPLATIZATION` feature flag. Contact [Harness Support](mailto:support@harness.io) to enable the flag on your account.

Perform the following steps to select a monitored service template at runtime:

1. On the AI Verify (v1) step settings page, select Template input as a runtime value, then apply the step configuration.

   ![Monitored service template configured as a runtime input](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-504796c56f28c03dda3d3ffa2e1860f9bb2596b0%2Fmonitored-service-template-as-runtime-input.png?alt=media)
2. When you run the pipeline, on the **Run Pipeline** page under **Execution** -> **Step: Verify** -> **Monitored service template**, select **Select Template**.

   ![Select a monitored service template on the Run Pipeline page](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-cccb272bb07826d7c97466ac34c3ec2b7acda8a7%2Fmonitored-service-template-1.png?alt=media)
3. On the **Select a Monitored Service Template** page, select a monitored service template.

   ![Choose a monitored service template at runtime](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-f184e4568aa3224a267f44477245ec063d166ccb%2Fselect-template-runtime.png?alt=media)
4. Select **Apply Selected**.

***

## Advanced use cases

A monitored service template supports the following patterns:

* Configure multiple AI Verify (v1) steps in a single stage, each with a different monitored service template, and run them based on conditions.
* Create a monitored service template with a user-impacting metric that is not tied to a single service, and use it in verification alongside a template that uses service-linked metrics.

***

## Troubleshooting

<details>

<summary>AI Verify (v1) step is skipped when Monitored Service Type is Default</summary>

Harness skips the step when it cannot find a monitored service that matches the stage service and environment. Create the monitored service first, or use **Click to autocreate a monitored service** when the service and environment inputs are fixed.

</details>

<details>

<summary>Select Template is not available as a runtime input</summary>

Confirm that the `CV_MONITORED_SERVICE_TEMPLATIZATION` feature flag is enabled on your account. Contact [Harness Support](mailto:support@harness.io) if the option is still missing after the flag is enabled.

</details>

<details>

<summary>Verification runs but has no health source data</summary>

Edit the monitored service or template and add at least one health source. Go to [Configure verification](/continuous-delivery/use-continuous-delivery/verify-deployments/configure-cv.md) to add health sources for Continuous Verification.

</details>

***

## Next steps

* [Verification Overview](/continuous-delivery/use-continuous-delivery/verify-deployments/verify-deployments-with-the-verify-step.md): Review Continuous Verification concepts and AI Verify (v1) options.
* [Configure verification](/continuous-delivery/use-continuous-delivery/verify-deployments/configure-cv.md): Add health sources and finish verification setup.
* [Monitored service templates](https://developer.harness.io/docs/service-reliability-management/monitored-services/monitored-service-template-quickstart): Create and manage monitored service templates in Service Reliability Management.

{% @harness-feedback/feedback %}

[^1]: Beta features are feature-complete but still being validated. Available on request.
