From 5de95cfaac26e01e80c24e59c32f39f64e0c147c Mon Sep 17 00:00:00 2001 From: lshippy Date: Thu, 4 Jan 2024 09:38:32 -0800 Subject: [PATCH] Adding example for querying against Grafana Cloud log tenant in API docs --- docs/sources/reference/api.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/sources/reference/api.md b/docs/sources/reference/api.md index 666cc43f91c2..4e92cb5a6443 100644 --- a/docs/sources/reference/api.md +++ b/docs/sources/reference/api.md @@ -404,6 +404,14 @@ curl -u "Tenant1|Tenant2|Tenant3:$API_TOKEN" \ --data-urlencode 'query=sum(rate({job="varlogs"}[10m])) by (level)' | jq ``` + +To query against your hosted log tenant in Grafana Cloud, use the **User** and **URL** values provided in the Loki logging service details of your Grafana Cloud stack. You can find this information in the [Cloud Portal](https://grafana.com/docs/grafana-cloud/account-management/cloud-portal/#your-grafana-cloud-stack). Use an access policy token in your queries for authentication. The password in this example is an access policy token that has been defined in the `API_TOKEN` environment variable: +```bash +curl -u "User:$API_TOKEN" \ + -G -s "/loki/api/v1/query" \ + --data-urlencode 'query=sum(rate({job="varlogs"}[10m])) by (level)' | jq +``` + ## Query logs within a range of time ```