List log patterns

List the patterns of a source's logs in a time range, most frequent first. Returns every pattern in one page. A source with no logs in the time range returns an empty list.

GET https://telemetry.betterstack.com/api/v4/sources/{source_id}/log-patterns

URL parameters

source_id
required string

Query parameters

start_time
string
end_time
string
limit
DEFAULT 30 integer
step
string
level
DEFAULT all string
service
string
team_id
string

Headers

Authorization
required string
200

Response body

{
  "data": [
    {
      "id": "cb97bef4cd1cbd14afe4a7b9aa7b74a2",
      "type": "log_pattern",
      "attributes": {
        "message": "Timeout after 500ms while calling payments",
        "occurrences": 3588,
        "first_seen_at": "2026-11-22T16:04:00Z",
        "last_seen_at": "2026-11-22T17:03:56Z",
        "samples": [
          {
            "time": "2026-11-22T16:00:00Z",
            "count": 1204
          },
          {
            "time": "2026-11-22T16:05:00Z",
            "count": 1187
          }
        ],
        "logs": [
          {
            "dt": "2026-11-22T17:03:56Z",
            "level": "error",
            "message": "Timeout after 500ms while calling payments"
          }
        ]
      }
    }
  ]
}
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

Response body

{
  "errors": "You don't have permission to view live tail in this team. Your Better Stack role restricts this action. Ask an organization admin to update your role's permissions."
}
404

Response body

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

Response body

{
  "errors": "Sorry, some values are incorrect",
  "invalid_values": {
    "level": "level must be one of error, warn, info, debug, all."
  }
}
422

Response attributes

id
string
type
string
message
string or null
occurrences
integer
first_seen_at
datetime
last_seen_at
datetime
samples
array of objects
samples[].time
datetime
samples[].count
integer
logs
array of objects
logs[].dt
datetime
logs[].level
string or null
logs[].message
string or null

Example cURL

Errors of one service Errors over time
curl --request GET \
  --url "https://telemetry.betterstack.com/api/v4/sources/123456/log-patterns?start_time=now-6h&level=error&service=checkout" \
  --header "Authorization: Bearer $TOKEN"
curl --request GET \
  --url "https://telemetry.betterstack.com/api/v4/sources/123456/log-patterns?start_time=now-6h&level=error&step=15m" \
  --header "Authorization: Bearer $TOKEN"