Get a metric

Get one metric of a source or an application, with the expressions to query it with.

GET https://telemetry.betterstack.com/api/v4/metrics/{id}

URL parameters

id
required string

Query parameters

source_id
string
application_id
string
team_id
string

Headers

Authorization
required string
200

Response body

{
  "data": {
    "id": "http_requests_total",
    "type": "source_metric",
    "attributes": {
      "name": "http_requests_total",
      "type": "float64",
      "origin": "ingested",
      "layout": "row-based",
      "aggregations": [
        "avg",
        "max",
        "min"
      ],
      "data_points": 182400,
      "active_series": 37,
      "sql_expression": null,
      "json_dot_notation": null,
      "query_examples": [
        "avgMergeIf(value_avg, name = 'http_requests_total')",
        "avgMergeIf(rate_avg, name = 'http_requests_total')   -- per-second rate, for counters"
      ],
      "labels": [
        "host",
        "method",
        "status"
      ]
    }
  }
}
401

Response body

{
  "errors": "Invalid Team API token. How to find your Team API token: https://betterstack.com/docs/logs/api/getting-started/#obtaining-a-logtail-api-token"
}
403
404
422

Response attributes

id
string
type
string
name
string
attributes.type
string
origin
string
layout
string
aggregations
array of strings
data_points
integer
active_series
integer
sql_expression
string or null
json_dot_notation
string or null
query_examples
array of strings
labels
array of strings or null

Example cURL

Get a metric
curl --request GET \
  --url "https://telemetry.betterstack.com/api/v4/metrics/http_requests_total?source_id=123456" \
  --header "Authorization: Bearer $TOKEN"