Skip to content
Menu

Data-source connectors

View .md

A connector teaches Beacon one kind of data source. Register the ones you need on the AddBeaconServices(...) builder, before UsePostgreSql() / UseSqlServer():

using Beacon.Connector.PostgreSql;
using Beacon.Connector.SqlServer;
builder.Services.AddBeaconServices(builder.Configuration, options => { /* … */ })
.AddPostgreSqlConnector()
.AddSqlServerConnector()
.UsePostgreSql();
EnginePackageRegistration
PostgreSQLMoberg.Beacon.Connector.PostgreSql.AddPostgreSqlConnector()
SQL ServerMoberg.Beacon.Connector.SqlServer.AddSqlServerConnector()
MySQLMoberg.Beacon.Connector.MySql.AddMySqlConnector()
Azure SynapseMoberg.Beacon.Connector.AzureSynapse.AddAzureSynapseConnector()
SnowflakeMoberg.Beacon.Connector.Snowflake.AddSnowflakeConnector()
Google BigQueryMoberg.Beacon.Connector.BigQuery.AddBigQueryConnector()
DatabricksMoberg.Beacon.Connector.Databricks.AddDatabricksConnector()
AWS CloudWatch LogsMoberg.Beacon.Connector.CloudWatch.AddCloudWatchConnector()
REST API (OpenAPI)Moberg.Beacon.Connector.Api.AddApiConnector()

Only registered engines appear in New data source. Data sources themselves (connection details, metadata options, project links) are created in the UI by a DataSourceAdmin or an Admin, and their connection strings are encrypted with Beacon:EncryptionKey before they are stored. See Data sources.

EngineMetadata scanDatabase-level read-onlyRow cap stops the read earlyMigration write target
PostgreSQLYesYes: READ ONLY transaction, one statement per batchYesYes
MySQLYesYes: START TRANSACTION READ ONLY, batches offYesYes
SQL ServerYesNo: runs in a transaction that is always rolled backYesYes
Azure SynapseYesNoYesNo
SnowflakeYesNoYesNo
BigQueryNoNo: the connector’s own parser check plus a dry run whose statement type must be SELECTYes: stops reading the job’s resultNo
DatabricksNoNo: the connector’s own parser check and configured catalogYes: the statement is sent with row_limitNo
CloudWatchLog fieldsn/a (Logs Insights queries, no SQL)n/aNo
REST APIOpenAPI endpointsn/a (HTTP requests, no SQL)n/aNo

Every SQL engine goes through the same execution gate before anything runs: length and character checks, a guardrail, a dialect-aware AST validator, the cross-database rule, the refusal of the engine’s catalog, statistics and query history, a row cap written into the SQL and a statement timeout. Where the database cannot refuse a write itself, the data source shows a badge and Beacon logs a warning at startup and on save.

PostgreSQL

CREATE ROLE beacon_reader LOGIN PASSWORD '…';
GRANT CONNECT ON DATABASE shop TO beacon_reader;
GRANT USAGE ON SCHEMA public TO beacon_reader;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO beacon_reader;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO beacon_reader;
ALTER ROLE beacon_reader SET default_transaction_read_only = on;

SQL Server

CREATE LOGIN beacon_reader WITH PASSWORD = '…';
USE shop;
CREATE USER beacon_reader FOR LOGIN beacon_reader;
ALTER ROLE db_datareader ADD MEMBER beacon_reader;
DENY INSERT, UPDATE, DELETE, ALTER, EXECUTE TO beacon_reader;

MySQL

CREATE USER 'beacon_reader'@'%' IDENTIFIED BY '…';
GRANT SELECT, SHOW VIEW ON shop.* TO 'beacon_reader'@'%';

Snowflake, Synapse, BigQuery, Databricks: a role or service principal with read access to the objects Beacon should see, and nothing else (Snowflake: a role with USAGE + SELECT; BigQuery: BigQuery Data Viewer + BigQuery Job User on the project; Databricks: SELECT + USE CATALOG/USE SCHEMA through Unity Catalog).

EngineThe New data source dialog asks for
PostgreSQL, SQL Server, MySQL, Synapse, SnowflakeDatabase engine and connection string, plus metadata options: max tables, max columns per table, include and exclude schemas
DatabricksHost, HTTP path, personal access token; catalog and schema (optional)
BigQueryProject id, service-account JSON; dataset id and location (optional); MaximumBytesBilled and QueryTimeoutSeconds in the connection settings (optional)
CloudWatchAWS region, log groups; access key id, secret access key or AWS profile (optional)
REST APIBase URL, OpenAPI spec URL, authentication (API key in a header or parameter, bearer token, or basic), include and exclude path patterns

The last step of the dialog runs Test connection before Create data source.

  • BigQuery: every query job is sent with MaximumBytesBilled: the data source’s own value, or 10 GiB when it sets none, lowered by the deployment’s Beacon:DataSources:BigQuery:MaxBytesBilled when that is set. A job that would bill more fails without a charge. Set the per-source value (bytes) as MaximumBytesBilled in the connection JSON. A job still running when the timeout passes or the caller cancels is cancelled.
  • Databricks: the statement is submitted without waiting, so a caller’s cancellation or the timeout cancels it on the warehouse. Results are limited to 16 MiB (a larger one fails) and, on Beacon’s capped reads, to the row cap.
  • BigQuery, Databricks: a result read without a row cap fails above 10,000 rows instead of being cut short.
  • Snowflake: each statement also runs under the session’s STATEMENT_TIMEOUT_IN_SECONDS (Beacon:Query:StatementTimeoutSeconds), reset after the read; a session whose reset fails is closed without returning to the driver’s pool.
  • BigQuery, Databricks, CloudWatch: a stored QueryTimeoutSeconds above 900 seconds is treated as 900.
  • REST API: TimeoutSeconds is clamped to 1–120 seconds; one response may hold 10 MB; the OpenAPI description is fetched within 30 seconds and may hold 50 MB.

See Warehouse cost limits.

Queries may only name objects in the database (catalog, project) the data source is configured for: the gate refuses other databases, remote servers, files and dynamic SQL.

A query can have several steps on different data sources. Each step’s result is materialised (@result1, @result2, …) and a final query joins them in an in-memory SQLite database. Nothing is joined across engines at the database level, and the final query passes the same gate. See Queries.

Monitoring your own application’s database

Section titled “Monitoring your own application’s database”

To let Beacon (and MCP clients) read your application’s own EF Core model (with a table allow-list, column masking and a read-only connection string that is never stored) use ExposeDbContext<TContext>(...) instead of creating a data source by hand. See Extending Beacon.

CloudWatch data sources run Logs Insights queries, not SQL, so they cannot be queried through MCP query (the SQL gate has no dialect for them and refuses the statement). Beacon’s own CloudWatch features use the configured log groups only, so restrict the IAM role to them.

  • Connector registration also fills process-wide registries (engine → connection factory). Register connectors once, at startup.
  • The data-quality SQL generator supports PostgreSQL, SQL Server and MySQL.