@skyhook-io/radar-app 1.21.5 → 1.21.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.md +1 -1
  2. package/package.json +7 -7
  3. package/src/App.tsx +19 -1
  4. package/src/RadarApp.tsx +8 -2
  5. package/src/api/client.discoverMetrics.test.tsx +69 -0
  6. package/src/api/client.issueCorrelation.test.tsx +244 -0
  7. package/src/api/client.issueRowChanges.test.tsx +129 -0
  8. package/src/api/client.pendingOwnership.test.tsx +197 -0
  9. package/src/api/client.prometheusStatus.test.ts +4 -0
  10. package/src/api/client.restartError.test.ts +36 -1
  11. package/src/api/client.stopWorkflow.test.tsx +133 -0
  12. package/src/api/client.submitWorkflowTemplate.test.tsx +127 -0
  13. package/src/api/client.ts +572 -111
  14. package/src/api/connectionBinding.test.tsx +3 -1
  15. package/src/api/connectionBinding.ts +14 -2
  16. package/src/api/gitOpsPermissions.render.test.tsx +155 -0
  17. package/src/api/gitOpsPermissions.test.ts +90 -0
  18. package/src/api/gitOpsPermissions.ts +51 -0
  19. package/src/api/httpErrors.test.ts +30 -1
  20. package/src/api/httpErrors.ts +17 -0
  21. package/src/api/openobserveSetup.ts +85 -0
  22. package/src/api/podDebug.test.tsx +137 -0
  23. package/src/api/podDebug.ts +82 -0
  24. package/src/api/prometheusCharts.test.ts +23 -0
  25. package/src/api/prometheusCharts.ts +25 -0
  26. package/src/api/radarFeatures.render.test.tsx +43 -2
  27. package/src/api/radarFeatures.test.ts +18 -1
  28. package/src/api/radarFeatures.ts +17 -4
  29. package/src/api/reviewedActionMutation.ts +9 -2
  30. package/src/api/workloadMetrics.ts +2 -0
  31. package/src/components/applications/ApplicationsView.openResource.test.tsx +137 -11
  32. package/src/components/applications/ApplicationsView.tsx +56 -31
  33. package/src/components/cnpg/host.test.tsx +1 -1
  34. package/src/components/cnpg/host.tsx +0 -2
  35. package/src/components/dock/BottomDock.tsx +7 -3
  36. package/src/components/dock/MissingShellDebug.test.tsx +193 -0
  37. package/src/components/dock/MissingShellDebug.tsx +114 -0
  38. package/src/components/dock/PodDebugSession.test.tsx +60 -0
  39. package/src/components/dock/PodDebugSession.tsx +96 -0
  40. package/src/components/dock/TerminalTab.test.tsx +48 -4
  41. package/src/components/dock/TerminalTab.tsx +47 -25
  42. package/src/components/dock/WorkloadLogsTab.test.tsx +24 -1
  43. package/src/components/dock/WorkloadLogsTab.tsx +16 -0
  44. package/src/components/execution/BatchExecutionView.command.test.tsx +69 -0
  45. package/src/components/execution/BatchExecutionView.tsx +88 -5
  46. package/src/components/execution/BatchExecutionView.workflow-stop.test.tsx +69 -0
  47. package/src/components/execution/WorkflowRunStopAction.tsx +8 -0
  48. package/src/components/gitops/GitOpsPermissionRowActions.test.tsx +100 -0
  49. package/src/components/gitops/GitOpsPermissionRowActions.tsx +27 -0
  50. package/src/components/gitops/GitOpsView.identity.test.tsx +1 -0
  51. package/src/components/gitops/GitOpsView.permissions.test.tsx +102 -0
  52. package/src/components/gitops/GitOpsView.syncRequest.test.tsx +95 -7
  53. package/src/components/gitops/GitOpsView.tsx +93 -32
  54. package/src/components/helm/OwnedResources.tsx +1 -0
  55. package/src/components/home/mcpToolCatalog.ts +1 -0
  56. package/src/components/issues/IssuesPane.render.test.tsx +1 -1
  57. package/src/components/issues/IssuesPane.tsx +11 -0
  58. package/src/components/issues/useIssueExpansion.ts +91 -0
  59. package/src/components/resource/MetricsNotConnected.test.tsx +50 -0
  60. package/src/components/resource/MetricsNotConnected.tsx +114 -0
  61. package/src/components/resource/PVCUsageBar.tsx +2 -1
  62. package/src/components/resource/PrometheusCharts.render.test.tsx +47 -0
  63. package/src/components/resource/PrometheusCharts.tsx +14 -2
  64. package/src/components/resource/PrometheusChartsGrid.render.test.tsx +91 -1
  65. package/src/components/resource/PrometheusChartsGrid.tsx +28 -52
  66. package/src/components/resource/RestartChart.tsx +4 -3
  67. package/src/components/resource/RightsizingPanel.source.test.tsx +34 -0
  68. package/src/components/resource/RightsizingStrip.tsx +5 -3
  69. package/src/components/resource/WorkloadMetricsSection.render.test.tsx +6 -0
  70. package/src/components/resource/WorkloadMetricsSection.tsx +14 -11
  71. package/src/components/resource/nameMatchedScope.ts +9 -3
  72. package/src/components/resources/EmptyNamespaceHint.tsx +42 -0
  73. package/src/components/resources/PodDebugAction.test.tsx +157 -0
  74. package/src/components/resources/PodDebugAction.tsx +207 -0
  75. package/src/components/resources/PodDebugPermission.tsx +21 -0
  76. package/src/components/resources/ResourcesView.empty-hint.test.tsx +132 -0
  77. package/src/components/resources/ResourcesView.tsx +39 -5
  78. package/src/components/resources/namespaceHint.test.ts +34 -0
  79. package/src/components/resources/namespaceHint.ts +19 -0
  80. package/src/components/resources/renderers/AdmissionPolicyRenderers.tsx +135 -0
  81. package/src/components/resources/renderers/NodeRenderer.tsx +2 -1
  82. package/src/components/resources/renderers/PodRenderer.tsx +12 -5
  83. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +24 -1
  84. package/src/components/settings/LocalIntegrationStatus.tsx +14 -3
  85. package/src/components/settings/MetricsBackendSwitch.tsx +167 -0
  86. package/src/components/settings/OpenObserveSetup.test.tsx +343 -0
  87. package/src/components/settings/OpenObserveSetup.tsx +358 -0
  88. package/src/components/settings/SettingsDialog.tsx +21 -7
  89. package/src/components/settings/openobserveStatus.test.ts +34 -0
  90. package/src/components/settings/openobserveStatus.ts +55 -0
  91. package/src/components/timeline/TimelineList.selection.test.tsx +40 -0
  92. package/src/components/timeline/TimelineList.test.ts +18 -0
  93. package/src/components/timeline/TimelineList.tsx +19 -5
  94. package/src/components/timeline/TimelineView.tsx +2 -0
  95. package/src/components/workload/WorkloadView.pendingOwnership.test.tsx +34 -0
  96. package/src/components/workload/WorkloadView.tabUrl.test.tsx +44 -0
  97. package/src/components/workload/WorkloadView.tsx +95 -10
  98. package/src/context/TimelineNavigation.test.ts +59 -0
  99. package/src/context/TimelineNavigation.tsx +86 -0
  100. package/src/contexts/CapabilitiesContext.tsx +3 -1
  101. package/src/hooks/useResourceCounts.ts +2 -1
  102. package/src/hooks/useWorkflowStopAction.ts +31 -0
  103. package/src/index.css +1 -0
  104. package/src/integrations/resourceHosts.test.tsx +2 -2
  105. package/src/integrations/resourceHosts.tsx +4 -2
  106. package/src/k8s-ui-exports.test.ts +10 -0
  107. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +0 -128
