Integrations
Observability
Grafana

Grafana

Overview

You can utilize FeatBit's Webhook integration to transmit updates about flags, environments, and projects to Grafana. These updates will appear as annotations, adding contextual information to your graphs. The figure below is an example:

Create Service Accounts for Integration

To use the Grafana integration, you need to create a Grafana service account and generate a service account token:

  1. In Grafana, open the Administration menu and select "Service accounts." The "Service accounts" tab appears.

  1. Click Add service account. The "Create service account" page appears.
  2. Enter a Display name.
  3. Change the Role selection to "Editor"

  1. Click Create. The "Service token" page appears.
  2. Click Add service account token.
  3. Enter a Display name for the token.
  4. Click Generate token.

  1. Copy the token and save if somewhere secure. Grafana displays this token only once, so you must copy and store it now. You will use it to set up the Grafana integration in FeatBit.

Setting up WebHook for Grafana integration

You can use FeatBit's Webhook to subscribe to changes in Feature Flags, then create an event sender for Grafana.

  1. On the menu, under Integrations, select Webhook to access the webhook configuration page.
  2. Click the + Add button.
  3. In the 'Add Webhook' drawer, enter the Name for the webhook.
  4. Enter the URL of the Grafana Annotation API. You can find the API URL in the official tutorial (opens in a new tab).
  5. Select the scope of WebHook you wish to subscribe to by choosing the Project and Environments.
  6. Choose the Events you want to subscribe to. For this tutorial, select Flag Change and Segment.
  7. Add the header Authorization for authorization. It uses bearer token for authorization. The token is the service account token you generated in the previous section.
  8. In the Payload Template enter the following template (you can also customize your own payload template):
{
{{#eq data.kind "feature flag"}}
  "tags":["featbit-feature-flag", "env:{{environment.name}}", "proj:{{project.name}}"],
  "text":"At {{happenedAt}} Feature Flag '{{data.object.name}}' in {{project.name}}/{{environment.name}}: <br/> {{#each changes}}{{this}}{{#unless @last}} ; {{/unless}}{{/each}}"
{{/eq}}
{{#eq data.kind "segment"}}
  "tags":["featbit-segment", "env:{{environment.name}}", "proj:{{project.name}}"],
  "text":"At {{happenedAt}} Segment '{{data.object.name}}' in {{project.name}}/{{environment.name}}: <br/> {{#each changes}}{{this}}{{#unless @last}} ; {{/unless}}{{/each}}"
{{/eq}}
}

For more information about WebHook, please refer this tutorial.

Add WebHook

  1. Test your webhook configuration by clicking on the Test your webhook configuration link. If the test is successful, you will see a success message. If the test fails, you will see an error message.

Add WebHook

  1. You will see the webhook you created in the webhook list.

Adding FeatBit annotations to Grafana dashboards

To add FeatBit Webhook events as annotations in Grafana dashboards:

  1. Open the Grafana dashboard in edit mode.
  2. Click the Dashboard settings gear icon button located at the top of the page.

  1. Click Annotations.
  2. Click New query. The "New annotation" page appears.
  3. Enter a human-readable name for the annotation, such as "FeatBit feature flags."
  4. In the Data source menu, select "-- Grafana --."
  5. In the Filter by menu, select "Tags."
  6. In the Tag field, enter tag(s) that you specified in the webhook. These are tags that you used to filter the annotations that appear on your dashboard.

  1. Click Save Dashboard. Then, return to the Dashboard, and you will see the annotations appear on the graph.

You can disable the annotations by clicking the toggle at the top of the dashboard.