From 54e25c844e4b0251c40b0b18e0eb21dda4f1018f Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Thu, 14 Jul 2022 23:20:30 +0200 Subject: [PATCH] Add API delete curl examples (#6680) (#6682) * Add API delete curl examples * Update docs/sources/api/_index.md Co-authored-by: Jennifer Villa * Update docs/sources/api/_index.md Co-authored-by: Jennifer Villa * Update docs/sources/api/_index.md Co-authored-by: Jennifer Villa * Update docs/sources/api/_index.md Co-authored-by: Jennifer Villa Co-authored-by: Jennifer Villa (cherry picked from commit 1f676adf063869c6491f4b1e21eeac4c5cb3af1e) Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com> --- docs/sources/api/_index.md | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/docs/sources/api/_index.md b/docs/sources/api/_index.md index f8e49522bdfd6..1259b0cbbe453 100644 --- a/docs/sources/api/_index.md +++ b/docs/sources/api/_index.md @@ -1036,6 +1036,10 @@ Query parameters: A 204 response indicates success. +The query parameter can also include filter operations. For example `query={foo="bar"} |= "other"` will filter out lines that contain the string "other" for the streams matching the stream selector `{foo="bar"}`. + +#### Examples + URL encode the `query` parameter. This sample form of a cURL command URL encodes `query={foo="bar"}`: ```bash @@ -1044,7 +1048,13 @@ curl -g -X POST \ -H 'X-Scope-OrgID: 1' ``` -The query parameter can also include filter operations. For example `query={foo="bar"} |= "other"` will filter out lines that contain the string "other" for the streams matching the stream selector `{foo="bar"}`. +The same example deletion request for Grafana Enterprise Logs uses Basic Authentication and specifies the tenant name as a user; `Tenant1` is the tenant name in this example. The password in this example is an access policy token that has been defined in the API_TOKEN environment variable. The token must be for an access policy with `logs:delete` scope for the tenant specified in the user field: + +```bash +curl -u "Tenant1:$API_TOKEN" \ + -g -X POST \ + 'http://127.0.0.1:3100/loki/api/v1/delete?query={foo="bar"}&start=1591616227&end=1591619692' +``` ### List log deletion requests @@ -1062,7 +1072,11 @@ List the existing delete requests using the following API: GET /loki/api/v1/delete ``` -Sample form of a cURL command: +This endpoint returns both processed and unprocessed deletion requests. It does not list canceled requests, as those requests will have been removed from storage. + +#### Examples + +Example cURL command: ``` curl -X GET \ @@ -1070,7 +1084,13 @@ curl -X GET \ -H 'X-Scope-OrgID: ' ``` -This endpoint returns both processed and unprocessed requests. It does not list canceled requests, as those requests will have been removed from storage. +The same example deletion request for Grafana Enterprise Logs uses Basic Authentication and specifies the tenant name as a user; `Tenant1` is the tenant name in this example. The password in this example is an access policy token that has been defined in the API_TOKEN environment variable. The token must be for an access policy with `logs:delete` scope for the tenant specified in the user field. + +```bash +curl -u "Tenant1:$API_TOKEN" \ + -X GET \ + /loki/api/v1/delete +``` ### Request cancellation of a delete request @@ -1096,7 +1116,9 @@ Query parameters: A 204 response indicates success. -Sample form of a cURL command: +#### Examples + +Example cURL command: ``` curl -X DELETE \ @@ -1104,6 +1126,14 @@ curl -X DELETE \ -H 'X-Scope-OrgID: ' ``` +The same example deletion cancellation request for Grafana Enterprise Logs uses Basic Authentication and specifies the tenant name as a user; `Tenant1` is the tenant name in this example. The password in this example is an access policy token that has been defined in the API_TOKEN environment variable. The token must be for an access policy with `logs:delete` scope for the tenant specified in the user field. + +```bash +curl -u "Tenant1:$API_TOKEN" \ + -X DELETE \ + '/loki/api/v1/delete?request_id=' +``` + ## Deprecated endpoints ### `GET /api/prom/tail`