Reference
Saved searches
The saved searches endpoints of the HTTP API.
GET /saved-searches
List the saved logs, trace and metrics searches the caller can view, most recently changed first.
Lists every saved search in the folders the caller can view, newest updated_at first. kind keeps only one kind of search, and folder_id keeps one folder; a folder the caller cannot view gives 404. Each item carries the folder it is saved in, what the caller may do with it in permissions, and the url of the logs, traces or metrics page that reopens it.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
kind |
query | "logs", "traces", "metrics" |
|
folder_id |
query | string (uuid) |
|
limit |
query | integer |
Between 1 and 100. Default 20. |
cursor |
query | string |
The next_cursor of the previous page. |
Responses
| Status | Description | Body |
|---|---|---|
200 |
One page of saved searches. | SavedSearchList |
400 |
The request is malformed or fails validation. | Error |
401 |
Authentication is missing or invalid. | Error |
404 |
The resource does not exist, or the caller cannot see it; the two are never told apart. | Error |
500 |
The server failed to handle the request. | Error |
POST /saved-searches
Save a logs, trace or metrics search in a folder.
Saves what the logs page, the trace view or the metrics page shows: the datasource, the query as it runs with its filter pills folded in, the visible columns of a logs search, the filters of a trace search or the mode of a metrics search, and the range as written. It is saved in folder_id, which needs Create there, else in the caller’s My Dashboards, else in General. Everyone who can view that folder can read it. The datasource must exist (422 unknown_datasource) and fit the kind (422 unsupported_datasource): logs take Loki, ClickHouse, Elasticsearch and OpenSearch, traces take Tempo, Jaeger and ClickHouse, metrics take Prometheus. A logs or metrics search needs a query; a traces search may have one, TraceQL on Tempo, key=value pairs on Jaeger and SQL on ClickHouse. A body that breaks a rule of its fields answers 422 invalid_saved_search with the rule in error. A service-account key gets the checks of the save_search tool: a query with a lint error answers 422 query_invalid and nothing is saved, and a search the key already saved with the same title, datasource, query, filters, range and folder answers 200 with replayed true and that search, so a retry makes no second copy. The kind and the datasource never change afterwards: save a new search instead. The query, filters and range can be changed with a PATCH.
Request body
application/json, required.
A CreateSavedSearchRequest object.
Responses
| Status | Description | Body |
|---|---|---|
200 |
The search this key had already saved, with replayed true. |
SavedSearchReplayed |
201 |
The saved search. | SavedSearch |
400 |
The request is malformed or fails validation. | Error |
401 |
Authentication is missing or invalid. | Error |
403 |
The caller is not allowed to perform the request; a role that is too low is code forbidden_role. |
Error |
404 |
The resource does not exist, or the caller cannot see it; the two are never told apart. | Error |
409 |
The content reads a datasource only Admins can query and the folder is not one only Admins can read (restricted_content, naming the datasource). |
RestrictedContentError |
413 |
The request body exceeds the size limit. | Error |
422 |
A field breaks a rule (invalid_saved_search), the datasource does not exist (unknown_datasource), does not fit the kind (unsupported_datasource) or a key’s query fails the lint check (query_invalid). |
Error |
500 |
The server failed to handle the request. | Error |
PATCH /saved-searches/{id}
Rename a saved search, move it to another folder or change what it searches.
Needs Edit on the saved search; a move also needs Edit on the target folder, and a move into a personal folder answers 409 personal_folder, because it would make the search private: save it there instead. query, filters, from and to replace what the search runs; the kind and the datasource never change, and the result is checked the way a save is, so a rule a save would break answers 422 invalid_saved_search. A rename or a change of what it searches appends one saved_search.updated that lists what changed, a move appends saved_search.moved and takes the earlier events of the search to the new folder, and a change to what the search already has appends nothing. A body with none of title, folder_id, query, filters, from and to answers 400.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) |
path | string (uuid) |
Request body
application/json, required.
A UpdateSavedSearchRequest object.
Responses
| Status | Description | Body |
|---|---|---|
200 |
The saved search as it is now. | SavedSearch |
400 |
The request is malformed or fails validation. | Error |
401 |
Authentication is missing or invalid. | Error |
403 |
The caller is not allowed to perform the request; a role that is too low is code forbidden_role. |
Error |
404 |
The resource does not exist, or the caller cannot see it; the two are never told apart. | Error |
409 |
The target is a personal folder (personal_folder). Or the content reads a datasource only Admins can query and the folder is not one only Admins can read (restricted_content, naming the datasource). |
Error or RestrictedContentError |
413 |
The request body exceeds the size limit. | Error |
422 |
The title is empty, too long or has control characters (invalid_saved_search). |
Error |
500 |
The server failed to handle the request. | Error |
DELETE /saved-searches/{id}
Delete a saved search.
Needs Edit on the saved search. The deletion is recorded as saved_search.deleted, which stays in the folder the search was in.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) |
path | string (uuid) |
Responses
| Status | Description | Body |
|---|---|---|
204 |
The saved search is gone. | |
400 |
The request is malformed or fails validation. | Error |
401 |
Authentication is missing or invalid. | Error |
403 |
The caller is not allowed to perform the request; a role that is too low is code forbidden_role. |
Error |
404 |
The resource does not exist, or the caller cannot see it; the two are never told apart. | Error |
500 |
The server failed to handle the request. | Error |
Generated from api/openapi.yaml at c770e5e0. Report a problem.