Use Better Stack with Codex and ChatGPT

The Better Stack plugin puts our AI SRE in Codex and ChatGPT, with its skills and every Better Stack tool. It's free on every Better Stack plan.

Connect Codex to Better Stack

ChatGPT

  1. Open Plugins in the sidebar and find Better Stack.
  2. Click + to install it.
  3. Connect Better Stack when asked and sign in with your Better Stack account.
  4. Start a new chat.

Codex CLI

Add the Better Stack marketplace and install the plugin:

Install the Better Stack plugin in Codex
codex plugin marketplace add BetterStackHQ/codex-plugin
codex plugin add betterstack@betterstack

Sign in with your Better Stack account in the browser that opens, then start a new Codex session:

Sign in to Better Stack
codex mcp login betterstack

Know when to roll back a deploy

When your service gets a new error or incident, ChatGPT checks whether your latest deploy caused it and tells you in the chat whether to roll back. This check is powered by MCP Events: the Better Stack MCP server sends ChatGPT each new error and incident as it happens. It works in ChatGPT on the web, not in the Codex CLI.

  1. Connect Better Stack in ChatGPT.
  2. Start a new chat and paste this prompt, with your service filled in:
Prompt to check every deploy
When <service> gets a new error or incident, check whether my
latest release caused it and tell me if I should roll back.

ChatGPT creates a task that runs on each new error or incident instead of on a schedule. Each run posts its verdict, such as "Roll back", with the evidence in the same chat.

Fix errors on a schedule with ChatGPT

Add a ChatGPT scheduled task that checks your errors in Better Stack every 4 hours and fixes the obvious ones with pull requests. It runs in the cloud, so it doesn't need ChatGPT open.

  1. Connect Better Stack in ChatGPT.
  2. Give ChatGPT's GitHub app, ChatGPT Codex Connector, read and write access to your repository's contents and pull requests.
  3. Switch to Work, start a new chat, and paste this prompt with your repository filled in:
Prompt to fix your errors on schedule
Set up a scheduled task that fixes new errors Better Stack catches
in the app of GitHub repository <owner>/<repo>. It has to run in
the cloud, so it keeps working while my computer is off.

- Name: Fix new Better Stack errors
- Schedule: every 4 hours
- Repository: <owner>/<repo>
- Prompt for each run:

  Fix the obvious new errors Better Stack caught in this
  repository's app.
  1. With the Better Stack tools, list the unresolved errors of
     this repository's Better Stack error tracking application
     seen in the last 4 hours, most occurrences first.
  2. Skip errors that already have an open pull request in this
     repository: look for the error's Better Stack link in the
     descriptions of open pull requests.
  3. Pick at most 3 errors whose root cause is in this
     repository's code and that a small, safe change fixes. Skip
     errors caused by outages, configuration or third-party
     services, and any fix you aren't confident about.
  4. Install the project's dependencies. For each error, start a
     new branch from the latest default branch, read the error's
     stack trace with the Better Stack tools, fix the root cause,
     add a test that fails without the fix, and run the tests.
  5. Push each fix and open a pull request. In the description,
     link the Better Stack error and say what caused it and how
     you tested the fix.
  6. End with one line per error you looked at: its pull request,
     or why you skipped it.

If you can use the Better Stack tools here, look up which error
tracking application this repository belongs to and name it in
the task's prompt. Otherwise ask me. Before you create the task,
check that you can push a branch and open a pull request in this
repository; if you can't, tell me exactly what to connect.

ChatGPT checks it can open pull requests in your repository, creates the task, and lists it under Scheduled. To try it right away, click Run now. Pull requests are opened from your GitHub account, and nothing is merged until you review it.

Need help?

Please let us know at hello@betterstack.com.
We're happy to help! 🙏