---
title: "Auto fix with OpsAI"
description: "Configure OpsAI auto investigation for Kubernetes, APM and RUM: set the scope per source, choose notification channels and frequency, manage skills and add project context."
section: "Ops AI"
breadcrumb: "Ops AI > Settings"
canonical: "https://docs.middleware.io/features/opsai/autofix"
---
# Auto fix with OpsAI

OpsAI Settings is the central control panel for configuring how OpsAI monitors, investigates, and helps resolve issues across your environment.

From here, you can choose what OpsAI monitors across Kubernetes clusters, APM services, and RUM apps, enable or disable Auto Investigation for each source, configure notifications, and centralize alerts from Middleware and third-party tools. You can also manage the skills OpsAI follows and give it context about your project.

When Auto Investigation is enabled, OpsAI continuously analyzes available signals such as metrics, logs, and traces. It correlates telemetry across related entities and recent changes, performs root cause analysis (RCA), and proposes a fix that you can review and apply.

## Prerequisites

- For **Kubernetes**: Install the Kube Agent with `opsai.enabled=true` and verify that the cluster is visible in Middleware.
- For **APM**: Instrument the service and ensure it is reporting traces to Middleware.
- For **RUM**: Install the RUM snippet in your application and ensure it is sending data to Middleware.

> **Note:** Connect your [GitHub](/integrations/github-integration) or [Bitbucket](/integrations/bitbucket-integration) repository so OpsAI can read the files related to an error through the MCP server. With the repository linked, OpsAI delivers far more accurate, code-level fixes for APM and RUM issues.

## Open OpsAI Settings

Go to **Settings** → **OpsAI Settings**.

The page has three tabs:

