Grafana

The Grafana integration in Middleware lets you connect your Grafana instance and ingest alerts via webhook so that whenever an alert fires in Grafana, its details are sent to Middleware and displayed in the OpsAI alerts listing. Each alert includes context such as title, status, state, message, receiver, commonLabels (e.g. alertname, rulename, grafana_folder), generatorURL, and silenceURL, so you can see full context and jump back to Grafana.

The integration has two tabs: Configuration (where you set the connection and capabilities) and Alert Ingestion (where you follow steps to configure the webhook in Grafana). Once alerts are flowing, you can open any alert in a detailed side panel and start an OpsAI investigation, Middleware uses your Grafana integration and enabled capabilities to fetch metrics, logs, dashboards, and more, then produces a report and suggested fixes.

Prerequisites

Before connecting Grafana to Middleware, ensure you meet the following requirement:

1 Grafana Account

You must have an active Grafana account. The integration uses a Grafana service account token to securely access dashboards, metrics, logs, and other data needed for OpsAI investigation.

Setup

The Grafana integration in Middleware has two tabs: Configuration and Alert Ingestion. Configure the connection and capabilities first, then set up the webhook in Grafana so alerts are sent to Middleware.

Configuration tab

Use this tab to connect Middleware to your Grafana instance and choose which capabilities OpsAI can use.

Grafana Configuration

1 Connection details

  1. Navigate to Installation > Integration > Grafana Integration within the Middleware platform.
  2. Open the Configuration tab and click Add New Connection.
  3. Enter a Connection name for this integration.
  4. Enter your Grafana URL (e.g. https://my-company.grafana.net or your self-hosted URL).
  5. For Service token, create a service account in Grafana with the Viewer role and use its token (see step 2 below).

2 Create a service account and token in Grafana

To obtain the Service token for the connection:

  1. Open the Service Accounts page in Grafana (e.g. https://my-company.grafana.net/org/serviceaccounts).
  2. Select an existing Viewer service account, or create a new one with the Viewer role.
  3. Click Add service account token.
  4. Click Generate token.
  5. Click Copy to clipboard and paste the value into the Service token field in Middleware.

Save the connection after pasting the token.

3 Modify Capabilities

You can enable or disable the following capabilities for OpsAI:

  • Scrape - When enabled, Middleware lists incoming webhook alerts in the OpsAI alerts listing so you can run investigations. Alert ingestion itself is configured via the Alert Ingestion tab (webhook), not by automatic polling.
  • Dashboards
  • Events
  • Webhooks
  • Logs
  • Metrics
  • Metrics Cardinality

Based on the capabilities you enable, OpsAI will use the Grafana integration to fetch the corresponding data during investigation and analysis of alert issues.

Alert Ingestion tab

This tab shows read-only instructions for configuring Grafana so that alerts are sent to Middleware via webhook. After you complete these steps in Grafana, new alerts will fire the webhook, Middleware will receive them, and they will appear in the OpsAI alerts listing.

Grafana Alert Ingestion

1 Set Contact Points

  1. In Grafana, go to Alerts & IRM > Alerting > Contact points.
  2. Click Create Contact Point and set:
    • Name: mw-opsai
    • Integration: Webhook
    • URL: <Copy from the Alert Ingestion tab>
  3. Under Optional Webhook Settings:
    • Authorization Header - Scheme: ApiKey
    • Authorization Header - Credentials: <Copy from the Alert Ingestion tab>
  4. Click Save Contact Point.

2 Set Notification policies

  1. In Grafana, go to Alerts & IRM > Alerting > Notification policies.
  2. Click Add new policy, then New sibling above, and configure:
    • Matching Labels: Leave empty (click the bin icon to clear if needed).
    • Contact Point: mw-opsai
    • Continue matching subsequent sibling nodes: Enabled
    • Override grouping: Enabled
    • Group by: alertname only (remove any other values).
    • Override general timings: Enabled
    • Group wait and Group interval: 1s
    • Repeat interval: Leave empty.
  3. Click Save policy.

After saving, Grafana will send alert notifications to the Middleware webhook using the mw-opsai contact point.

Post-Installation

Once the Configuration is saved and the Alert Ingestion steps are done in Grafana, alerts that match your notification policy will be sent to Middleware via webhook and listed in the OpsAI alerts view. Click any alert to open a detailed view in the side panel. From there you can see full alert context and start an OpsAI investigation.

Grafana OpsAI Listing

Alert object

Each Grafana alert displayed in OpsAI includes payload fields similar to the following (among others):

KeyDescription
titleAlert title (e.g. [FIRING:1] DatasourceNoData ...).
statusFiring state (e.g. firing).
stateAlert state (e.g. alerting).
messageFull message body with labels and links (e.g. to source, silence).
receiverContact point that received the alert (e.g. mw-opsai).
externalURLBase URL of your Grafana instance.
commonLabelsLabels shared by all alerts (e.g. alertname, rulename, grafana_folder, datasource_uid, ref_id).
groupLabelsLabels used for grouping (e.g. alertname, grafana_folder).
groupKeyKey identifying the alert group.
alertsArray of individual alert objects, each with labels, annotations, startsAt, endsAt, generatorURL, silenceURL, ruleUID, fingerprint, status, valueString.
orgIdGrafana organization ID.
versionPayload version.

These fields are available in the alert side panel and are used by OpsAI during investigation to fetch context and link back to Grafana (e.g. via generatorURL, silenceURL).

OpsAI Investigation

From the alert side panel, you can start an investigation on that alert. OpsAI uses the received alert payload and your Grafana integration configuration (including enabled capabilities) to query Grafana for metrics, logs, dashboards, and events. It then analyzes the situation, identifies the root cause, and presents a detailed report with findings and suggested remediation. You can also start a new OpsAI chat; OpsAI will use the Grafana integration to give contextual answers, insights, and guided resolutions.

Grafana OpsAI Detailed View

Need assistance or want to learn more about Middleware? Contact our support team at [email protected] or join our Slack channel.