Skip to content

Commit

Permalink
Add API delete curl examples (#6680) (#6682)
Browse files Browse the repository at this point in the history
* Add API delete curl examples

* Update docs/sources/api/_index.md

Co-authored-by: Jennifer Villa <jvilla2013@gmail.com>

* Update docs/sources/api/_index.md

Co-authored-by: Jennifer Villa <jvilla2013@gmail.com>

* Update docs/sources/api/_index.md

Co-authored-by: Jennifer Villa <jvilla2013@gmail.com>

* Update docs/sources/api/_index.md

Co-authored-by: Jennifer Villa <jvilla2013@gmail.com>

Co-authored-by: Jennifer Villa <jvilla2013@gmail.com>
(cherry picked from commit 1f676ad)

Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>
  • Loading branch information
grafanabot and KMiller-Grafana authored Jul 14, 2022
1 parent d5bacad commit 54e25c8
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions docs/sources/api/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -1062,15 +1072,25 @@ 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 \
<compactor_addr>/loki/api/v1/delete \
-H 'X-Scope-OrgID: <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 \
<compactor_addr>/loki/api/v1/delete
```

### Request cancellation of a delete request

Expand All @@ -1096,14 +1116,24 @@ Query parameters:

A 204 response indicates success.

Sample form of a cURL command:
#### Examples

Example cURL command:

```
curl -X DELETE \
'<compactor_addr>/loki/api/v1/delete?request_id=<request_id>' \
-H 'X-Scope-OrgID: <tenant-id>'
```

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 \
'<compactor_addr>/loki/api/v1/delete?request_id=<request_id>'
```

## Deprecated endpoints

### `GET /api/prom/tail`
Expand Down

0 comments on commit 54e25c8

Please sign in to comment.