Telemetry.Collector
A Better Stack Collector: the agent you run on a host (docker), a Docker
Swarm (swarm) or a Kubernetes cluster (kubernetes) that collects logs,
metrics and traces — with eBPF when enabled — and sends them to its own
source (sourceId). Deploy it with its secret (a Redacted value),
following installationGuideUrl; add scrape targets with
CollectorTarget.
name defaults to a generated unique name. platform, dataRegion and
teamId replace the collector when changed. connectedSourceIds and
serviceFields can only be set by an update, so they are applied right
after create. connectedSourceIds is compared against the previous
deploy, and a change sends the whole list (see Source). Removing
note, a transformation, sourceGroupId or userVectorConfig from the
config clears it. configuration changes only the components you send.
customBucket is set on create; afterwards only its key pair can be
rotated (any other change, null included, fails with
CustomBucketImmutable; leaving it out sends nothing).
Creating a collector
Section titled “Creating a collector”A Docker host with host metrics and container logs
const collector = yield* BetterStack.Telemetry.Collector("hosts", { platform: "docker", note: "Production hosts", configuration: { components: { logsDocker: true, metricsHostOs: true, ebpfMetrics: false }, logsSampleRate: 50, },});Installing it
Section titled “Installing it”The secret is what the installer authenticates with; hand it to the
install step as a secret, never as plain text.
The values an install step needs
const install = { COLLECTOR_SECRET: collector.secret, guide: collector.installationGuideUrl,};platform "docker" | "swarm" | "kubernetes" | string required
Where the collector runs. Can't be changed after the collector is created.
blockedMetrics string[]
Metric names marked as spam, which are dropped when they're ingested. Read more about marking metrics as spam.
collectorLogsTransformation string | null
VRL program the collector runs on each log line on your hardware, before sending it to Better Stack. Send null to remove it.
collectorMetricsTransformation string | null
VRL program the collector runs on each metric on your hardware, before sending it to Better Stack. Send null to remove it.
collectorTracesTransformation string | null
VRL program the collector runs on each span on your hardware, before sending it to Better Stack. Send null to remove it.
configuration CreateCollectorRequestConfiguration
The collector's components, sampling rates, batching and buffering. An update changes only the components you send.
connectedSourceIds string[]
IDs of the sources connected to the collector's source, so you can correlate their logs and traces. Connections go both ways. The collector's source is connected to each listed source and to every source those are already connected to. Sending a list adds connections without removing any. Send [] to disconnect the collector's source from all of them.
customBucket CreateCollectorRequestCustomBucket | null
Your own S3-compatible bucket to archive data in, or null when the collector uses Better Stack storage. Read more about hosting data in your own bucket. Set it on create. To rotate the key pair, update only access_key_id and secret_access_key.
dataRegion string
The data region, europe, us, singapore or a dedicated cluster's name from List data regions. Can't be changed after the collector is created. Defaults to the organization's default data region.
ingestingPaused boolean
Whether ingestion is paused for this collector.
ingestionLogsTransformation string | null
VRL program Better Stack runs on each log line from the collector as it's ingested. Send null to remove it.
ingestionTracesTransformation string | null
VRL program Better Stack runs on each span from the collector as it's ingested. Send null to remove it.
liveTailPattern string | null
The pattern Live tail shows each log line with. Columns are wrapped in braces, such as PID: {message_json.pid} {level} {message}. null when the collector's source doesn't receive logs. See Formatting logs. Send null to restore the default format. Refused when the collector's source doesn't receive logs.
liveTailPatternSpans string | null
The pattern Live tail shows each span with. Columns are wrapped in braces, such as {span.name} {duration}. null when the collector's source doesn't receive spans. See Formatting logs. Send null to restore the default format. Refused when the collector's source doesn't receive spans.
logsRetention number
Days logs are kept, one of the retention periods your plan offers.
metricsRetention number
Days metrics are kept, one of the retention periods your plan offers.
name string
Collector name. Defaults to a unique name generated from the stack, stage and logical id.
note string | null
A note about the collector. Send null to clear it.
serviceFields CollectorServiceFieldsItem[]
Log fields that break data down by service. Each entry needs a name_key, and type_key can be null to skip it. The list replaces the existing one, and [] removes them all.
sourceGroupId string | null
Source group the collector's source belongs to, or null when it's in no group. Get the IDs via List source groups.
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.
userVectorConfig string | null
Your own Vector configuration in YAML, merged into the configuration the collector runs with.
Attributes
Section titled “Attributes”id string always set
The collector's id.
blockedMetrics string[]
Metric names marked as spam, which are dropped when they're ingested. Read more about marking metrics as spam.
collectorLogsTransformation string | null
VRL program the collector runs on each log line on your hardware, before sending it to Better Stack.
collectorMetricsTransformation string | null
VRL program the collector runs on each metric on your hardware, before sending it to Better Stack.
collectorTracesTransformation string | null
VRL program the collector runs on each span on your hardware, before sending it to Better Stack.
configuration CollectorConfiguration
The collector's components, sampling rates, batching and buffering. An update changes only the components you send.
connectedSourceIds string[]
IDs of the sources connected to the collector's source, so you can correlate their logs and traces. Connections go both ways. The collector's source is connected to each listed source and to every source those are already connected to. Sending a list adds connections without removing any. Send [] to disconnect the collector's source from all of them.
createdAt string
When the collector was created.
customBucket CollectorCustomBucket | null
Your own S3-compatible bucket to archive data in, or null when the collector uses Better Stack storage. Read more about hosting data in your own bucket. Set it on create. To rotate the key pair, update only access_key_id and secret_access_key.
dataRegion string
The data region, europe, us, singapore or a dedicated cluster's name from List data regions.
ingestingPaused boolean
Whether ingestion is paused for this collector.
ingestionLogsTransformation string | null
VRL program Better Stack runs on each log line from the collector as it's ingested.
ingestionTracesTransformation string | null
VRL program Better Stack runs on each span from the collector as it's ingested.
installationGuideUrl string
Link to the installation guide for the collector's platform, with the install command that uses its secret.
liveTailPattern string | null
The pattern Live tail shows each log line with. Columns are wrapped in braces, such as PID: {message_json.pid} {level} {message}. null when the collector's source doesn't receive logs. See Formatting logs.
liveTailPatternSpans string | null
The pattern Live tail shows each span with. Columns are wrapped in braces, such as {span.name} {duration}. null when the collector's source doesn't receive spans. See Formatting logs.
logsRetention number
Days logs are kept, one of the retention periods your plan offers.
metricsRetention number
Days metrics are kept, one of the retention periods your plan offers.
name string
Collector name.
note string | null
A note about the collector.
pingedAt string | null
When a host of the collector last checked in, or null when no host has checked in yet.
platform "docker" | "swarm" | "kubernetes"
Where the collector runs.
secret string | Redacted<string>
Secret the deployed collector authenticates with. Returned in every response.
serviceFields CollectorServiceFieldsItem[]
Log fields that break data down by service. Each entry needs a name_key, and type_key can be null to skip it. The list replaces the existing one, and [] removes them all.
sourceGroupId string | null
Source group the collector's source belongs to, or null when it's in no group. Get the IDs via List source groups.
sourceId string | null
ID of the source the collector sends data to.
status string
The collector's status, worked out from its hosts, one of pending, up, degraded, unknown, partially_up, unsupported_version or down.
teamId string
Team that owns the collector, such as t123.
teamName string
Name of the team that owns the collector.
updatedAt string
When the collector was last updated.
userVectorConfig string | null
Your own Vector configuration in YAML, merged into the configuration the collector runs with.
Lookup
Section titled “Lookup”Collector.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.
teamId string
Team that owns it, such as t123. Defaults to the credentials' team.