Database Logs API
This page is part of MariaDB's Documentation.
The parent of this page is: Observability API
Topics on this page:
Overview
The Database Logs API enables secure retrieval of log data stored in the Log Archive.
The Database Logs API is accessed by REST client.
The Database Logs API is part of the Observability API.
Authentication
Generate an API Key
Before using the Logs API, a SkySQL API Key must be generated. The SkySQL API Key must have the Observability API: Read key scope.
For additional information, see "Generate a SkySQL API Key".
Obtain a Bearer Token
The SkySQL API Key is not used directly with the Logs API. Instead, the SkySQL API Key is used to request a short-lived bearer token from MariaDB ID, and the short-lived bearer token is used with the Logs API.
For example, to request a bearer token using cURL with the output piped to jq
for readability:
$ curl --location --request POST \
--header 'Authorization: Token SKYSQL_API_KEY' \
--header 'Content-length: 0' \
https://id.mariadb.com/api/v1/token/ \
| jq .
For additional information, see "Request a Bearer Token".
Make API calls
When making API calls, the short-lived bearer token must be provided in a header using the format Authorization: Bearer SKYSQL_BEARER_TOKEN
, where SKYSQL_BEARER_TOKEN
is the short-lived bearer token.
For example, to call the Log List endpoint using cURL:
$ curl --location --request GET \
--header "Authorization: Bearer SKYSQL_BEARER_TOKEN" \
'https://api.mariadb.com/observability/v1/logs'
Supported Log Types
The following log types are supported by the Database Logs API.
See log-specific documentation for details on log format and steps to configure logging.
Log Type | Description |
---|---|
| |
| |
| |
|
List Servers with Logs
Detail | Description |
---|---|
Endpoint | https://api.mariadb.com/observability/v1/logs/servers
|
Method |
|
Behavior |
|
Parameters |
|
Response Code |
|
Sample Request | https://api.mariadb.com/observability/v1/logs/servers?logType=error-log,slow-query-log&fromDate=2022-05-31T21:00:00.000Z&toDate=2022-07-31T21:00:00.000Z
|
Command-Line Example | $ curl --location --request GET \
--header "Authorization: Bearer SKYSQL_BEARER_TOKEN" \
'https://api.mariadb.com/observability/v1/logs/servers?logType=error-log,slow-query-log&fromDate=2022-05-31T21:00:00.000Z&toDate=2022-07-31T21:00:00.000Z' \
| jq .
|
Sample Response | {
"servers": [
{
"service": "cs",
"server": "cs-node-1",
"serverDataSourceId": "db00012334/cs-node-1"
}
]
}
|
List Logs
Detail | Description |
---|---|
Endpoint | https://api.mariadb.com/observability/v1/logs
|
Method |
|
Behavior |
|
Parameters |
|
Response Code |
|
Sample Request | https://api.mariadb.com/observability/v1/logs?limit=20&offset=0&fromDate=2021-07-16T01:16:18Z&toDate=2021-08-16T01:16:18Z&serverContext=db00012334/cs-node-1
|
Command-Line Example | $ curl --location --request GET \
--header "Authorization: Bearer SKYSQL_BEARER_TOKEN" \
'https://api.mariadb.com/observability/v1/logs?limit=20&offset=0&fromDate=2021-07-16T01:16:18Z&toDate=2021-08-16T01:16:18Z&serverContext=db00012334/cs-node-1' \
| jq .
|
Sample Response | {
"count": 2,
"logs": [
{
"id": "eda604f7c5160b14d3223d5ae7737964d6efad66fe635d1509a4b7331f3ab838",
"name": "error-log_2022-07-30.log",
"logType": "error-log",
"service": "cs",
"server": "cs-node-1",
"serverDataSourceId": "db00012334/cs-node-1",
"size": 18788,
"startTime": "2022-07-30T00:00:00Z",
"endTime": "2022-07-30T23:59:59Z"
},
{
"id": "ee310a1c7f5c684f1c85f78648c898a7b8f28757901db93ab93e4455c5fd7d3f",
"name": "error-log_2022-07-22.log",
"logType": "error-log",
"service": "cs",
"server": "cs-node-1",
"serverDataSourceId": "db00012334/cs-node-1",
"size": 18950,
"startTime": "2022-07-22T00:00:00Z",
"endTime": "2022-07-22T23:59:59Z"
}
]
}
|
Download a Log Archive
Detail | Description |
---|---|
Endpoint | https://api.mariadb.com/observability/v1/logs/archive
|
Method |
|
Behavior |
|
Parameters |
|
Response Code |
|
Sample Request | https://api.mariadb.com/observability/v1/logs/archive?logsIds=eda604f7c5160b14d3223d5ae7737964d6efad66fe635d1509a4b7331f3ab838,iee310a1c7f5c684f1c85f78648c898a7b8f28757901db93ab93e4455c5fd7d3f&logFormat=raw,json
|
Command-Line Example | $ curl --location --request GET \
--header "Authorization: Bearer SKYSQL_BEARER_TOKEN" \
-o archive_file.zip \
'https://api.mariadb.com/observability/v1/logs/archive?logsIds=eda604f7c5160b14d3223d5ae7737964d6efad66fe635d1509a4b7331f3ab838,iee310a1c7f5c684f1c85f78648c898a7b8f28757901db93ab93e4455c5fd7d3f&logFormat=raw,json'
|
Sample Response | Binary data in the form of a .zip archive containing the requested logs. |