@@ -0,0 +1,114 @@
1
+ import { clsx } from "clsx";
2
+ import { Loader2, Wifi, WifiOff } from "lucide-react";
3
+ import {
4
+ usePrometheusConnect,
5
+ useDiscoverMetrics,
6
+ type PrometheusStatus,
7
+ } from "../../api/client";
8
+ import { useNavCustomization } from "../../context/NavCustomization";
9
+ import { unavailableReason } from '../settings/openobserveStatus';
10
+ import { previousSettingsNote, usePreviousIntegrationSettings } from '../../hooks/usePreviousIntegrationSettings';
11
+
12
+ const openMetricsSettings = () => window.dispatchEvent(new CustomEvent('radar:open-settings', { detail: { section: 'prometheus' } }));
13
+
14
+ interface MetricsNotConnectedProps {
15
+ status?: PrometheusStatus;
16
+ isWorkload: boolean;
17
+ }
18
+
19
+ // A discovery result describes the status it ran against, so it starts over
20
+ // once the connection or its source changes.
21
+ export function MetricsNotConnected(props: MetricsNotConnectedProps) {
22
+ const { status } = props;
23
+ return <NotConnected key={`${status?.connected}|${status?.source?.kind}|${status?.source?.via}`} {...props} />;
24
+ }
25
+
26
+ function NotConnected({ status, isWorkload }: MetricsNotConnectedProps) {
27
+ const connectMutation = usePrometheusConnect();
28
+ const discoverMutation = useDiscoverMetrics();
29
+ const settingsAvailable = !useNavCustomization().embedded;
30
+ const offers = usePreviousIntegrationSettings(!!status);
31
+ const previousNote = offers.metrics ? previousSettingsNote('metrics', offers.metrics) : undefined;
32
+ const openObservePath = status?.openobserve;
33
+ const discovery = openObservePath ? discoverMutation : connectMutation;
34
+ const outcome = openObservePath ? discoverMutation.data : undefined;
35
+ const failure = openObservePath ? discoverMutation.error?.message : undefined;
36
+ const notFound = outcome === "none" || outcome === "collector";
37
+ return (
38
+ <div className="flex flex-col items-center justify-center py-12 gap-4">
39
+ <WifiOff className="w-10 h-10 text-theme-text-quaternary" />
40
+ <div className="text-center">
41
+ <p className="text-sm text-theme-text-secondary mb-1">
42
+ {openObservePath ? "No metrics source connected" : "Prometheus not connected"}
43
+ </p>
44
+ <p className="text-xs text-theme-text-tertiary mb-4">
45
+ {status?.error || (openObservePath
46
+ ? "Radar can read metrics from Prometheus or OpenObserve."
47
+ : "Connect to view historical CPU, memory, and network metrics")}
48
+ </p>
49
+ {(notFound || failure) && <p role="status" className="text-sm text-theme-text-secondary mb-4">
50
+ {failure
51
+ ? failure
52
+ : outcome === "none"
53
+ ? "No metrics source found."
54
+ : openObservePath === "hub"
55
+ ? "OpenObserve collector found. Ask your organization owner to connect OpenObserve in Radar Hub."
56
+ : "OpenObserve collector found. Connect it in Settings → Metrics."}
57
+ </p>}
58
+ <div className="flex flex-wrap items-center justify-center gap-3">
59
+ {!notFound && <button
60
+ onClick={() => discovery.mutate()}
61
+ disabled={discovery.isPending}
62
+ className="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg btn-brand"
63
+ >
64
+ {discovery.isPending ? (
65
+ <Loader2 className="w-4 h-4 animate-spin" />
66
+ ) : (
67
+ <Wifi className="w-4 h-4" />
68
+ )}
69
+ {openObservePath ? "Discover metrics" : "Discover Prometheus"}
70
+ </button>}
71
+ {settingsAvailable && <button
72
+ type="button"
73
+ className="text-sm text-accent hover:underline"
74
+ onClick={openMetricsSettings}
75
+ >Configure metrics</button>}
76
+ </div>
77
+ {previousNote && <p className="mt-3 text-xs text-theme-text-secondary">{previousNote}</p>}
78
+ {!settingsAvailable && <p className="mt-3 text-xs text-theme-text-tertiary">Ask your operator to configure the metrics connection for this cluster.</p>}
79
+ {isWorkload && <a className="mt-3 inline-block text-xs text-accent hover:underline" href="https://github.com/skyhook-io/radar/blob/main/docs/workload-metrics.md#what-each-chart-needs" target="_blank" rel="noopener noreferrer">What each chart needs</a>}
80
+ </div>
81
+ </div>
82
+ );
83
+ }
84
+
85
+ export function OpenObserveUnavailable({
86
+ status,
87
+ compact = false,
88
+ }: {
89
+ status: PrometheusStatus;
90
+ compact?: boolean;
91
+ }) {
92
+ const viaHub = status.source?.via === "hub";
93
+ const error = unavailableReason(status.source?.error);
94
+ const settingsAvailable = !useNavCustomization().embedded;
95
+ return (
96
+ <div className={clsx("flex flex-col items-center justify-center gap-4", compact ? "py-4" : "py-12")}>
97
+ <WifiOff className="w-10 h-10 text-theme-text-quaternary" />
98
+ <div className="text-center">
99
+ <p className="text-sm text-theme-text-secondary mb-1">OpenObserve unavailable</p>
100
+ {error && <p className="text-xs text-theme-text-tertiary mb-1">{error}</p>}
101
+ <p className="text-xs text-theme-text-tertiary">
102
+ {viaHub
103
+ ? "This cluster's metrics come from OpenObserve through Radar Hub. Charts come back when it answers again."
104
+ : "This cluster's metrics come from the saved OpenObserve connection. Charts come back when it answers again."}
105
+ </p>
106
+ {!viaHub && settingsAvailable && <button
107
+ type="button"
108
+ className="mt-3 text-sm text-accent hover:underline"
109
+ onClick={openMetricsSettings}
110
+ >Configure metrics</button>}
111
+ </div>
112
+ </div>
113
+ );
114
+ }
@@ -1,3 +1,4 @@
1
+ import { hasPrometheusCharts } from '../../api/prometheusCharts'
1
2
  import { formatMemoryBytes } from '@skyhook-io/k8s-ui/utils/format'
