> ## Documentation Index
> Fetch the complete documentation index at: https://docs.steadwing.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Grafana

> Steadwing queries Prometheus metrics and Loki logs through Grafana to identify error patterns, latency spikes, and resource bottlenecks during incident analysis.

## What does the Grafana integration do?

Steadwing connects to Grafana to query Prometheus metrics and Loki logs during incident analysis. The Grafana integration helps Steadwing identify root causes faster by analyzing your observability data -- from error rates and latency spikes to application logs and stack traces.

## Why Use Grafana with Steadwing?

<CardGroup cols={2}>
  <Card title="Metrics Analysis" icon="chart-line">
    Analyze CPU, memory, error rates, and latency from Prometheus
  </Card>

  <Card title="Log Analysis" icon="file-text">
    Search Loki for error messages, stack traces, and patterns
  </Card>

  <Card title="Smart Correlation" icon="chart-network">
    Automatically link metric spikes to error logs
  </Card>

  <Card title="Complete Picture" icon="code-merge">
    Combine observability data with code analysis for faster RCA
  </Card>
</CardGroup>

## How do I connect Grafana to Steadwing?

### Step 1: Get Your Grafana URL

Your Grafana web address. Examples:

* **Grafana Cloud:** `https://yourcompany.grafana.net`
* **Self-hosted:** `https://grafana.yourcompany.com`
* **AWS EC2:** `https://ec2-xx-xx-xx-xx.compute.amazonaws.com:3000`
* **On-premises:** `https://10.0.1.50:3000`

<Note>
  Works with any Grafana deployment - Cloud, self-hosted, or on-premises.
</Note>

### Step 2: Create a Service Account Token

1. Open Grafana and navigate to **Administration** → **Service Accounts**
   * Direct link: `https://your-grafana-url/org/serviceaccounts`
2. Click **Add service account**
3. Configure the account:
   * **Display name:** Steadwing Integration (or your preferred name)
   * **Role:** Viewer (read-only access)
4. Click **Create**
5. Click **Add service account token**
6. Configure the token:
   * **Display name:** Steadwing Token
   * **Expiration:** Choose your preferred duration (or no expiration)
7. Click **Generate token**
8. Copy the token (starts with `glsa_...`)

<Warning>
  Save your token immediately! It's shown only once. If you lose it, you'll need to create a new token.
</Warning>

### Step 3: Connect Grafana in Steadwing

1. Navigate to [Steadwing Settings](https://app.steadwing.com/settings)
2. Find the **Grafana** integration card
3. Click to expand the collapsible form
4. Fill in the required fields:
   * **Grafana URL:** Your Grafana web address (e.g., `https://yourcompany.grafana.net`)
   * **Service Account Token:** Your token (starts with `glsa_`)
5. Toggle the switch to **Enable** the integration

## What data does Steadwing pull from Grafana?

When analyzing an incident, Steadwing automatically:

1. Checks your Grafana for Prometheus and Loki datasources
2. Queries **Prometheus metrics** (if available) - error rates, CPU/memory usage, latency
3. Queries **Loki logs** (if available) - error messages, stack traces, application logs
4. Correlates metric spikes with log errors to find patterns
5. Combines findings with code analysis to identify the root cause
6. Provides evidence-based diagnosis with relevant metrics and logs

No manual searching required!

## Requirements

* **Grafana version:** 9.0 or newer
* **Service account role:** Viewer (read-only)
* **Datasources:** At least one of:
  * Prometheus (for metrics)
  * Loki (for logs)
  * Both (recommended for best results)

## Datasource Flexibility

The integration automatically adapts to what you have:

| Your Setup             | What Happens                                 |
| ---------------------- | -------------------------------------------- |
| Prometheus only        | Analyzes metrics (CPU, errors, latency)      |
| Loki only              | Analyzes logs (error messages, stack traces) |
| Both Prometheus + Loki | Best results! Correlates metrics with logs   |

<Note>
  You don't need both datasources - Steadwing uses whatever you have configured.
</Note>

## What Data Can Steadwing Access?

**Prometheus Metrics:**

* Performance data (CPU, memory, latency)
* Error rates and request counts
* Custom application metrics
* Only data around incident timeframes

**Loki Logs:**

* Application logs and error messages
* Stack traces and exceptions
* Service logs for affected applications
* Only relevant time ranges

**Security:** Read-only access. Cannot modify dashboards, alerts, or data.

## Uninstall

To disconnect the integration:

1. In Steadwing Settings, disable the Grafana integration
2. In Grafana, delete the service account:
   * Navigate to **Administration** → **Service Accounts**
   * Find "Steadwing Integration" (or your chosen name)
   * Click **Delete service account**

This immediately revokes access.

## FAQs

<AccordionGroup>
  <Accordion title="Can Steadwing modify my dashboards or alerts?">
    No. Steadwing has read-only access and can only query data. It cannot modify any Grafana configuration, dashboards, alerts, or data.
  </Accordion>

  <Accordion title="Do I need both Prometheus and Loki?">
    No. The integration works with either one or both. Having both provides the best results since it can correlate metrics with logs.
  </Accordion>

  <Accordion title="Can I revoke access later?">
    Yes. Simply delete the service account token in Grafana anytime to immediately revoke access.
  </Accordion>

  <Accordion title="What if I only have Prometheus?">
    Perfect! Steadwing will analyze metrics like error rates, latency, CPU, and memory usage.
  </Accordion>

  <Accordion title="What if I only have Loki?">
    Great! Steadwing will analyze logs including error messages, stack traces, and patterns.
  </Accordion>

  <Accordion title="Does this work with self-hosted Grafana?">
    Yes! Works with Grafana Cloud, self-hosted, or on-premises installations.
  </Accordion>

  <Accordion title="How much data does it query?">
    Only relevant data around the incident timeframe (typically a few hours). Queries are optimized to focus on error patterns and anomalies.
  </Accordion>

  <Accordion title="What if no datasources are found?">
    Add at least one Prometheus or Loki datasource in Grafana, then reconnect the integration.
  </Accordion>
</AccordionGroup>

Need additional help? Please reach out to us at [hello@steadwing.com](mailto:hello@steadwing.com)
