Skip to content

Commit

Permalink
Docs: Adding example in API docs for querying against Grafana Cloud l…
Browse files Browse the repository at this point in the history
…og tenant (grafana#11579)

**What this PR does / why we need it**:
Adds example for querying against Grafana Cloud log tenant to API docs. 


**Which issue(s) this PR fixes**:
Addresses internal doc request that came about via a Support ticket

**Special notes for your reviewer**:

**Checklist**
- [x] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [x] Documentation added
- [ ] Tests updated
- [ ] `CHANGELOG.md` updated
- [ ] If the change is worth mentioning in the release notes, add
`add-to-release-notes` label
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/setup/upgrade/_index.md`
- [ ] For Helm chart changes bump the Helm chart version in
`production/helm/loki/Chart.yaml` and update
`production/helm/loki/CHANGELOG.md` and
`production/helm/loki/README.md`. [Example
PR](grafana@d10549e)
- [ ] If the change is deprecating or removing a configuration option,
update the `deprecated-config.yaml` and `deleted-config.yaml` files
respectively in the `tools/deprecated-config-checker` directory.
[Example
PR](grafana@0d4416a)
  • Loading branch information
lshippy authored and rhnasc committed Apr 12, 2024
1 parent 56e0a8f commit 08218a8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/sources/reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<URL-PROVIDED-IN-LOKI-DATA-SOURCE-SETTINGS>/loki/api/v1/query" \
--data-urlencode 'query=sum(rate({job="varlogs"}[10m])) by (level)' | jq
```

## Query logs within a range of time

```
Expand Down

0 comments on commit 08218a8

Please sign in to comment.