Create a metric for a source

Returns a newly created metric.

POST https://logs.betterstack.com/api/v2/sources/{source_id}/metrics

URL parameters

source_id
required integer

Headers

Authorization
required string

Body parameters

team_name
string
name
required string
sql_expression
required string
aggregations
array
type
required string
200

Response body

{
  "data": {
    "id": "g-123",
    "type": "metric",
    "attributes": {
      "name": "level",
      "sql_expression": "JSONExtract(json, 'level', 'Nullable(String)')",
      "aggregations": [

      ],
      "type": "string_low_cardinality"
    }
  }
}