Create a time series

Creates a new computed time series for a Warehouse source.

POST https://warehouse.betterstack.com/api/v1/sources/{source_id}/time_series

URL parameters

source_id
required string

Headers

Authorization
required string
Content-Type
required string

Body parameters

name
required string
type
required string
sql_expression
required string
aggregations
array
expression_index
string
vector_dimension
integer
vector_distance_function
string
201

Response body

{
  "data": {
    "id": "5215107",
    "type": "time_series",
    "attributes": {
      "name": "level",
      "sql_expression": "JSONExtract(raw, 'level', 'Nullable(String)')",
      "aggregations": [],
      "type": "string_low_cardinality",
      "expression_index": null
    }
  }
}
401

Response body

{
  "errors": "Invalid authentication"
}
404

Response body

{
  "errors": "Source with the provided ID was not found"
}
422

Response body

{
  "errors": "Validation errors",
  "invalid_values": {
    "name": [
      "name must only contain letters, numbers, and underscores"
    ],
    "type": [
      "type must be one of string, string_low_cardinality, int64_delta, int64, uint64_delta, uint64, float64_delta, datetime64_delta, boolean, array_bfloat16, array_float32"
    ],
    "sql_expression": [
      "sql_expression is invalid"
    ]
  }
}

Example cURL

Example
curl --request POST \
  --url https://warehouse.betterstack.com/api/v1/sources/12345/time_series \
  --header "Authorization: Bearer $TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "response_time_avg",
    "type": "float64_delta",
    "sql_expression": "JSONExtract(raw, 'response_time', 'Nullable(Float64)')",
    "aggregations": ["avg", "min", "max"]
  }'