2
3
  import { isForbiddenError, useAutoPromConnect, useCloudRole, usePrometheusPVCUsage, usePrometheusStatus } from '../../api/client'
3
4
  import { useNavCustomization } from '../../context/NavCustomization'
@@ -11,7 +12,7 @@ export function PVCUsageBar({ namespace, name }: { namespace: string; name: stri
11
12
  const settingsAvailable = !useNavCustomization().embedded
12
13
  const canConfigure = settingsAvailable && !roleLoading && canAtLeast('owner')
13
14
  const { data: status, error: statusError } = usePrometheusStatus()
14
- const isConnected = status?.connected === true
15
+ const isConnected = hasPrometheusCharts(status)
15
16
  const { data: usage, error } = usePrometheusPVCUsage(namespace, name, isConnected)
16
17
 
17
18
  let unavailable: string | undefined
@@ -0,0 +1,47 @@
1
+ import { beforeEach, expect, it, vi } from 'vitest'
2
+ import { renderToString } from 'react-dom/server'
3
+ import { NavCustomizationProvider } from '../../context/NavCustomization'
4
+ vi.mock('../../hooks/usePreviousIntegrationSettings', () => ({ usePreviousIntegrationSettings: () => ({ metrics: false }) }))
5
+
6
+ let status: Record<string, unknown>
7
+
8
+ vi.mock('../../api/client', async (importActual) => ({
9
+ ...(await importActual<typeof import('../../api/client')>()),
10
+ useAutoPromConnect: () => undefined,
11
+ usePrometheusStatus: () => ({ data: status, isLoading: false }),
12
+ usePrometheusConnect: () => ({ mutate: vi.fn(), isPending: false }),
13
+ useDiscoverMetrics: () => ({ mutate: vi.fn(), isPending: false }),
14
+ usePrometheusResourceMetrics: () => ({ data: undefined }),
15
+ }))
16
+
17
+ const { PrometheusCharts } = await import('./PrometheusCharts')
18
+ const render = () => renderToString(
19
+ <NavCustomizationProvider value={{}}>
20
+ <PrometheusCharts kind="Deployment" namespace="demo" name="web" showEmptyState />
21
+ </NavCustomizationProvider>,
22
+ )
23
+
24
+ beforeEach(() => { status = { available: false, connected: false } })
25
+
26
+ it('keeps the Prometheus setup when Radar cannot read OpenObserve', () => {
27
+ const html = render()
28
+ expect(html).toContain('Prometheus not connected')
29
+ expect(html).toContain('Discover Prometheus')
30
+ expect(html).not.toContain('Configure metrics')
31
+ })
32
+
33
+ it.each(['hub', 'local'])('offers metrics discovery when OpenObserve is available through %s', (path) => {
34
+ status.openobserve = path
35
+ const html = render()
36
+ expect(html).toContain('No metrics source connected')
37
+ expect(html).toContain('Discover metrics')
38
+ expect(html).not.toContain('Discover Prometheus')
39
+ })
40
+
41
+ it('shows OpenObserve unavailable instead of Prometheus discovery', () => {
42
+ status = { available: true, connected: true, openobserve: 'local', source: { kind: 'openobserve', via: 'local', unavailable: true, error: 'timeout' } }
43
+ const html = render()
44
+ expect(html).toContain('OpenObserve unavailable')
45
+ expect(html).toContain('timeout')
46
+ expect(html).not.toContain('Discover')
47
+ })
@@ -1,3 +1,4 @@
1
+ import { hasPrometheusCharts, metricsSourceUnavailable } from '../../api/prometheusCharts'
1
2
  import { useState, useMemo } from 'react'
2
3
  import {
3
4
  PrometheusChartsView,
@@ -14,6 +15,7 @@ import {
14
15
  type PrometheusTimeRange,
15
16
  } from '../../api/client'
16
17
  import { parseQuantity } from '@skyhook-io/k8s-ui/utils/format'
18
+ import { MetricsNotConnected, OpenObserveUnavailable } from './MetricsNotConnected'
17
19
 
18
20
  // ============================================================================
19
21
  // Radar-specific category config (lives here, not in k8s-ui, so consumers
@@ -93,10 +95,12 @@ export function PrometheusCharts({ kind, namespace, name, showEmptyState = false
93
95
  const { data: status, isLoading: statusLoading } = usePrometheusStatus()
94
96
  const connectMutation = usePrometheusConnect()
95
97
 
96
- const [activeCategory, setActiveCategory] = useState<PrometheusMetricCategory>('cpu')
98
+ const [selectedCategory, setActiveCategory] = useState<PrometheusMetricCategory>('cpu')
97
99
  const [timeRange, setTimeRange] = useState<PrometheusTimeRange>('1h')
98
100
 
99
- const isConnected = status?.connected === true
101
+ const isConnected = hasPrometheusCharts(status)
102
+ const gkeOnly = status?.gkeSystemMetrics && !status.connected
103
+ const activeCategory = gkeOnly && kind !== 'Node' && selectedCategory === 'filesystem' ? 'cpu' : selectedCategory
100
104
  const isSupported = SUPPORTED_KINDS.has(kind)
101
105
 
102
106
  // Fetch metrics when connected
@@ -113,12 +117,20 @@ export function PrometheusCharts({ kind, namespace, name, showEmptyState = false
113
117
  return computeRequestLimitLines(resource, kind, activeCategory)
114
118
  }, [resource, kind, activeCategory])
115
119
 
120
+ if (showEmptyState && isSupported && status) {
121
+ if (metricsSourceUnavailable(status)) return <OpenObserveUnavailable status={status} />
122
+ if (status.openobserve && !isConnected && !status.discovering) {
123
+ return <MetricsNotConnected status={status} isWorkload={['Deployment', 'StatefulSet', 'DaemonSet'].includes(kind)} />
124
+ }
125
+ }
126
+
116
127
  return (
117
128
  <PrometheusChartsView
118
129
  kind={kind}
119
130
  showEmptyState={showEmptyState}
120
131
  statusLoading={statusLoading}
121
132
  isConnected={isConnected}
133
+ gkeOnly={gkeOnly}
122
134
  statusError={status?.error}
123
135
  onConnect={() => connectMutation.mutate()}
124
136
  connecting={connectMutation.isPending}
@@ -8,6 +8,10 @@ vi.mock('../../hooks/usePreviousIntegrationSettings', () => ({ usePreviousIntegr
8
8
  import type { WorkloadMetrics } from '../../api/workloadMetrics'
9
9
 
10
10
  let connected = false
11
+ let source: Record<string, unknown> | undefined
12
+ let openobserve: 'hub' | 'local' | undefined
13
+ let discoverOutcome: 'connected' | 'collector' | 'none' | undefined
14
+ let discoverError: Error | null = null
11
15
  const ranges: string[] = []
12
16
  const charts: { seriesLabels?: string[]; referenceLines?: unknown[] }[] = []
13
17
  let workload: WorkloadMetrics
@@ -18,8 +22,9 @@ let metricsByCategory: Record<string, Record<string, unknown>> = {}
18
22
  vi.mock('../../api/client', async (importActual) => ({
19
23
  ...(await importActual<typeof import('../../api/client')>()),
20
24
  useAutoPromConnect: () => undefined,
21
- usePrometheusStatus: () => ({ data: { connected, error: 'Backend query failed' } }),
25
+ usePrometheusStatus: () => ({ data: { connected, error: openobserve ? undefined : 'Backend query failed', source, openobserve } }),
22
26
  usePrometheusConnect: () => ({ mutate: vi.fn(), isPending: false }),
27
+ useDiscoverMetrics: () => ({ mutate: vi.fn(), isPending: false, data: discoverOutcome, error: discoverError }),
23
28
  usePrometheusResourceMetrics: (_kind: string, _ns: string, _name: string, category: string, range: string, enabled = true) => {
24
29
  if (enabled) ranges.push(range)
25
30
  return { data: metricsByCategory[category] ?? resourceMetrics }
@@ -44,6 +49,10 @@ const render = (url = '/workloads/Deployment/demo/web?tab=metrics', embedded = f
44
49
 
45
50
  beforeEach(() => {
46
51
  connected = false
52
+ source = undefined
53
+ openobserve = undefined
54
+ discoverOutcome = undefined
55
+ discoverError = null
47
56
  ranges.length = 0
48
57
  charts.length = 0
49
58
  resourceMetrics = drawnMetrics
@@ -52,6 +61,35 @@ beforeEach(() => {
52
61
  })
53
62
 
54
63
  describe('Expanded metrics recovery and scope', () => {
64
+ it('shows one unavailable state instead of querying charts when OpenObserve through Hub is down', () => {
65
+ connected = true
66
+ source = { kind: 'openobserve', via: 'hub', unavailable: true, error: 'Radar Hub could not reach OpenObserve' }
67
+ const html = render()
68
+ expect(html).toContain('OpenObserve unavailable')
69
+ expect(html).toContain('Radar Hub could not reach OpenObserve')
70
+ expect(html).toContain('through Radar Hub')
71
+ expect(html).not.toContain('Discover Prometheus')
72
+ expect(html).not.toContain('Configure metrics')
73
+ expect(ranges).toEqual([])
74
+ })
75
+
76
+ it('shows the OpenObserve notice, not Prometheus setup, when newer Radar reports it not connected', () => {
77
+ source = { kind: 'openobserve', via: 'local', unavailable: true, error: 'OpenObserve unavailable: timeout' }
78
+ const html = render()
79
+ expect(html).toContain('OpenObserve unavailable')
80
+ expect(html).not.toContain('Discover Prometheus')
81
+ expect(ranges).toEqual([])
82
+ })
83
+
84
+ it('offers metrics settings when the saved local OpenObserve connection is down', () => {
85
+ connected = true
86
+ source = { kind: 'openobserve', via: 'local', unavailable: true }
87
+ const html = render()
88
+ expect(html).toContain('saved OpenObserve connection')
89
+ expect(html).toContain('Configure metrics')
90
+ expect(ranges).toEqual([])
91
+ })
92
+
55
93
  it('offers standalone setup without losing the backend error or retry', () => {
56
94
  const html = render()
57
95
  expect(html).toContain('Backend query failed')
@@ -59,6 +97,36 @@ describe('Expanded metrics recovery and scope', () => {
59
97
  expect(html).toContain('Configure metrics')
60
98
  expect(html).toContain('workload-metrics.md#what-each-chart-needs')
61
99
  })
100
+ it.each(['hub', 'local'] as const)('offers metrics discovery when OpenObserve is available through %s', (path) => {
101
+ openobserve = path
102
+ const html = render()
103
+ expect(html).toContain('No metrics source connected')
104
+ expect(html).toContain('Radar can read metrics from Prometheus or OpenObserve.')
105
+ expect(html).toContain('Discover metrics')
106
+ expect(html).not.toContain('Discover Prometheus')
107
+ expect(html).not.toContain('Prometheus not connected')
108
+ expect(html).toContain('Configure metrics')
109
+ })
110
+ it.each([
111
+ ['local', 'none', 'No metrics source found.'],
112
+ ['hub', 'none', 'No metrics source found.'],
113
+ ['local', 'collector', 'OpenObserve collector found. Connect it in Settings → Metrics.'],
114
+ ['hub', 'collector', 'OpenObserve collector found. Ask your organization owner to connect OpenObserve in Radar Hub.'],
115
+ ] as const)('shows the %s discovery outcome %s without offering discovery again', (path, outcome, message) => {
116
+ openobserve = path
117
+ discoverOutcome = outcome
118
+ const html = render()
119
+ expect(html).toContain(`<p role="status" class="text-sm text-theme-text-secondary mb-4">${message}</p>`)
120
+ expect(html).not.toContain('Discover metrics')
121
+ expect(html).not.toContain('Discover Prometheus')
122
+ })
123
+ it('shows a failed discovery in place and offers it again', () => {
124
+ openobserve = 'local'
125
+ discoverError = new Error('Not connected to a cluster')
126
+ const html = render()
127
+ expect(html).toContain('<p role="status" class="text-sm text-theme-text-secondary mb-4">Not connected to a cluster</p>')
128
+ expect(html).toContain('Discover metrics')
129
+ })
62
130
  it('uses operator guidance instead of standalone settings when embedded', () => {
63
131
  const html = render(undefined, true)
64
132
  expect(html).toContain('Ask your operator')
@@ -154,6 +222,19 @@ describe('Mapped workload Metrics tab', () => {
154
222
  ]))
155
223
  })
156
224
 
225
+ // Newer Radar reports a down OpenObserve as not connected; older Radar as
226
+ // connected with an unavailable source. Either way Datadog stays.
227
+ it.each([false, true])('keeps Datadog totals beside the OpenObserve notice when it is down (connected=%s)', async (wasConnected) => {
228
+ connected = wasConnected
229
+ source = { kind: 'openobserve', via: 'hub', unavailable: true, error: 'Radar Hub could not reach OpenObserve' }
230
+ const html = await renderMapped()
231
+ expect(html).toContain('OpenObserve unavailable')
232
+ expect(html).toContain('Datadog workload totals')
233
+ expect(html).not.toContain('Discover Prometheus')
234
+ expect(html).not.toContain('Network and storage')
235
+ expect(ranges).toHaveLength(0)
236
+ })
237
+
157
238
  it('renders Datadog independently when Prometheus is disconnected', async () => {
158
239
  const html = await renderMapped()
159
240
  expect(html).toContain('Datadog workload totals')
@@ -186,6 +267,15 @@ describe('Name-matched chart captions follow the charts\' cluster scope', () =>
186
267
  expect(html).toContain('Pod-name matched · operator declared single-cluster')
187
268
  expect(html).not.toContain('may include another cluster')
188
269
  })
270
+ it('names OpenObserve, not an operator, when Radar reads metrics through it', () => {
271
+ resourceMetrics = scoped('single_cluster_asserted', 'Scoped to this cluster through OpenObserve (matched by confirmed name).')
272
+ const html = renderText()
273
+ expect(html).toContain('Basic CPU / memory · scoped through OpenObserve')
274
+ expect(html).toContain('Pod-name matched · scoped through OpenObserve')
275
+ expect(html).toContain('kept to this cluster through OpenObserve')
276
+ expect(html).not.toContain('operator declared')
277
+ expect(html).not.toContain('may include another cluster')
278
+ })
189
279
  it.each([['absent', drawnMetrics], ['unlabeled', scoped('unlabeled')]])('keeps today\'s caveat when clusterScope is %s', (_label, metrics) => {
190
280
  resourceMetrics = metrics
191
281
  const html = renderText()
@@ -1,7 +1,8 @@
1
+ import { hasPrometheusCharts, metricsSourceUnavailable } from '../../api/prometheusCharts'
1
2
  import { clsx } from "clsx";
2
3
  import { useMemo, type ReactNode } from "react";
3
4
  import { useSearchParams } from "react-router-dom";
4
- import { Loader2, Wifi, WifiOff } from "lucide-react";
5
+ import { Loader2 } from "lucide-react";
5
6
  import { Disclosure } from "@skyhook-io/k8s-ui/components/ui/Disclosure";
6
7
  import { ClusterScopeNote } from "@skyhook-io/k8s-ui/components/ui/ClusterScopeNote";
7
8
  import { isClusterScopeWithheld } from "@skyhook-io/k8s-ui/types/cluster-scope";
@@ -20,7 +21,6 @@ import {
20
21
  } from "@skyhook-io/k8s-ui/utils/badge-colors";
21
22
  import {
22
23
  usePrometheusStatus,
23
- usePrometheusConnect,
24
24
  usePrometheusResourceMetrics,
25
25
  useAutoPromConnect,
26
26
  type PrometheusMetricCategory,
@@ -38,9 +38,8 @@ import { RestartEventLane } from "./RestartChart";
38
38
  import { Tooltip } from "../ui/Tooltip";
39
39
  import { WorkloadMetricsSection } from "./WorkloadMetricsSection";
40
40
  import { RightsizingStrip } from "./RightsizingStrip";
41
- import { useNavCustomization } from "../../context/NavCustomization";
42
41
  import { leastCertainScope, NAME_MATCHED_CLUSTER_NOTE, NAME_MATCHED_SUMMARY } from "./nameMatchedScope";
43
- import { previousSettingsNote, usePreviousIntegrationSettings } from '../../hooks/usePreviousIntegrationSettings';
42
+ import { MetricsNotConnected, OpenObserveUnavailable } from "./MetricsNotConnected";
44
43
 
45
44
  // Used when MetricsTabContent is in expanded (full-screen) mode. Drawer mode
46
45
  // uses the single-chart tabbed `PrometheusCharts` instead — drawer width
@@ -79,15 +78,11 @@ export function PrometheusChartsGrid({
79
78
  }: PrometheusChartsGridProps) {
80
79
  useAutoPromConnect();
81
80
  const { data: status, isLoading: statusLoading } = usePrometheusStatus();
82
- const connectMutation = usePrometheusConnect();
83
- const isConnected = status?.connected === true;
81
+ const isConnected = hasPrometheusCharts(status);
84
82
  const isSupported = SUPPORTED_KINDS.has(kind);
85
83
  const isWorkload = ["Deployment", "StatefulSet", "DaemonSet"].includes(kind);
86
84
  const showRestartLane = isSupported && kind !== "Node";
87
85
 
88
- const settingsAvailable = !useNavCustomization().embedded;
89
- const offers = usePreviousIntegrationSettings(isSupported && !statusLoading && !!status && !isConnected && !status.discovering);
90
- const previousNote = offers.metrics ? previousSettingsNote('metrics', offers.metrics) : undefined;
91
86
  const [searchParams, setSearchParams] = useSearchParams();
92
87
  const timeRange = TIME_RANGES.find((range) => range.value === searchParams.get("metricsRange"))?.value ?? "1h";
93
88
 
@@ -110,7 +105,8 @@ export function PrometheusChartsGrid({
110
105
  const rxScope = usePrometheusResourceMetrics(kind, namespace, name, "network_rx", timeRange, false).data?.clusterScope;
111
106
  const txScope = usePrometheusResourceMetrics(kind, namespace, name, "network_tx", timeRange, false).data?.clusterScope;
112
107
  const diskScope = usePrometheusResourceMetrics(kind, namespace, name, "filesystem", timeRange, false).data?.clusterScope;
113
- const nameMatchedScope = leastCertainScope(categories.some((c) => c.key === "filesystem") ? [rxScope, txScope, diskScope] : [rxScope, txScope]);
108
+ const hasDisk = kind === "Node" || !status?.gkeSystemMetrics || status.connected;
109
+ const nameMatchedScope = leastCertainScope(hasDisk ? [rxScope, txScope, diskScope] : [rxScope, txScope]);
114
110
  const nameMatchedNote = NAME_MATCHED_CLUSTER_NOTE[nameMatchedScope];
115
111
 
116
112
  if (!isSupported) return null;
@@ -132,6 +128,23 @@ export function PrometheusChartsGrid({
132
128
  ))}
133
129
  </select>;
134
130
 
131
+ // OpenObserve down takes only its own charts: workload totals from another
132
+ // source and the restart lane stay, as they do when Prometheus isn't set up.
133
+ if (status && metricsSourceUnavailable(status)) {
134
+ const notice = (
135
+ <OpenObserveUnavailable status={status} compact={!!workloadTotals} />
136
+ );
137
+ if (!workloadTotals && !showRestartLane) return notice;
138
+ return (
139
+ <div className={clsx("space-y-4 p-4", fill && "h-full overflow-auto")}>
140
+ {workloadTotals && <div className="flex">{rangeControl}</div>}
141
+ {notice}
142
+ {workloadTotals}
143
+ {showRestartLane && <RestartEventLane kind={kind} namespace={namespace} name={name} range={timeRange} />}
144
+ </div>
145
+ );
146
+ }
147
+
135
148
  if (workloadTotals && !isConnected) {
136
149
  return (
137
150
  <div className={clsx("space-y-4 p-4", fill && "h-full overflow-auto")}>
@@ -160,44 +173,7 @@ export function PrometheusChartsGrid({
160
173
  );
161
174
  }
162
175
 
163
- if (!isConnected) {
164
- return (
165
- <div className="flex flex-col items-center justify-center py-12 gap-4">
166
- <WifiOff className="w-10 h-10 text-theme-text-quaternary" />
167
- <div className="text-center">
168
- <p className="text-sm text-theme-text-secondary mb-1">
169
- Prometheus not connected
170
- </p>
171
- <p className="text-xs text-theme-text-tertiary mb-4">
172
- {status?.error ||
173
- "Connect to view historical CPU, memory, and network metrics"}
174
- </p>
175
- <div className="flex flex-wrap items-center justify-center gap-3">
176
- <button
177
- onClick={() => connectMutation.mutate()}
178
- disabled={connectMutation.isPending}
179
- className="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg btn-brand"
180
- >
181
- {connectMutation.isPending ? (
182
- <Loader2 className="w-4 h-4 animate-spin" />
183
- ) : (
184
- <Wifi className="w-4 h-4" />
185
- )}
186
- Discover Prometheus
187
- </button>
188
- {settingsAvailable && <button
189
- type="button"
190
- className="text-sm text-accent hover:underline"
191
- onClick={() => window.dispatchEvent(new CustomEvent('radar:open-settings', { detail: { section: 'prometheus' } }))}
192
- >Configure metrics</button>}
193
- </div>
194
- {previousNote && <p className="mt-3 text-xs text-theme-text-secondary">{previousNote}</p>}
195
- {!settingsAvailable && <p className="mt-3 text-xs text-theme-text-tertiary">Ask your operator to configure the metrics connection for this cluster.</p>}
196
- {isWorkload && <a className="mt-3 inline-block text-xs text-accent hover:underline" href="https://github.com/skyhook-io/radar/blob/main/docs/workload-metrics.md#what-each-chart-needs" target="_blank" rel="noopener noreferrer">What each chart needs</a>}
197
- </div>
198
- </div>
199
- );
200
- }
176
+ if (!isConnected) return <MetricsNotConnected status={status} isWorkload={isWorkload} />;
201
177
 
202
178
  const findCategory = (
203
179
  key: PrometheusMetricCategory,
@@ -214,7 +190,7 @@ export function PrometheusChartsGrid({
214
190
  const tx = findCategory("network_tx");
215
191
  if (tx) primaryCats.push({ def: tx });
216
192
  }
217
- const disk = findCategory("filesystem");
193
+ const disk = hasDisk ? findCategory("filesystem") : undefined;
218
194
  const chartPanels = disk ? [...primaryCats, { def: disk }] : primaryCats;
219
195
  const renderPanel = ({ def, refLines }: { def: CategoryDef; refLines?: ReferenceLine[] }) => (
220
196
  <MetricsPanel key={def.key} category={def} kind={kind} namespace={namespace} name={name} timeRange={timeRange} referenceLines={refLines} />
@@ -246,7 +222,7 @@ export function PrometheusChartsGrid({
246
222
  )}
247
223
 
248
224
  <div className="metrics-layout min-w-0 px-4 pt-4">
249
- {isWorkload && <h3 className="mb-2 text-sm font-semibold text-theme-text-primary">Network and storage</h3>}
225
+ {isWorkload && <h3 className="mb-2 text-sm font-semibold text-theme-text-primary">{disk ? "Network and storage" : "Network"}</h3>}
250
226
  {isWorkload && <Disclosure className="mb-2 text-xs text-theme-text-secondary" summary={`Pod-name matched · ${NAME_MATCHED_SUMMARY[nameMatchedScope]}`}>
251
227
  <p className="mt-2 max-w-2xl text-sm leading-relaxed">These charts match current Pod names, independently of the identity-checked charts above. {nameMatchedNote ?? "Matching names in a shared backend may include another cluster."}</p>
252
228
  </Disclosure>}
@@ -262,7 +238,7 @@ export function PrometheusChartsGrid({
262
238
  timeRange={timeRange}
263
239
  category={isWorkload ? "network_rx" : "cpu"}
264
240
  />
265
- {showRightsizing && isWorkload && (
241
+ {showRightsizing && status?.connected && isWorkload && (
266
242
  <div className="px-4 pb-4"><RightsizingStrip kind={kind} namespace={namespace} name={name} /></div>
267
243
  )}
268
244
  </div>
@@ -341,7 +317,7 @@ function MetricsPanel({
341
317
  <header className="flex flex-wrap items-center justify-between mb-2 gap-3">
342
318
  <div className="flex flex-wrap items-center gap-2">
343
319
  <h3 className="text-xs font-medium text-theme-text-secondary uppercase tracking-wide">
344
- {category.label}
320
+ {metrics?.source === "gke" && category.key === "memory" ? "Non-evictable memory" : metrics?.source === "gke" && category.key === "filesystem" && kind === "Node" ? "Ephemeral storage used" : category.label}
345
321
  </h3>
346
322
  {saturation && <SaturationChip {...saturation} />}
347
323
  </div>
@@ -1,3 +1,4 @@
1
+ import { hasPrometheusCharts } from '../../api/prometheusCharts'
1
2
  import { useEffect, useMemo } from 'react'
2
3
  import { AlertCircle } from 'lucide-react'
3
4
  import { usePrometheusResourceMetrics, usePrometheusStatus, type PrometheusSeries, type PrometheusTimeRange } from '../../api/client'
@@ -9,7 +10,7 @@ import { Tooltip } from '../ui/Tooltip'
9
10
  /**
10
11
  * RestartEventLane — vertical markers at each restart event, on a dedicated
11
12
  * row below the chart. Markers stay readable when they cluster because they
12
- * don't overlay the chart waveform. KSM-gated (uses kube_pod_container_status_restarts_total)
13
+ * don't overlay the chart waveform. Uses KSM or native GKE restart counters
13
14
  * — silently hidden when Prom isn't connected or the series doesn't exist,
14
15
  * but says why when the metrics store couldn't be kept to this cluster, and
15
16
  * notes an answer the store gave only in part.
@@ -21,7 +22,7 @@ export function RestartEventLane({ kind, namespace, name, range = '1h' }: {
21
22
  range?: PrometheusTimeRange
22
23
  }) {
23
24
  const { data: status } = usePrometheusStatus()
24
- const isConnected = status?.connected === true
25
+ const isConnected = hasPrometheusCharts(status)
25
26
  const { data: metrics, isLoading, error } = usePrometheusResourceMetrics(kind, namespace, name, 'restarts', range, isConnected)
26
27
 
27
28
  const restarts = useMemo(() => collectRestartEvents(metrics?.result?.series), [metrics])
@@ -117,7 +118,7 @@ function collectRestartEvents(series: PrometheusSeries[] | undefined): RestartEv
117
118
  const events: RestartEvent[] = []
118
119
  for (const s of series) {
119
120
  const pod = s.labels.pod ?? 'pod'
120
- // `changes(...[1h])` produces a rolling count, so a single restart shows
121
+ // The query produces a rolling hourly count, so a single restart shows
121
122
  // value=1 for ~60 consecutive samples (the whole 1h window). Emit a marker
122
123
  // only when the count increases — that's when a *new* restart entered the
123
124
  // window — and use the increase as the marker's restart count.
@@ -0,0 +1,34 @@
1
+ import { renderToStaticMarkup } from 'react-dom/server'
2
+ import { MemoryRouter } from 'react-router-dom'
3
+ import { beforeEach, expect, it, vi } from 'vitest'
4
+ import { RightsizingPanel } from './RightsizingStrip'
5
+
6
+ let source: Record<string, unknown> | undefined
7
+
8
+ vi.mock('../../api/client', () => ({
9
+ useAutoPromConnect: () => {},
10
+ usePrometheusStatus: () => ({ data: { connected: true, source } }),
11
+ usePrometheusRightsizing: () => ({ error: null, data: { window: '7d', ownerCoverage: 'ksm_history', rows: [] } }),
12
+ }))
13
+
14
+ beforeEach(() => { source = undefined })
15
+
16
+ const render = () => renderToStaticMarkup(
17
+ <MemoryRouter>
18
+ <RightsizingPanel kind="Deployment" namespace="shop" name="api" />
19
+ </MemoryRouter>,
20
+ )
21
+
22
+ it('names Prometheus without an OpenObserve source', () => {
23
+ expect(render()).toContain('Rightsizing · Prometheus')
24
+ })
25
+
26
+ it('names OpenObserve when it serves this cluster', () => {
27
+ source = { kind: 'openobserve', via: 'hub', matchedBy: 'id' }
28
+ expect(render()).toContain('Rightsizing · OpenObserve')
29
+ })
30
+
31
+ it('keeps Prometheus when OpenObserve only explains why it is not used', () => {
32
+ source = { kind: 'openobserve', via: 'local', warning: 'Not matched for this cluster.' }
33
+ expect(render()).toContain('Rightsizing · Prometheus')
34
+ })
@@ -13,6 +13,7 @@ import {
13
13
  type PrometheusRightsizing,
14
14
  } from '../../api/client'
15
15
  import { Tooltip } from '../ui/Tooltip'
16
+ import { metricsSourceLine } from '../settings/openobserveStatus'
16
17
 
17
18
  const RIGHTSIZING_KINDS = new Set(['Deployment', 'StatefulSet', 'DaemonSet'])
18
19
  export const RIGHTSIZING_DOCS_URL = 'https://radarhq.io/docs/features/rightsizing'
@@ -33,7 +34,8 @@ function useRightsizingEvidence({ kind, namespace, name }: RightsizingProps) {
33
34
  const connected = status?.connected === true
34
35
  const supported = RIGHTSIZING_KINDS.has(kind)
35
36
  const query = usePrometheusRightsizing(kind, namespace, name, connected && supported)
36
- return { connected, supported, statusLoading, ...query }
37
+ const sourceName = metricsSourceLine(status?.source) ? 'OpenObserve' : 'Prometheus'
38
+ return { connected, supported, statusLoading, sourceName, ...query }
37
39
  }
38
40
 
39
41
  export function RightsizingPanel(props: RightsizingProps) {
@@ -48,7 +50,7 @@ export function RightsizingPanel(props: RightsizingProps) {
48
50
  <div>
49
51
  <div className="flex items-center gap-1.5">
50
52
  <h3 className="text-sm font-semibold text-theme-text-primary">
51
- Rightsizing · Prometheus
53
+ Rightsizing · {state.sourceName}
52
54
  </h3>
53
55
  <Tooltip content={RIGHTSIZING_METHODOLOGY}>
54
56
  <HelpCircle className="h-3.5 w-3.5 text-theme-text-tertiary" />
@@ -91,7 +93,7 @@ export function RightsizingStrip(props: RightsizingProps) {
91
93
  <section className="mb-3 rounded-lg border border-theme-border bg-theme-surface/40 p-3">
92
94
  <header className="mb-2 flex items-center justify-between gap-3">
93
95
  <div className="flex items-center gap-1.5">
94
- <h3 className="text-sm font-medium text-theme-text-primary">Rightsizing · Prometheus</h3>
96
+ <h3 className="text-sm font-medium text-theme-text-primary">Rightsizing · {state.sourceName}</h3>
95
97
  <Tooltip content={RIGHTSIZING_METHODOLOGY}>
96
98
  <HelpCircle className="h-3.5 w-3.5 text-theme-text-tertiary" />
97
99
  </Tooltip>
@@ -179,6 +179,12 @@ describe('Workload metrics interpretation', () => {
179
179
  expect(html).toContain('Scope assertion discarded after reconnect')
180
180
  expect(html).not.toContain('Automatic metrics attribution')
181
181
  })
182
+ it('names OpenObserve, not an operator, when the scope comes from OpenObserve', () => {
183
+ result.data!.attribution = { scope: 'Scoped to this cluster through OpenObserve.' }
184
+ const html = render()
185
+ expect(html).toContain('scoped through OpenObserve')
186
+ expect(html).not.toContain('operator-asserted scope')
187
+ })
182
188
  it('explains withheld populations instead of suggesting instrumentation is absent', () => {
183
189
  result.data!.panels.requests = {state:'partial',unit:'requests/s',series:[],reason:'Multiple observation populations'}
184
190
  const html = render()