Configure OpsAI
Middleware OpsAI uses collected observability data to detect supported production issues, investigate likely causes, and recommend solutions across infrastructure, Kubernetes, and applications.
Instead of manually switching between metrics, traces, logs, and source code to investigate an error, OpsAI correlates the available telemetry, identifies possible root causes, and provides suggested fixes.
For application errors, OpsAI can generate code changes and create pull requests for review. For supported Kubernetes issues, it can recommend or apply infrastructure-level fixes.
With OpsAI, you can:
- Automatically detect issues across infrastructure, Kubernetes, APM, and RUM.
- View detected issues in one place.
- Investigate errors using related logs, traces, stack traces, and resource information.
- Get root cause analysis and suggested solutions.
- Generate code fixes and pull requests for application errors.
- Apply supported Kubernetes fixes with the required permissions.
- Automatically investigate new issues and receive analysis through configured notification channels.
- Ask questions about your observability data using natural language.
How OpsAI Works#
OpsAI uses data collected by Middleware to identify issues and investigate their causes.
You do not need to install a separate OpsAI SDK to begin using its conversational capabilities or detecting supported issues from already-instrumented applications.
The setup depends on the capability: Kubernetes collection, repository-based code fixes, and automatic investigation each require the relevant configuration described below.
Set Up OpsAI#
The setup depends on the resources you want to monitor.
| Monitoring Source | Required Setup |
|---|---|
| Infrastructure | Install the Middleware Infrastructure Agent and collect host telemetry |
| Kubernetes | Install the Middleware Kube Agent with OpsAI enabled |
| Backend Applications | Instrument applications using Middleware APM |
| Frontend Applications | Install the Middleware RUM SDK |
| Code Fixes | Connect a supported source code repository |
| Automatic Investigation | Enable Auto Investigation and select its monitoring scope |
Once telemetry collection is configured, OpsAI can begin identifying supported issues from the available data.
Configure OpsAI for Kubernetes#
For Kubernetes, install the Middleware Kube Agent with OpsAI and auto-instrumentation enabled.
You will need:
- Middleware API Key — Authenticates telemetry collection.
- Middleware Target URL — Endpoint for your Middleware account.
- Cluster Name — Identifies the Kubernetes cluster.
Install Using Helm#
Add the Middleware Helm repository:
1helm repo add middleware-labs https://helm.middleware.ioInstall the agent with OpsAI enabled:
1helm install mw-agent middleware-labs/mw-kube-agent-v3 \
2 --set global.mw.apiKey=<MW_API_KEY> \
3 --set global.mw.target=<MW_TARGET_URL> \
4 --set opsai.enabled=true \
5 --set global.clusterMetadata.name=<CLUSTER_NAME> \
6 --set mw-autoinstrumentation.enabled=true \
7 -n mw-agent-ns --create-namespaceReplace the placeholders with your Middleware API key, target URL, and Kubernetes cluster name.
Verify the agent installation:
1kubectl get daemonset/mw-kube-agent -n mw-agent-ns
2kubectl get deployment/mw-kube-agent -n mw-agent-nsOnce the agent starts collecting data, OpsAI can detect supported Kubernetes issues and investigate them using available telemetry.
For complete setup and upgrade instructions, see Install the Middleware Agent on Kubernetes.
Configure OpsAI for Applications#
To detect application issues, instrument your backend or frontend application using Middleware APM or RUM.
Backend Applications#
Install the appropriate Middleware APM SDK or enable supported auto-instrumentation.
Once traces and errors are collected, OpsAI can identify application issues and use trace and error context during investigations.
Frontend Applications#
Install the Middleware RUM SDK to collect frontend errors and application activity.
OpsAI can use the collected frontend telemetry to investigate supported application issues.
For installation instructions, see the Middleware APM documentation.
Connect Your Code Repository#
To generate source-code fixes and pull requests, connect your application repository to Middleware.
OpsAI supports repository access through GitHub or Bitbucket using the configured integration.
When investigating a code-related issue, OpsAI uses the relevant repository files alongside the error context to identify the likely cause and prepare a fix.
For accurate repository identification, configure the following environment variables in your application build environment:
1MW_VCS_REPOSITORY_URL=<your-repository-url>
2MW_VCS_COMMIT_SHA=<commit-sha>- MW_VCS_REPOSITORY_URL — Identifies the repository associated with the application.
- MW_VCS_COMMIT_SHA — Optional but recommended for identifying the relevant code revision.
Connecting a repository is not required to view detected issues or ask OpsAI questions, but it is needed for repository-based code fixes.
Enable Auto Investigation#
OpsAI supports two investigation modes:
| Mode | Behavior |
|---|---|
| Manual Investigation | You open an issue and ask OpsAI to investigate it |
| Auto Investigation | OpsAI automatically investigates supported newly detected issues within the configured scope |
To enable automatic investigation:
- Open the OpsAI Home screen or navigate to OpsAI Settings.
- Enable Auto Investigation.
- Configure the monitoring scope for the supported sources you want OpsAI to investigate.
- Save the configuration.
Depending on the source, you can control the scope using Kubernetes clusters, APM services, or RUM applications.
Once enabled, OpsAI automatically investigates supported issues and prepares root cause analysis and suggested solutions.
Note: Auto Investigation does not mean every proposed change is automatically deployed. Code changes are prepared for review, and Kubernetes remediation requires the appropriate permissions and supported fix actions.
Configure Notifications#
You can receive issue investigation results through configured notification channels, including email and Slack.
With Slack integration, OpsAI can share root cause analysis in the relevant alert thread.
You can also mention @Middleware in a supported Slack thread to ask follow-up questions about the investigation.
For more information, see OpsAI Settings.
Verify OpsAI Setup#
After installation:
- Confirm that Middleware is receiving infrastructure, Kubernetes, APM, or RUM telemetry.
- Open the Middleware Home screen.
- Review detected issues and ask for fix, if any are present.
OpsAI will display issues as supported problems are detected from the collected telemetry.
Privacy and Access#
For repository-based investigations, OpsAI retrieves only the source files relevant to the issue through the configured integration.
For Kubernetes remediation, write access must be explicitly granted before OpsAI can apply changes to Kubernetes resources.
This allows you to use OpsAI for investigation while controlling access to source code and infrastructure changes.
Next Steps#
Once OpsAI is configured, you can:
- Use Issue Detection to review problems across your monitored environment.
- Use Fix with OpsAI to investigate errors and generate solutions.
- Use Ask OpsAI to query telemetry and troubleshoot using natural language.
Need assistance or want to learn more about Middleware? Get in touch with us via our Contact Us or join our Slack channel.
What did you think of this content?