osdctl rhobs logs: incorrect Grafana URL for HCP clusters
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 47
- Forks
- 142
- Avg merge
- 21h 19m
- Merged PRs (30d)
- 9
Description
Summary
osdctl rhobs logs -C <hcp-cluster-id> --url generates an incorrect Grafana URL for HCP (Hosted Control Plane) clusters. The URL shows no logs when opened in a browser.
Root Cause
When given an HCP cluster ID, the command:
- Correctly resolves the RHOBS cell by looking up the management cluster (MC)
- But incorrectly uses the HCP cluster's
openshift_cluster_id(external UUID) as the Loki filter
HCP control-plane logs run in a namespace on the MC (e.g. ocm-production-<hcp-id>-...) and are indexed in RHOBS under the MC's openshift_cluster_id, not the HCP cluster's.
The generated query is:
{k8s_namespace_name="default"} | openshift_cluster_id = "<hcp-external-uuid>"
This returns no logs because:
k8s_namespace_name="default"is not where HCP control-plane logs liveopenshift_cluster_id = "<hcp-external-uuid>"is the wrong cluster label for RHOBS HCP logs
Expected Behavior
For an HCP cluster, the URL should use:
- Namespace: the HCP control-plane namespace on the MC, e.g.
ocm-production-<hcp-id>-<suffix>(available viaGetHCPNamespace) openshift_cluster_id: the MC's external UUID (available viaGetManagementCluster(...).ExternalID())
Working Loki query (confirmed by user investigation):
{k8s_namespace_name="ocm-production-<hcp-id>-<suffix>"} | openshift_cluster_id = "<mc-external-uuid>"
Steps to Reproduce
osdctl rhobs logs -C <hcp-cluster-id> --url
Open the generated URL — shows "No logs found".
Compare with:
osdctl rhobs logs -C <mc-cluster-id> --url
Then manually set the namespace to the HCP namespace — shows logs correctly.
Affected Code
cmd/rhobs/logs_cmd.go — the GetDefaultGrafanaLogsUrl() method and the namespace flag default value ("default").
When populateRhobsFetchers is called with an HCP cluster ID, it sets monitoredClusterId to the MC's internal ID (correct for RHOBS cell resolution) but leaves clusterExternalId as the HCP cluster's external UUID (wrong for the Loki query).
Fix
In populateRhobsFetchers (or in the logs URL generation path), when the cluster is an HCP cluster:
- Fetch the HCP namespace via
utils.GetHCPNamespace(clusterId) - Fetch the MC's external UUID via
utils.GetManagementCluster(clusterId).ExternalID() - Use these to build the correct Loki stream selector and filter
Note: osdctl cluster context has already been patched with this workaround separately.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in cmd/rhobs/logs_cmd.go by reading populateRhobsFetchers and GetDefaultGrafanaLogsUrl, then reproduce the issue with osdctl rhobs logs -C --url. Verify the generated URL uses the HCP namespace from GetHCPNamespace and the management cluster's ExternalID; done means opening it shows HCP control-plane logs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100