데이터베이스 통계 조회
데이터베이스의 상위 쿼리와 읽기·쓰기 행 수를 조회하는 API예요.
출처: 문서
본문
요청 예시:
curl -L -X GET 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases/{databaseName}/stats' \
-H 'Authorization: Bearer ***'
OpenAPI
openapi: 3.0.1
info:
title: Turso Platform API
description: API description here
license:
name: MIT
version: 0.1.0
servers:
- url: https://api.turso.tech
description: Turso's Platform API
security: []
paths:
/v1/organizations/{organizationSlug}/databases/{databaseName}/stats:
get:
summary: Retrieve Database Stats
description: >-
Fetch the top queries of a database, including the count of rows read
and written.
operationId: getDatabaseStats
parameters:
- $ref: '#/components/parameters/organizationSlug'
- $ref: '#/components/parameters/databaseName'
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
top_queries:
type: array
description: >-
The top queries performed on the given database as well as
the total rows read and written.
nullable: true
items:
$ref: '#/components/schemas/DatabaseStatsOutput'
'404':
$ref: '#/components/responses/DatabaseNotFoundResponse'
components:
parameters:
organizationSlug:
in: path
name: organizationSlug
required: true
schema:
type: string
description: The slug of the organization or user account.
databaseName:
name: databaseName
in: path
required: true
schema:
type: string
description: The name of the database.
schemas:
DatabaseStatsOutput:
type: object
properties:
query:
type: string
description: A string representing the SQL query executed.
example: >-
SELECT COUNT(*), CustomerID FROM Orders GROUP BY CustomerID HAVING
COUNT(*) > 5;
rows_read:
type: integer
description: >-
An integer indicating the number of rows read by the query, which
reflects the volume of data the query processed from the database.
example: 123
rows_written:
type: integer
description: >-
An integer indicating the number of rows written (inserted, updated,
or deleted) by the query, which reflects the impact of the query on
the database data.
example: 4567
responses:
DatabaseNotFoundResponse:
description: Database not found
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: The error message
example: >-
could not find database with name [databaseName]: record not
found