Create a collector metric target

Creates a new monitoring target on a collector.

Each target kind accepts a specific set of connection fields. Sending a field that does not apply to the chosen kind (for example, ssl_mode on a redis target) will return a validation error.

POST https://telemetry.betterstack.com/api/v1/collectors/{collector_id}/targets

Headers

Authorization
required string

Body parameters

kind
required string
host
required string
port
integer
service
string
listen_ip
string
endpoint
string
username
string
password
string
api_key
string
ssl_mode
string
tls
string
scheme
string
enabled
boolean

Fields accepted per kind

Kind Required fields Optional fields
postgres host, port, ssl_mode username, password
mysql host, port, tls username, password
redis host, port username, password
mongodb host, port username, password
memcached host, port username, password
elasticsearch host, port username, password, api_key, scheme
nginx host, service port, listen_ip
apache host, service port, listen_ip
kafka host, service port, listen_ip
prometheus host, service, endpoint
201

Response body

{
  "data": {
    "id": "10",
    "type": "collector_target",
    "attributes": {
      "kind": "postgres",
      "host": "db.example.com",
      "port": 5432,
      "service": null,
      "listen_ip": null,
      "endpoint": null,
      "scheme": null,
      "username": "monitor",
      "ssl_mode": "require",
      "tls": null,
      "status": "pending",
      "enabled": true,
      "container": null,
      "detected_host": null,
      "autogenerated": false,
      "paused_until": null,
      "consecutive_failure_count": 0,
      "last_ping_at": null,
      "created_at": "2025-06-15T12:00:00.000Z",
      "updated_at": "2025-06-15T12:00:00.000Z"
    }
  }
}
422

Response body

{
  "errors": [
    "Ssl mode can't be blank"
  ],
  "invalid_attributes": [
    "ssl_mode"
  ]
}

Example: PostgreSQL target

cURL
curl -X POST "https://telemetry.betterstack.com/api/v1/collectors/1/targets" \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "kind": "postgres",
       "host": "db.example.com",
       "port": 5432,
       "username": "monitor",
       "password": "secret",
       "ssl_mode": "require"
     }'


Example: Elasticsearch target with API key

cURL
curl -X POST "https://telemetry.betterstack.com/api/v1/collectors/1/targets" \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "kind": "elasticsearch",
       "host": "es.example.com",
       "port": 9200,
       "scheme": "https",
       "api_key": "VnVhQ19fb29CT0hraHQyVEhhV0M6..."
     }'


Example: Nginx process target

cURL
curl -X POST "https://telemetry.betterstack.com/api/v1/collectors/1/targets" \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "kind": "nginx",
       "host": "collector-host-1",
       "service": "edge-nginx",
       "listen_ip": "10.0.0.1",
       "port": 80
     }'


Example: Prometheus target

cURL
curl -X POST "https://telemetry.betterstack.com/api/v1/collectors/1/targets" \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "kind": "prometheus",
       "host": "collector-host-1",
       "service": "my-app",
       "endpoint": "http://10.0.0.5:9090/metrics"
     }'


Example: Create disabled

cURL
curl -X POST "https://telemetry.betterstack.com/api/v1/collectors/1/targets" \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "kind": "redis",
       "host": "r.example.com",
       "port": 6379,
       "enabled": false
     }'