Skip to main content

Overview

OpenSRE uses MySQL diagnostics to investigate database-related alerts — checking server health, surfacing slow queries, monitoring replication status, and analyzing table statistics. Queries are wrapped as read-only.

Prerequisites

  • MySQL 5.7+ (8.0+ recommended for full performance_schema support)
  • Network access from the OpenSRE environment to your MySQL instance
  • A read-only user with access to information_schema and performance_schema

Setup

Option 1: Interactive CLI

Option 2: Environment variables

Option 3: Persistent store

Credentials

Creating a read-only user

Three notes on these grants, each confirmed against a real server:
  • information_schema needs no explicit grant — MySQL exposes it automatically based on a user’s other privileges. GRANT SELECT ON information_schema.* is rejected outright (ERROR 1044) and aborts the script before later grants run.
  • The grant on the target database (MYSQL_DATABASE) is required — the connector selects it as the default schema on connect, and without it every tool call fails with Access denied ... to database.
  • REPLICATION CLIENT is required for get_mysql_replication_status (SHOW REPLICA STATUS / SHOW SLAVE STATUS) — without it, that one tool returns an access-denied error even though integrations verify mysql and the other four tools pass.
performance_schema is enabled by default in MySQL 5.7+. Slow query data will not be available if it has been explicitly disabled in my.cnf.

Quick local test with Docker

Wait for it to become healthy, then create the read-only user and a table to inspect:
Verify:
opensre investigate only treats an integration as active once the store resolution has something to fall through to env vars with — an untouched ~/.opensre/integrations.json with an unrelated integration in it blocks env-var fallback entirely. Point OPENSRE_INTEGRATIONS_STORE_PATH at an empty, valid store instead, so your real config is never read or written and the exported MYSQL_* vars above are the only source of credentials:
A literal zero-byte file does not work here — the store loader expects valid JSON and raises on an empty read, so this writes an explicitly empty (but valid) store rather than just creating the file with mktemp alone. Kick off a long-running query so there is something real to investigate, then trigger a real investigation — this is the actual supported entrypoint, not an internal import:
Real output from a run against this exact local instance (edited for length). An empty store makes opensre investigate fall through to env-var resolution for every integration, not just MySQL — if your shell or machine already resolves another integration from its own env vars, it rides along too (harmless; it just means extra unrelated tool availability, not incorrect MySQL results). Here telegram appears because this environment happens to resolve it:
All 5 registered tools were exercised in this single turn, and the agent correctly identified the exact synthetic probe query. Teardown — remove the demo store file and unset every demo variable, so nothing lingers in the shell to affect a later command:

Investigation tools

Verify

Expected output:

Troubleshooting

Security

  • Use a dedicated read-only user — avoid root credentials.
  • Prefer MYSQL_SSL_MODE=required in production.
  • Restrict the user to specific hosts rather than '%' where possible.
  • Store credentials in .env or your secret manager — not in source control.