Repository navigation
Fix Loki toolset docs for Grafana Cloud and trailing slash bug #1590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aantn
wants to merge
5
commits into
master
Choose a base branch
from
claude/fix-loki-docs-tSHIk
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
33ae3d8
Fix Loki toolset docs for Grafana Cloud and trailing slash bug
claude 7ce3762
Remove trailing slash warning from Loki docs since code handles it
claude 7ddeeab
Restructure Loki docs: merge confusing 3 options into 2 clear ones
claude 17fa0ee
Simplify Grafana Cloud Loki direct config to just api_url + api_key
claude 96716a7
Fix token instructions order and remove Capabilities section
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: HolmesGPT/holmesgpt
Length of output: 106
🏁 Script executed:
rg -n "api_key|Bearer|basic_auth|Authorization" --type py -A3 -B3 holmes/plugins/toolsets/grafana/common.pyRepository: HolmesGPT/holmesgpt
Length of output: 1044
🏁 Script executed:
Repository: HolmesGPT/holmesgpt
Length of output: 392
🏁 Script executed:
Repository: HolmesGPT/holmesgpt
Length of output: 6629
🏁 Script executed:
Repository: HolmesGPT/holmesgpt
Length of output: 3362
🌐 Web query:
Grafana Cloud Loki authentication API key bearer token💡 Result:
For Grafana Cloud Loki (logs), the “API key” you create is typically a Grafana Cloud Access Policy token. How you pass it depends on which endpoint you’re calling:
1) Calling Loki (read/write logs): use tenant/user + token
Grafana Cloud Loki expects your Logs tenant ID (a.k.a. logs user / tenant) plus the token.
Option A — HTTP Basic Auth (most common)
Option B —
Authorization: Bearer <user>:<token>(common for push examples)Grafana’s own curl example for pushing logs uses:
Authorization: Bearer <LOGS_USERID>:<API_KEY>(grafana.com)Example (push):
(grafana.com)
2) Calling the Grafana Cloud API (not Loki): use
Bearer <token>For Grafana Cloud API requests, you pass the Access Policy token as:
Authorization: Bearer <CLOUD ACCESS POLICY TOKEN>(grafana.com)If you tell me whether you’re pushing logs (
/loki/api/v1/push) or querying (/loki/api/v1/query/query_range), and paste your Loki endpoint host pattern (redact IDs), I can give you the exact curl for your case.Citations:
🌐 Web query:
Grafana Cloud Loki query_range authentication tenant ID logs user💡 Result:
To call Loki’s
GET /loki/api/v1/query_rangeagainst Grafana Cloud Logs (Loki) you typically need (a) the logs tenant ID / logs userID and (b) a token (Cloud Access Policy token) withlogs:read.1) Endpoint
Use your stack’s Loki “Logs endpoint” (shown in the Grafana Cloud Portal). The range-query path is:
.../loki/api/v1/query_range. [1]2) Authentication (Grafana Cloud)
Grafana Cloud’s recommended setup is HTTP Basic Auth:
3) Tenant / Org header (
X-Scope-OrgID)Loki is multi-tenant and, in general, identifies the tenant with the
X-Scope-OrgIDheader. [3]In Grafana Cloud, the fronting gateway commonly derives tenant from your credentials (so you often don’t need to manually add
X-Scope-OrgIDif you’re using the Cloud endpoint + basic auth), but if you’re hitting Loki behind your own proxy or a custom deployment, you may need to set it explicitly. [3]4) Example
curl(range query)Common failure modes
logs:readscope. [2]X-Scope-OrgIDwhen talking to Loki without a gateway that injects it. [3]Sources: [1] [2] [3]
🏁 Script executed:
cat -n holmes/plugins/toolsets/grafana/common.py | head -60Repository: HolmesGPT/holmesgpt
Length of output: 2498
🏁 Script executed:
cat -n holmes/plugins/toolsets/grafana/loki/toolset_grafana_loki.py | head -100Repository: HolmesGPT/holmesgpt
Length of output: 4074
The Grafana Cloud Loki configuration example is incomplete for direct-access authentication.
Grafana Cloud Loki requires both the logs tenant ID (numeric user ID) and an Access Policy token with
logs:readscope. Official Grafana documentation specifies HTTP Basic Auth (username=tenant ID, password=token) orAuthorization: Bearer <TENANT_ID>:<TOKEN>.The current code implements only
Authorization: Bearer <api_key>, omitting the tenant ID. This will fail for Grafana Cloud Loki direct access (logs-prod-XXX.grafana.net/loki/api/v1/...).The configuration should:
glsa_*) is required withlogs:readscope.tenant_idconfig field or throughadditional_headersusing HTTP Basic Auth (Authorization: Basic <base64-encoded-tenant:token>).Without this, users following the current example with a direct Loki endpoint will encounter authentication errors.
🤖 Prompt for AI Agents