For the complete documentation index, see llms.txt. This page is also available as Markdown.
Continuous DeliveryCvHealth Sources

Grafana Loki

Add Grafana Loki as a health source in Harness CV to monitor log data and detect anomalies during deployments.

Feature flag required

Grafana Loki requires the feature flag SRM_ENABLE_GRAFANA_LOKI_LOGS. Contact Harness Support to enable the feature.

This topic explains how to add Grafana Loki as a health source for Continuous Verification (CV). Once configured, Harness queries your Loki instance for log data during deployment verification and flags anomalies that could indicate a degraded release.


What you will learn from this topic

  • Grafana Loki connector setup: How to create and configure a Grafana Loki connector, including the base URL, headers, and validation path.

  • Health source configuration: How to add Grafana Loki as a health source in the AI Verify (v1) step.

  • Log query definition: How to write a Loki log query and run it to confirm accuracy.

  • Field mapping: How to map query results to Harness service instances for accurate verification.


Before you begin

Before you add Grafana Loki as a health source, complete the following:

  • CV setup: Set up an AI Verify (v1) step in your pipeline. Go to Configure CV to complete the prerequisite configuration.

  • Grafana Loki instance: You need a running Grafana Loki instance. By default, Loki exposes its API on port 3100 without authentication.

  • Connector permissions: You need permission to create connectors in your Harness project.


Add Grafana Loki as a health source

The following steps walk you through adding Grafana Loki as a health source in the AI Verify (v1) step.

Define the health source

To configure the health source connection, do the following:

  1. In the Health Sources section of the Verify screen, select + Add New Health Source.

    The Add New Health Source dialog appears.

  2. In the Define Health Source tab, do the following:

    1. In the Define Health Source section, select GrafanaLoki as the health source type.

    2. In the Health Source Name field, enter a name for the health source.

    3. In the Connect Health Source section, select Select Connector.

      The Create or Select an Existing Connector dialog appears.

    4. Select a connector for the Grafana Loki health source, then select Apply Selected.

      The selected connector appears in the Select Connector dropdown. The Grafana Loki Logs option is selected by default in the Select Feature field.

Create a new Grafana Loki connector

Follow these steps if you do not already have a Grafana Loki connector:

  1. In the Create or Select an Existing Connector dialog, select + New Connector.

  2. In the Overview tab, enter a name for the connector, an optional description, and a tag, then select Continue. If you use multiple providers of the same type, give each provider a different name.

  3. In the Headers tab, enter the following, then select Next:

    • Base URL: The base URL of your Grafana Loki account. By default, Grafana Loki exposes its API on port 3100 without authentication.

    • Key and Value (optional): A key-value pair for the Grafana Loki log stream you want to select in the query. Go to Log stream selector to review log stream selector syntax and key-value pairs.

  4. In the Parameters tab (optional), enter the Key and Value pair.

  5. In the Validation Path tab, select either the GET or POST request method and enter the Validation Path.

    If you select POST, you must also include the request body. The following is an example validation path for a GET request: loki/api/v1/labels.

  6. In the Delegates Setup tab, choose one of the following:

    • Use any available Delegate: Harness automatically assigns an available delegate.

    • Only use Delegates with all of the following tags: Enter tags to ensure Harness selects only delegates assigned those specific tags.

  7. Select Save and Continue.

    Harness verifies the connection.

  8. Once the verification is successful, select Finish.

    The Grafana Loki connector is added to the list of connectors.

  1. Select Next. The Configuration tab appears.

Define log configuration settings

In the Configuration tab, do the following to add and name a query:

  1. Select + Add Query.

    The Add Query dialog appears.

  2. Enter a name for the query, then select Submit.

    The query is listed under Logs Group. The query specification and mapping settings appear. These settings help you retrieve the desired logs from the Grafana Loki platform and map them to the Harness service.

Define a query

After naming the query, configure the log query and field mappings:

  1. In the Query field, enter a log query and select Run Query to execute it.

    A sample record appears in the Records field. This helps you confirm the accuracy of the query you constructed.

  2. In the Field Mapping section, select + to map the service instance identifiers and select the data you want displayed from the logs. Go to Service Instance Identifier (SII) to understand how Harness uses this mapping.

  3. Select Get sample log messages.

    Sample logs appear to help you verify that the query is correct.

Sample log query

The following query returns data from all filenames except syslog:

Grafana Loki sample query results showing matched log entries in the Records field

Next steps

After adding Grafana Loki as a health source, run your pipeline to start collecting log data during deployment verification.

Last updated

Was this helpful?