• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
    No results for ""
    EXPAND ALL

    EDIT ON GITHUB

    Grafana

    Read time: 2 minutes
    Last edited: Apr 04, 2023
    The Grafana integration is a Pro and Enterprise feature

    The Grafana integration is available to customers on a Pro or Enterprise plan. To learn more, read about our pricing. To upgrade your plan, contact Sales.

    Overview

    This topic explains how to use the LaunchDarkly Grafana integration. You can use the integration to send flag, environment, and project updates to Grafana to add context to your graphs.

    Prerequisites

    To use the Grafana integration, you must have the following prerequisites:

    • A Grafana instance that is accessible to LaunchDarkly's servers.
    • An API key from Grafana with editor privileges.

    To generate an API key:

    1. In Grafana, open the the Configuration menu and select "API keys." The "API keys" tab appears.
    The "API keys" tab in Grafana.
    The "API keys" tab in Grafana.
    1. Click Add API key. An "Add API Key" section appears.
    2. Enter a Key name.
    3. Change the Role selection to "Editor" or "Admin."
    4. Click Add. An "API Key Created" dialog appears.
    5. Copy the key from the Key field and save it somewhere secure. Grafana displays this key only once, so you must copy and store it now. You will use it to set up the Grafana integration in LaunchDarkly.

    Setting up the Grafana integration

    After you create an API key in Grafana, you can set up the integration in LaunchDarkly.

    1. Navigate to the Integrations page and find "Grafana."
    2. Click Add integration. The "Create Grafana configuration" panel appears.
    3. (Optional) Give your integration a human-readable Name.
    4. Enter your Grafana instance URL.
    5. Enter the Grafana API key. You created this key in the Prerequisites section.
    6. (Optional) Configure a custom policy to control which events LaunchDarkly sends to Grafana. To learn more, read Filtering the events you send to Grafana.
    The "Create Grafana integration" panel.
    The "Create Grafana integration" panel.
    1. After reading the Integration Terms and Conditions, check the I have read and agree to the Integration Terms and Conditions checkbox.
    2. Click Save configuration. The new integration appears on the Integrations page. It is switched On by default.

    After you set up the Grafana integration, events from LaunchDarkly appear in your Grafana dashboard.

    Grafana configurations on the "Integrations" page.
    Grafana configurations on the "Integrations" page.

    Filtering the events you send to Grafana

    By default, LaunchDarkly sends events to Grafana for changes made to any feature flag, environment, or project. If you have a more limited use case for using the integration, or you wish to restrict which data you send to Grafana, you can filter which events LaunchDarkly sends.

    To filter events, write a policy using the same syntax as the custom roles feature to filter the events sent to Grafana.

    For more information about writing policies, read Policies in custom roles.

    For example, if you only want to receive an event when a change is made to one of the feature flags in your testing environment, you can add the following policy to your events stream:

    [
    {
    "effect": "allow",
    "actions": ["*"],
    "resources": ["proj/*:env/your-test-environment:flag/*"]
    }
    ]

    To add a custom filter:

    1. Navigate to the Integrations page and find "Grafana."
    2. Find the configuration you wish to modify, and click the overflow menu. The "Edit Grafana configuration" panel appears.
    Grafana integrations with the "Edit integration configuration" option called out.
    Grafana integrations with the "Edit integration configuration" option called out.
    1. Click Advanced editor. The Advanced editor appears.
    2. Enter your custom policy.

    The "Edit Grafana configuration" panel with the Advanced editor open and a policy inside it.
    The "Edit Grafana configuration" panel with the Advanced editor open and a policy inside it.

    1. Click Save configuration.

    You can verify that LaunchDarkly is sending a customized set of events by viewing the events in your Grafana dashboard.