Skip to content
betterstack-alchemyUnofficial

Telemetry.Connection

Kind ResourceType id BetterStack.Telemetry.ConnectionSource src/Telemetry/Connection.tsLive test available A live lifecycle test exists: it runs against the offline mock by default and against the real API under bun run test:live. This records that the test exists, not a dated live run (see Compatibility). Test file: test/Telemetry/Connection.test.ts.

A connection for querying ingested data directly: ClickHouse over HTTP (clientType: "clickhouse", reaching every cluster its teams store data on unless cluster names one), or a Grafana data source (clientType: "grafana", which needs cluster, a Source’s cluster). teamIds are the teams whose data it reaches.

The API has no update: every change replaces the connection, which issues new credentials. The password (and the sampleQuery that contains it) is returned only when the connection is created, so the attributes keep the values from create; a looked-up connection has none.

Without validUntil the credential expires one hour after it’s created and the connection disappears. An unchanged deploy does not notice (it does not read the API); alchemy drift --repair creates a new one. Pass validUntil: null for one that never expires (adding it later replaces the connection), or a timestamp. Creating connections needs a global API token (not a team-scoped Telemetry token).

A connection that never expires, from one office

const sql = yield* BetterStack.Telemetry.Connection("analytics", {
clientType: "clickhouse",
teamIds: ["t123"],
ipAllowlist: ["203.0.113.0/24"],
validUntil: null,
note: "Analytics notebooks",
});
const clickhouse = {
CLICKHOUSE_HOST: sql.host,
CLICKHOUSE_USER: sql.username,
CLICKHOUSE_PASSWORD: sql.password,
};

A Grafana data source for one source’s cluster

const app = yield* BetterStack.Telemetry.Source("app", { platform: "http" });
yield* BetterStack.Telemetry.Connection("grafana", {
clientType: "grafana",
cluster: app.cluster,
teamIds: ["t123"],
validUntil: null,
});

clientType "clickhouse" | "grafana" | string required

Client protocol.

teamIds string[] required

Teams whose data this connection reaches, as t-prefixed team IDs such as t123. Get the IDs via List teams.

cluster string | null

The one cluster the connection points at, by its name. Get a source returns the cluster its data is stored on. Required for a Grafana connection. A ClickHouse connection that names one reaches only that cluster. Leave it out for a ClickHouse connection that reaches every cluster where its teams store data. cluster is then null.

ipAllowlist string[]

Allowed source IPs or CIDRs.

note string | null

Free-form note.

teamId string

Team that owns the resource, such as t123. Defaults to the credentials' team (BETTERSTACK_TEAM_ID, or the profile's team). Changing it replaces the resource.

validUntil string | null

When the credential expires, or null if it never does. If you leave it out, the credential expires one hour after it's created.

id string always set

The connection's id.

clientType "clickhouse" | "grafana"

Client protocol.

cluster string | null

The one cluster the connection points at, by its name. Get a source returns the cluster its data is stored on.

clusters ConnectionClustersItem[]

Every cluster the connection reaches.

createdAt string

When the connection was created.

createdBy ConnectionCreatedBy | null

User who created the connection in the web UI. Always null for a connection created through the API or MCP.

dataSources ConnectionDataSourcesItem[]

Sources this connection can query. Not returned when listing connections.

host string | null

Connection host.

ipAllowlist string[]

Allowed source IPs or CIDRs.

note string | null

Free-form note.

password string | Redacted<string>

Connection password. Returned only when the connection is created and never again, so save it then.

port number

Connection port.

sampleQuery string | Redacted<string>

An example curl query to get started. When you create the connection, the query includes the password. Later responses show INSERT_PASSWORD in its place. Not returned when listing connections.

teamId string

The team the connection was created in, when the props named one.

teamIds string[]

Teams whose data this connection reaches, as t-prefixed team IDs such as t123. Get the IDs via List teams.

teamNames string[]

Names of the teams whose data this connection reaches.

username string

The username to connect with.

validUntil string | null

When the credential expires, or null if it never does.

Connection.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.

id string required

The connection's id.

teamId string

Team to look in, such as t123. Defaults to the credentials' team.