Telemetry.CollectorTarget
A database or process a Collector scrapes for metrics: Postgres,
PgBouncer, MySQL, Redis, MongoDB, Memcached, Elasticsearch, nginx,
Apache, Kafka, Traefik or a Prometheus endpoint (kind).
password and apiKey are Redacted and never returned: changes are
detected against the previous deploy’s props. Removing password,
apiKey, username, port or listenIp from the config clears it.
collectorId and kind replace the target when changed. An update to a
connection setting sets status back to pending until the collector
checks the target again.
Scraping a database
Section titled “Scraping a database”A Postgres target with credentials
const collector = yield* BetterStack.Telemetry.Collector("db-hosts", { platform: "docker" });yield* BetterStack.Telemetry.CollectorTarget("orders-db", { collectorId: collector.id, kind: "postgres", host: "orders-db.internal", port: 5432, username: "metrics", password: Redacted.make(process.env.ORDERS_DB_METRICS_PASSWORD ?? ""), sslMode: "require",});Scraping a Prometheus endpoint
Section titled “Scraping a Prometheus endpoint”A service’s /metrics
yield* BetterStack.Telemetry.CollectorTarget("api-metrics", { collectorId: collector.id, kind: "prometheus", host: "api.internal", service: "api", endpoint: "http://api.internal:9090/metrics",});collectorId string required
host string required
Target host. For a process target such as nginx or prometheus, the host the collector runs on.
kind "postgres" | "pgbouncer" | "mysql" | "redis" | "mongodb" | "memcached" | "elasticsearch" | "nginx" | "apache" | "kafka" | "prometheus" | "traefik" | string required
Target type. Responses can also hold pgcat, node_exporter and kube_state_metrics, targets the collector finds by itself. You can't create those. Can't be changed after the target is created.
apiKey string | Redacted<string> | null
API key for elasticsearch targets.
enabled boolean
Whether the collector scrapes this target. A new target is enabled unless it's set to false. Disabling it sets status to disabled, and enabling it again checks the target again.
endpoint string
The full scrape URL, like http://10.0.0.5:9090/metrics. Required for prometheus targets and returned only for them.
listenIp string | null
The IP address the process listens on. Accepted and returned only for nginx, apache, kafka and traefik, and null when not set.
password string | Redacted<string> | null
Password for database and elasticsearch targets.
port number | null
The target's port. null when a target is found by its listen_ip or service instead. Required for database kinds and accepted for nginx, apache, kafka and traefik.
scheme "http" | "https" | string
The connection scheme. Accepted and returned only for elasticsearch. Defaults to http.
service string
The service name. Required for nginx, apache, kafka, prometheus and traefik targets, and accepted and returned only for those.
sslMode "disable" | "require" | "verify-ca" | string
The SSL mode for the connection. Required for postgres and pgbouncer, and accepted and returned only for those.
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.
tls "false" | "true" | "skip-verify" | "preferred" | string
The TLS mode for the connection. Required for mysql, and accepted and returned only for it.
username string | null
The username for the connection, or null when not set. While Kubernetes annotations control the target, the collector gets the username as annotations shows instead. Accepted and returned only for postgres, pgbouncer, mysql, redis, mongodb, memcached and elasticsearch.
Attributes
Section titled “Attributes”collectorId string always set
The collector that scrapes the target.
id string always set
The collector_target's id.
annotations CollectorTargetAnnotations | null
Where the collector gets the target's credentials and connection settings while Kubernetes annotations control the target, or null when no annotations control it. While annotations control a target, the collector ignores the credentials and connection settings stored on the target. The target's username, ssl_mode, tls and scheme keep the values you stored.
container string | null
Detected container.
createdAt string
When the target was created.
enabled boolean
Whether the collector scrapes this target. A new target is enabled unless it's set to false. Disabling it sets status to disabled, and enabling it again checks the target again.
endpoint string
The full scrape URL, like http://10.0.0.5:9090/metrics. Required for prometheus targets and returned only for them.
host string
Target host. For a process target such as nginx or prometheus, the host the collector runs on.
kind "postgres" | "pgbouncer" | "mysql" | "redis" | "mongodb" | "memcached" | "elasticsearch" | "nginx" | "apache" | "kafka" | "prometheus" | "traefik"
Target type. Responses can also hold pgcat, node_exporter and kube_state_metrics, targets the collector finds by itself. You can't create those.
listenIp string | null
The IP address the process listens on. Accepted and returned only for nginx, apache, kafka and traefik, and null when not set.
port number | null
The target's port. null when a target is found by its listen_ip or service instead.
scheme "http" | "https"
The connection scheme. Accepted and returned only for elasticsearch.
service string
The service name. Required for nginx, apache, kafka, prometheus and traefik targets, and accepted and returned only for those.
sslMode "disable" | "require" | "verify-ca"
The SSL mode for the connection. Required for postgres and pgbouncer, and accepted and returned only for those.
status "disabled" | "pending" | "up" | "down" | "unreachable" | "invalid_credentials" | "configuration_required" | "removed"
The connection status. An update that includes host, port, service, listen_ip, endpoint, scheme, username, password, api_key, ssl_mode or tls sets it back to pending.
teamId string
Team that owns the collector's source, such as t123.
tls "false" | "true" | "skip-verify" | "preferred"
The TLS mode for the connection. Required for mysql, and accepted and returned only for it.
updatedAt string
When the target was last updated.
username string | null
The username for the connection, or null when not set. While Kubernetes annotations control the target, the collector gets the username as annotations shows instead. Accepted and returned only for postgres, pgbouncer, mysql, redis, mongodb, memcached and elasticsearch.
Lookup
Section titled “Lookup”CollectorTarget.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.
collectorId string required
The collector it belongs to.
id string required
The target's id.
teamId string
Team that owns the collector, such as t123. Defaults to the credentials' team.