# LaunchDarkly

{% hint style="info" %}
Cortex connects to many third-party vendors whose system interfaces frequently change. As a result, integration behavior or configuration steps may shift without notice. If you encounter unexpected issues, check with your system administrator or refer to the vendor's documentation for the most current information. Additionally, integration sync times vary and are subject to scheduling overrides and timing variance.
{% endhint %}

[LaunchDarkly](https://launchdarkly.com/) is a feature flag management platform.

Integrating Cortex with LaunchDarkly allows you to:

* Track LaunchDarkly feature flags on entities in the catalog.
* Create [Scorecards](/standardize/scorecards.md) that track progress and drive alignment on projects involving your LaunchDarkly feature flags.
* Perform tasks relating to LaunchDarkly feature flags as a part of a [Workflow](/streamline/workflows.md).
  * For example, you can include a "Create feature flag" step within a Workflow.

## How to configure LaunchDarkly with Cortex

### Prerequisites

Before getting started, create a [LaunchDarkly access token](https://app.launchdarkly.com/settings/authorization) with:

* The `Writer` role
  * If you are not adding LaunchDarkly-related tasks to your [Workflows](/streamline/workflows.md), you can configure the token with the `Reader` role.
* `20220603` as the API version

### Configure the integration in Cortex

1. In Cortex, navigate to the [LaunchDarkly settings page](https://app.getcortexapp.com/admin/integrations/launchdarkly):
   * Click **Integrations** from the main nav. Search for and select **LaunchDarkly**.
2. Click **Add configuration**.
3. Configure the integration details:
   * **Account alias**: Enter the alias for this configuration.
   * **Access token**: Enter your LaunchDarkly access token.
   * **Environment**: Select your environment.
4. Click **Save**.

To modify the integration configuration, see [Modifying an existing integration configuration](/ingesting-data-into-cortex/integrations.md#modifying-an-existing-integration-configuration).

#### **Configure the integration for multiple LaunchDarkly accounts**[**​**](https://docs.cortex.io/docs/reference/integrations/github#configure-the-integration-for-multiple-propsintegration-accounts)

The LaunchDarkly integration has multi-account support. You can add a configuration for each additional organization, instance, or account by repeating the process above.

Each configuration requires an alias, which Cortex uses to correlate the designated organization, instance, or account with registrations for various entities. Registrations can also use a default configuration without a listed alias. You can edit aliases and default configurations from the LaunchDarkly page in your Cortex settings. Select the edit icon next to a given configuration and toggle **Set as default** on. If you only have one configuration, it will automatically be set as the default.

## How to connect Cortex entities to LaunchDarkly

### Discovery

By default, Cortex will try to "best-guess" the corresponding project in LaunchDarkly based on the key or tags.

Cortex first looks up a LaunchDarkly project using the entity name (e.g. `My Service`), then the entity identifier (e.g. `my-service`). For example, if your entity name is “My Service”, then the corresponding LaunchDarkly project's key or tag should contain either “My Service” or "my-service".

If no project was matched, Cortex will try to "best-guess" feature flags from all available projects using feature flag tags.

### Editing the entity descriptor

You can find the project key and tags in LaunchDarkly under **Account settings > Projects**. The URL for the project will contain the key. For example: `https://app.launchdarkly.com/projects/default/settings/environments`.

If you prefer to use the project tags in the registration instead, you can find it in the projects table or project settings page.

```yaml
x-cortex-launch-darkly:
  projects:
    - key: project-key
      environments: # Optional
        - environmentName: prod
        - environmentName: staging
      alias: alias-1 # alias is optional and only relevant if you have opted into multi account support
    - tag: project-tag
      environments: # Optional
        - environmentName: prod
      alias: alias-2 # alias is optional and only relevant if you have opted into multi account support
  feature-flags:
    - tag: feature-flag-tag
      environments: # Optional
        - environmentName: staging
      alias: alias-3 # alias is optional and only relevant if you have opted into multi account support
```

## Using the LaunchDarkly integration <a href="#still-need-help" id="still-need-help"></a>

### Scorecards and CQL <a href="#still-need-help" id="still-need-help"></a>

With the LaunchDarkly integration, you can create Scorecard rules and write CQL queries based on LaunchDarkly projects.

See more examples in the [CQL explorer](https://app.getcortexapp.com/admin/cql-explorer) in Cortex.

<details>

<summary>Check if LaunchDarkly project is set</summary>

Check if entity has a registered LaunchDarkly project in its [entity descriptor](/ingesting-data-into-cortex/entities-overview/entities.md#defining-entities-via-yaml-file). If no registration exists, we'll try to automatically detect which corresponding LaunchDarkly project is associated with the entity.

**Definition**: `launchDarkly (==/!=) null`

**Example**

For example, you could write a rule in a Scorecard to check whether an entity has a LaunchDarkly project set:

```
launchDarkly != null
```

</details>

<details>

<summary>Feature flags</summary>

List of flags

**Definition**: `launchDarkly.flags()`

**Example**

In a Scorecard, you could write a rule to check whether an entity has fewer than 10 flags:

```
launchDarkly.flags().length < 10
```

</details>

### View integration logs <a href="#still-need-help" id="still-need-help"></a>

{% hint style="info" %}
This feature is available in Cortex cloud.
{% endhint %}

While viewing an integration's settings page, click the **Logs** tab to view error logs from the last 7 days. You can filter the logs list by configuration and by operation (for example, you could filter to view errors surfaced only via Scorecards).

<div align="left" data-with-frame="true"><figure><img src="/files/x8JmoPqXZTJ7YHeFJpOA" alt="The &#x27;Logs&#x27; tab on an integration&#x27;s settings page shows error information over the past 7 days."><figcaption></figcaption></figure></div>

Click into a row to get more information, including time stamp, status code, full error, and request path.

## FAQs and troubleshooting

#### **How often does the integration poll for new flags?**

A scheduled job runs every 2 hours to check for new flags.

## Still need help?[​](https://docs.cortex.io/docs/reference/integrations/aws#still-need-help) <a href="#still-need-help" id="still-need-help"></a>

The following options are available to get assistance from the Cortex Customer Engineering team:

* **Email**: <help@cortex.io>, or open a support ticket in the in app Resource Center
* **Slack**: Users with a connected Slack channel will have a workflow added to their account. From here, you can either @CortexTechnicalSupport or add a `:ticket:` reaction to a question in Slack, and the team will respond directly.

Don’t have a Slack channel? Talk with your Customer Success Manager.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cortex.io/ingesting-data-into-cortex/integrations/launchdarkly.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
