Update a metric

Updates an existing metric. At least one of name, sql_expression, type, or aggregations must be provided.

PATCH https://telemetry.betterstack.com/api/v2/sources/{source_id}/metrics/{id}

URL parameters

source_id
required integer
id
required string

Headers

Authorization
required string

Body parameters

name
string
sql_expression
string
aggregations
array
type
string
build_type
string
200

Response body

{
  "data": {
    "id": "g-123",
    "type": "metric",
    "attributes": {
      "name": "level",
      "sql_expression": "JSONExtract(raw, 'level', 'Nullable(String)')",
      "aggregations": [],
      "type": "string_low_cardinality"
    }
  }
}
404

Response body

{
  "errors": "Resource with provided ID was not found"
}

Example cURL

Example
curl --request PATCH \
  --url https://telemetry.betterstack.com/api/v2/sources/123/metrics/g-456 \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "name": "log_type"
  }'