Collectors
A Collector is the agent you run on a host
(docker), a Docker Swarm (swarm) or a Kubernetes cluster (kubernetes). It
collects logs, metrics and traces, with eBPF when enabled, and sends them to its
own source. You declare the collector here; you install the agent yourself, with
the collector’s secret.
Create a collector
Section titled “Create 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, },});platform, dataRegion and teamId replace the collector when changed.
configuration changes only the components you send.
Install the agent
Section titled “Install the agent”The secret is what the installer authenticates with. It is Redacted; hand it
to your install step as a secret, and follow installationGuideUrl:
return { collectorSecret: collector.secret, installationGuide: collector.installationGuideUrl,};Scrape a database
Section titled “Scrape a database”A CollectorTarget is something the
collector scrapes for metrics: Postgres, PgBouncer, MySQL, Redis, MongoDB,
Memcached, Elasticsearch, nginx, Apache, Kafka, Traefik, or a Prometheus
endpoint (kind):
yield* BetterStack.Telemetry.CollectorTarget("orders-db", { collectorId: collector.id, kind: "postgres", host: "orders-db.internal", port: 5432, username: "metrics", password: yield* Config.Redacted("ORDERS_DB_METRICS_PASSWORD"), sslMode: "require",});password and apiKey are never returned, so changes are detected against your
previous deploy. A change to a connection setting sets the target’s status
back to pending until the collector checks it again.
Scrape a Prometheus endpoint
Section titled “Scrape a Prometheus endpoint”yield* BetterStack.Telemetry.CollectorTarget("api-metrics", { collectorId: collector.id, kind: "prometheus", host: "api.internal", service: "api", endpoint: "http://api.internal:9090/metrics",});Where next
Section titled “Where next”- Sources & ingest: sending data without an agent.
- Reference:
Collector,CollectorTarget. - Better Stack: Collector.