- **Automation**: Auto Investigation, Notification Medium, Notification Frequency, and Alert with OpsAI. These are covered in the sections below.
- **Skills**: Reusable procedures that OpsAI loads when a task needs them. See [Skills](#skills).
- **Project Context**: Facts about your project that OpsAI reads before every chat and investigation. See [Project Context](#project-context).

![OpsAI Settings Page](/images/opsai/ops_ai_setting.jpg)

## Auto Investigation

The **Auto Investigation** section lists every source OpsAI can monitor. For each source, you define the **Monitoring Scope** (which entities to watch) and enable or disable **Auto-Investigate**:

- **Kubernetes**: Set the Monitoring Scope to **All Clusters**, or select the **Specific Clusters** you want OpsAI to watch, then flip the Auto-Investigate toggle.
- **Application Performance Monitoring (APM)**: Choose **All Services** as the Monitoring Scope, or narrow it down to the **Specific Services** that are relevant, and turn on the Auto-Investigate toggle.
- **Real User Monitoring (RUM)**: Keep the Monitoring Scope at **All Apps**, or pick the **Specific Apps** you care about, and enable the Auto-Investigate toggle.

![Auto Investigation section with Kubernetes, APM, and RUM sources and the Auto-Investigate toggle](/images/opsai/opsai_autoinvestigation.jpg)

When **Auto-Investigate** is enabled for a source, OpsAI automatically investigates issues within the defined scope and proposes a fix. You remain in control and decide whether to apply it.

### Set the scope per source

Each source has its own scope, so you can keep OpsAI focused on the workloads that matter:

- **Kubernetes**: Keep **All Clusters**, or click **Select Cluster** to pick one or more specific clusters. Only clusters where the agent is installed with `opsai.enabled=true` appear in this list.
- **APM**: Keep **All Services**, or click **Select Services** to choose the specific backend services OpsAI should auto-investigate.
- **RUM**: Keep **All Apps**, or click **Select App** to choose the specific RUM applications OpsAI should auto-investigate.

> **Note:** **Enable all automation in one click**: From the main OpsAI dashboard you can toggle a single button that turns on Auto-Investigation across **all** sources at once. The per-source controls on this Settings page let you fine-tune the scope and turn individual sources on or off after that.

![Single button on the OpsAI dashboard to enable automation across all sources](/images/opsai/opsai_enable_all_automation.jpg)

### Ask OpsAI Follow-Up Questions in Slack

When Auto-Investigate identifies an issue and Slack is configured as a notification medium, you can continue the investigation directly from the Slack alert thread:

1. Auto-Investigate detects an issue and performs root cause analysis.

   ![OpsAI Automation Started](/images/v2/integration/slack/opsai-automation-started.png)
2. OpsAI posts its RCA as a threaded reply under the original Slack alert.

   ![Middleware Auto fix with OpsAI: Slack Notify](/images/v2/integration/slack/opsai-slack-notify.png)
3. Reply in the same thread and mention `@Middleware` with your question. OpsAI displays a live status indicator while investigating.

   ![Middleware Auto fix with OpsAI: Slack Spinner](/images/v2/integration/slack/opsai-slack-spinner.png)
4. OpsAI posts its answer in the same thread when the investigation is complete.

   ![Slack OpsAI Reply](/images/v2/integration/slack/opsai-thread-reply.png)
5. You can also view the conversation in the OpsAI chat window inside Middleware.

   ![OpsAI Chat Window](/images/v2/integration/slack/opsai-screen-ref.png)

> **Note:** Following up like this requires an explicit @Middleware mention, and works inside an OpsAI incident thread specifically. See the [Slack Integration](/integrations/slack-integration#ask-opsai-follow-up-questions-in-slack) documentation for setup instructions, permissions, retention limits, usage limits, and other considerations.

### Chat with OpsAI Anytime in Slack

You're not limited to incident threads. Once Slack is connected, you can also:

- **Start a General Conversation**: Mention `@Middleware` in any channel, or send it a direct message, to ask about your observability data without an alert or incident.
- **Ask about an Alert**: Reply and mention `@Middleware` under a plain alert notification thread — one that hasn't triggered an OpsAI incident — to investigate it directly.

General conversations route to your account's default project unless you choose another one under **Integrations** → **Slack** → **Route general chats to**, or with the `/middleware set project` command.

> **Note:** See [Start a General Conversation with OpsAI in Slack](/integrations/slack-integration#start-a-general-conversation-with-opsai-in-slack) and [Ask About a Specific Alert in Slack](/integrations/slack-integration#ask-about-a-specific-alert-in-slack) for full details.

## Notification Medium

Notification settings apply across all OpsAI sources. Choose how you want to be notified when OpsAI detects or investigates an issue.

You can configure one or more notification mediums:

- Gmail
- Slack
- Microsoft Teams
- Webhook

For each medium, you can assign recipients by source, including Kubernetes, APM, and RUM. This ensures that the right teams receive notifications for the issues relevant to them.

A **Configured** badge indicates how many notification mediums are currently set up.

![Notification Medium with Gmail, Slack, Teams, and Webhook options and per-source recipients](/images/opsai/opsai_notifications.jpg)

For Slack, you can also continue an OpsAI investigation directly from the alert thread. Mention `@Middleware` with your question, and OpsAI will respond in the same thread. See [Slack Integration](/integrations/slack-integration#ask-opsai-follow-up-questions-in-slack) for more details.

## Notification Frequency

Choose how frequently OpsAI sends notifications.

With **Immediate (Real-time)** selected, you receive a notification as soon as OpsAI detects or investigates an issue.

Alternatively, select a notification interval, such as every 15 minutes. OpsAI will consolidate issues detected during that period into a single notification.

## Confirm Changes

After you change the monitoring scope, toggle Auto-Investigate, or update notification settings, a confirmation message appears:

**Your changes have been saved. Updates will appear within 5 minutes.**

![Confirm Changes - Your changes have been saved](/images/opsai/opsai_setting_pop_ups.jpg)

## Import Alerts into OpsAI

OpsAI can centralize alerts from Middleware, Grafana, and Datadog, allowing you to investigate them from the OpsAI interface. Alerts can appear in OpsAI in two ways: through native Middleware alert ingestion or supported third-party integrations.

### A. Native Middleware Alerts

Go to **Settings** → **OpsAI Settings** and enable the **Alert with OpsAI** toggle.

![Alert Ingestions toggle in OpsAI Settings](/images/opsai/alerts-ingestion-setting.jpg)

### B. Import Alerts from Third-Party Integrations

To bring Grafana or Datadog alerts into OpsAI:

- **Grafana**: Connect [Grafana](/integrations/grafana-integration) and configure a webhook using a Contact Point and Notification Policy to send alerts to Middleware. You can then use OpsAI to investigate those alerts with the available Grafana telemetry.
- **Datadog**: Connect [Datadog](/integrations/datadog-integration) to ingest supported alerts. OpsAI can then investigate Monitor and Kubernetes alerts using the available metrics, logs, and traces.

## Skills

Skills are reusable procedures, such as runbooks and triage steps, that OpsAI loads only when a task needs them. Open the **Skills** tab to see the built-in **Middleware** skills and your team's **Custom** skills, turn skills on or off for the project, and create new ones with **New Skill**.

![Skills tab under Settings → OpsAI Settings listing skills with their type, description, and Enabled toggle](/images/opsai/skills/opsai-skills-tab.png)

In OpsAI chat, type `/` to pick a skill and run it directly.

For the full guide on creating, running, and managing skills, see [OpsAI Skills](/features/opsai/skills).

## Project Context

Project Context tells OpsAI what it should always know about your project. OpsAI reads it before every chat, investigation, and skill run in the project, including auto-investigations, so you don't have to repeat the same details in every conversation.

![Project Context tab with a Markdown editor for project instructions and an Insert example link](/images/opsai/skills/opsai-project-context.png)

Good things to include:

- Naming conventions, such as which namespaces or prefixes are production
- Environments and regions you run in
- Critical services and how to prioritize their issues
- Known noise that OpsAI shouldn't flag
- How deploys happen and where to check them
- SLOs, such as your latency targets
- How you want answers formatted

To add Project Context:

1. Go to **Settings** → **OpsAI Settings** and select the **Project Context** tab.
2. Write your context in the editor. Markdown is supported, up to 10,000 characters. Click **Insert example** to see a sample you can edit.
3. Click **Save Changes**.

Here's an example:

```markdown
We run an e-commerce platform on EKS (us-east-1, eu-west-1) with 42 services.
- Production namespaces start with prod-. Ignore sandbox-* and ci-runner.
- checkout-service and payment-gateway are tier-1. Treat their errors as P1.
- 404s on /healthz and /ping are expected. Don't flag them.
- Deploys go out through ArgoCD. Check the latest rollout before blaming code.
- Our p95 latency SLO is 400 ms for user-facing APIs.
- Reply in short bullet points and link the trace or log you used.
```

> **Note:** Keep Project Context to facts that are always true. Put procedures that only apply in certain situations, such as how to triage a payment failure, in a [skill](/features/opsai/skills) instead. OpsAI loads a skill only when it's needed, while it reads Project Context every time.

Project Context is saved per project. Each project has its own context.

## Tips and Troubleshooting

- **Cluster not listed**: Verify that the agent is installed with `opsai.enabled=true` and that the cluster name is configured correctly.
- **Service or app not listed**: Confirm that the APM service or RUM app is instrumented and actively reporting data to Middleware.
- **Nothing appears in OpsAI**: Verify that Auto-Investigate is enabled for the source and that at least one entity is included in its Monitoring Scope.

Need assistance or want to learn more about Middleware? Get in touch with us via our Contact Us page or join our Slack channel.
