Count Observability logs by field
Count logs matching a Logs explorer query, grouped by service, index, severity or an attribute key (@http.status_code). Answers questions like “errors per service in the last 6h” (filter[query]=severity:error, filter[from]=now-6h, group_by=service). Values are ordered by count, largest first; meta.total counts every matching log, and each value’s logs_query drills into its rows with GET /v1/observability/logs (null for a blank value, which the query syntax cannot select, or when the drill-down would exceed the query limits: 512 characters or 20 clauses). A log can carry an attribute key more than once (log, resource and scope attributes), so attribute counts can add up to more than meta.total; when logs match but none have the attribute, data is empty and meta.warnings has code attribute_missing. Requires a personal or Global API key (Team API Keys are group-scoped and get 403 unsupported_api_key) or an OAuth token with the obs.logs:read (or all) scope, and the Observability logs read permission. A Global API key uses its service user’s Observability role, which starts as the team’s default Observability role. Limited to 60 requests per minute per token; on this endpoint the X-RateLimit-* headers report that per-minute budget, not the default API limit. Every 429 returns the errors envelope with code rate_limited and a Retry-After header.
Authorizations
Query Parameters
Field to group by: service, index, severity, or @ followed by an attribute key (e.g. @http.status_code). Defaults to service. Secret-shaped attribute keys (password, token, auth, cookie, session, ...) are rejected with invalid_parameter. Secret-shaped values are returned redacted with logs_query: null.