@skyhook-io/radar-app 1.21.6 → 1.21.8
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.
- package/README.md +1 -1
- package/package.json +7 -7
- package/src/App.tsx +31 -4
- package/src/RadarApp.tsx +8 -2
- package/src/api/client.discoverMetrics.test.tsx +69 -0
- package/src/api/client.issueCorrelation.test.tsx +244 -0
- package/src/api/client.issueRowChanges.test.tsx +129 -0
- package/src/api/client.pendingOwnership.test.tsx +197 -0
- package/src/api/client.prometheusStatus.test.ts +4 -0
- package/src/api/client.restartError.test.ts +36 -1
- package/src/api/client.stopWorkflow.test.tsx +133 -0
- package/src/api/client.submitWorkflowTemplate.test.tsx +127 -0
- package/src/api/client.ts +582 -114
- package/src/api/connectionBinding.test.tsx +3 -1
- package/src/api/connectionBinding.ts +14 -2
- package/src/api/gitOpsPermissions.render.test.tsx +155 -0
- package/src/api/gitOpsPermissions.test.ts +90 -0
- package/src/api/gitOpsPermissions.ts +51 -0
- package/src/api/httpErrors.test.ts +30 -1
- package/src/api/httpErrors.ts +17 -0
- package/src/api/openobserveSetup.ts +85 -0
- package/src/api/podDebug.test.tsx +137 -0
- package/src/api/podDebug.ts +82 -0
- package/src/api/prometheusCharts.test.ts +23 -0
- package/src/api/prometheusCharts.ts +25 -0
- package/src/api/radarFeatures.render.test.tsx +43 -2
- package/src/api/radarFeatures.test.ts +18 -1
- package/src/api/radarFeatures.ts +17 -4
- package/src/api/reviewedActionMutation.ts +9 -2
- package/src/api/workloadMetrics.ts +2 -0
- package/src/components/NamespaceSwitcher.tsx +6 -2
- package/src/components/applications/ApplicationsView.identity.test.ts +35 -7
- package/src/components/applications/ApplicationsView.openResource.test.tsx +137 -11
- package/src/components/applications/ApplicationsView.tsx +127 -173
- package/src/components/cnpg/CNPGOperatorConditions.test.tsx +3 -0
- package/src/components/cnpg/CNPGOperatorConditions.tsx +4 -14
- package/src/components/cnpg/host.test.tsx +1 -1
- package/src/components/cnpg/host.tsx +0 -2
- package/src/components/dock/BottomDock.tsx +7 -3
- package/src/components/dock/MissingShellDebug.test.tsx +193 -0
- package/src/components/dock/MissingShellDebug.tsx +114 -0
- package/src/components/dock/PodDebugSession.test.tsx +60 -0
- package/src/components/dock/PodDebugSession.tsx +96 -0
- package/src/components/dock/TerminalTab.test.tsx +48 -4
- package/src/components/dock/TerminalTab.tsx +47 -25
- package/src/components/dock/WorkloadLogsTab.test.tsx +24 -1
- package/src/components/dock/WorkloadLogsTab.tsx +16 -0
- package/src/components/execution/BatchExecutionView.command.test.tsx +69 -0
- package/src/components/execution/BatchExecutionView.tsx +88 -5
- package/src/components/execution/BatchExecutionView.workflow-stop.test.tsx +69 -0
- package/src/components/execution/WorkflowRunStopAction.tsx +8 -0
- package/src/components/gitops/GitOpsPermissionRowActions.test.tsx +100 -0
- package/src/components/gitops/GitOpsPermissionRowActions.tsx +27 -0
- package/src/components/gitops/GitOpsView.identity.test.tsx +1 -0
- package/src/components/gitops/GitOpsView.permissions.test.tsx +102 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +95 -7
- package/src/components/gitops/GitOpsView.tsx +93 -32
- package/src/components/helm/OwnedResources.tsx +1 -0
- package/src/components/home/HomeView.tsx +9 -1
- package/src/components/home/ProblemsPanel.investigate.test.tsx +12 -2
- package/src/components/home/mcpToolCatalog.ts +1 -0
- package/src/components/issues/IssuesPane.render.test.tsx +78 -2
- package/src/components/issues/IssuesPane.tsx +49 -6
- package/src/components/issues/useIssueExpansion.ts +91 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +50 -0
- package/src/components/resource/MetricsNotConnected.tsx +114 -0
- package/src/components/resource/PVCUsageBar.tsx +2 -1
- package/src/components/resource/PrometheusCharts.render.test.tsx +47 -0
- package/src/components/resource/PrometheusCharts.tsx +14 -2
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +91 -1
- package/src/components/resource/PrometheusChartsGrid.tsx +28 -52
- package/src/components/resource/RestartChart.tsx +4 -3
- package/src/components/resource/RightsizingPanel.source.test.tsx +34 -0
- package/src/components/resource/RightsizingStrip.tsx +5 -3
- package/src/components/resource/WorkloadMetricsSection.render.test.tsx +6 -0
- package/src/components/resource/WorkloadMetricsSection.tsx +14 -11
- package/src/components/resource/nameMatchedScope.ts +9 -3
- package/src/components/resources/EmptyNamespaceHint.tsx +42 -0
- package/src/components/resources/PodDebugAction.test.tsx +157 -0
- package/src/components/resources/PodDebugAction.tsx +207 -0
- package/src/components/resources/PodDebugPermission.tsx +21 -0
- package/src/components/resources/ResourcesView.empty-hint.test.tsx +132 -0
- package/src/components/resources/ResourcesView.tsx +39 -5
- package/src/components/resources/namespaceHint.test.ts +34 -0
- package/src/components/resources/namespaceHint.ts +19 -0
- package/src/components/resources/renderers/AdmissionPolicyRenderers.tsx +135 -0
- package/src/components/resources/renderers/NodeRenderer.tsx +2 -1
- package/src/components/resources/renderers/PodRenderer.tsx +12 -5
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +24 -1
- package/src/components/settings/FormSaveActions.tsx +6 -2
- package/src/components/settings/LocalIntegrationStatus.tsx +14 -3
- package/src/components/settings/MetricsBackendSwitch.tsx +165 -0
- package/src/components/settings/OpenObserveSetup.test.tsx +384 -0
- package/src/components/settings/OpenObserveSetup.tsx +328 -0
- package/src/components/settings/SettingsDialog.tsx +21 -7
- package/src/components/settings/openobserveStatus.test.ts +34 -0
- package/src/components/settings/openobserveStatus.ts +55 -0
- package/src/components/timeline/TimelineList.selection.test.tsx +40 -0
- package/src/components/timeline/TimelineList.test.ts +18 -0
- package/src/components/timeline/TimelineList.tsx +19 -5
- package/src/components/timeline/TimelineView.tsx +2 -0
- package/src/components/workload/WorkloadView.pendingOwnership.test.tsx +34 -0
- package/src/components/workload/WorkloadView.tabUrl.test.tsx +44 -0
- package/src/components/workload/WorkloadView.tsx +103 -16
- package/src/components/workspace/WorkspaceConditions.tsx +56 -0
- package/src/components/workspace/layout.test.tsx +20 -0
- package/src/components/workspace/layout.tsx +1 -1
- package/src/context/TimelineNavigation.test.ts +59 -0
- package/src/context/TimelineNavigation.tsx +86 -0
- package/src/contexts/CapabilitiesContext.tsx +5 -1
- package/src/hooks/useResourceCounts.ts +2 -1
- package/src/hooks/useWorkflowStopAction.ts +31 -0
- package/src/index.css +1 -0
- package/src/integrations/resourceHosts.test.tsx +2 -2
- package/src/integrations/resourceHosts.tsx +4 -2
- package/src/k8s-ui-exports.test.ts +10 -0
- package/src/utils/page-links.ts +15 -1
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +0 -128
|
@@ -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 [
|
|
98
|
+
const [selectedCategory, setActiveCategory] = useState<PrometheusMetricCategory>('cpu')
|
|
97
99
|
const [timeRange, setTimeRange] = useState<PrometheusTimeRange>('1h')
|
|
98
100
|
|
|
99
|
-
const isConnected = status
|
|
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
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
//
|
|
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
|
-
|
|
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 ·
|
|
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 ·
|
|
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()
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import { latestWorkloadValue, workloadPodValues } from "./workloadMetricValues";
|
|
20
20
|
import { WorkloadMetricsHelpDialog } from './WorkloadMetricsHelpDialog';
|
|
21
21
|
import { Disclosure } from '@skyhook-io/k8s-ui/components/ui/Disclosure';
|
|
22
|
-
import { leastCertainScope, NAME_MATCHED_CLUSTER_NOTE, NAME_MATCHED_SUMMARY } from './nameMatchedScope';
|
|
22
|
+
import { leastCertainScope, NAME_MATCHED_CLUSTER_NOTE, NAME_MATCHED_SUMMARY, OPENOBSERVE_NOTE } from './nameMatchedScope';
|
|
23
23
|
|
|
24
24
|
interface Props {
|
|
25
25
|
kind: string;
|
|
@@ -58,6 +58,7 @@ export function WorkloadMetricsSection(props: Props) {
|
|
|
58
58
|
const memoryNameMatched = usePrometheusResourceMetrics(props.kind, props.namespace, props.name, 'memory', props.range, false).data;
|
|
59
59
|
const nameMatchedScope = leastCertainScope(nameMatchedFallbacks.map((key) => (key === 'cpu' ? cpuNameMatched : memoryNameMatched)?.clusterScope));
|
|
60
60
|
const nameMatchedNote = NAME_MATCHED_CLUSTER_NOTE[nameMatchedScope];
|
|
61
|
+
const gke = data?.resourceSource === "gke";
|
|
61
62
|
const resourceNotice = sameResourceScope ? sharedPanelNotice([data?.panels.cpu, data?.panels.memory, data?.panels.throttling]) : undefined;
|
|
62
63
|
const hasHistoricalTotals = (['cpu', 'memory'] as const).some((key) => data?.history[key]?.mode === 'workload-history');
|
|
63
64
|
const hasResourceDetails = hasHistoricalTotals || data?.history.throttling?.mode === 'workload-history' || resourceNotice?.state === 'stale';
|
|
@@ -65,26 +66,26 @@ export function WorkloadMetricsSection(props: Props) {
|
|
|
65
66
|
<div className="metrics-layout min-w-0 px-4 pt-3 space-y-4">
|
|
66
67
|
<div className="flex items-start justify-between gap-3">
|
|
67
68
|
<button type="button" aria-haspopup="dialog" onClick={() => setHelpOpen(true)} className="min-w-0 rounded py-1 text-left text-xs text-theme-text-secondary hover:text-accent-text focus-visible:outline-accent">
|
|
68
|
-
<Info aria-hidden="true" className="mr-1 inline h-3.5 w-3.5" />About these metrics{data?.attribution?.scope && ' · operator-asserted scope'}
|
|
69
|
+
<Info aria-hidden="true" className="mr-1 inline h-3.5 w-3.5" />About these metrics{data?.attribution?.scope && (data.attribution.scope.startsWith(OPENOBSERVE_NOTE) ? ' · scoped through OpenObserve' : ' · operator-asserted scope')}
|
|
69
70
|
</button>
|
|
70
71
|
{props.controls}
|
|
71
72
|
</div>
|
|
72
73
|
{helpOpen && <WorkloadMetricsHelpDialog kind={props.kind} namespace={props.namespace} name={props.name} range={props.range} data={data} pending={isLoading || isPlaceholderData} error={error} onClose={() => setHelpOpen(false)} />}
|
|
73
74
|
{data?.scopeNotice && <p role="status" className={`text-xs ${SEVERITY_TEXT.warning}`}>{data.scopeNotice}</p>}
|
|
74
|
-
{data?.state === 'partial' && data.reason && <p role="status" className={`text-xs ${SEVERITY_TEXT.warning}`}>{data.reason}</p>}
|
|
75
|
+
{(data?.state === 'partial' || (gke && (data?.state === 'unavailable' || data?.state === 'error'))) && data.reason && <p role="status" className={`text-xs ${SEVERITY_TEXT.warning}`}>{data.reason}</p>}
|
|
75
76
|
{isPlaceholderData && <p role="status" className="text-xs text-theme-text-secondary">Loading selected request source… Resources show previous samples.</p>}
|
|
76
|
-
<WorkloadRequests data={data} isLoading={isLoading || isPlaceholderData} error={error} setSource={setSource} />
|
|
77
|
+
{!gke && <WorkloadRequests data={data} isLoading={isLoading || isPlaceholderData} error={error} setSource={setSource} />}
|
|
77
78
|
{props.workloadTotals}
|
|
78
79
|
<section aria-label="Workload resource pressure">
|
|
79
80
|
{(data?.panels.cpu || data?.panels.memory || data?.panels.throttling) && <div className="mb-2 flex flex-wrap items-baseline gap-x-3 gap-y-1">
|
|
80
|
-
<h3 className="text-sm font-semibold text-theme-text-primary">{props.workloadTotals ? 'Prometheus resources' : 'Resources'}</h3>
|
|
81
|
+
<h3 className="text-sm font-semibold text-theme-text-primary">{gke ? 'GKE system metrics' : props.workloadTotals ? 'Prometheus resources' : 'Resources'}</h3>
|
|
81
82
|
{sameResourceScope && <HistoryNotice scope={data?.history.cpu} omitReason={data?.panels.cpu?.reason} />}
|
|
82
83
|
</div>}
|
|
83
84
|
{props.restartLane}
|
|
84
85
|
{resourceNotice && <div className="mb-2"><MetricNotice panel={resourceNotice} label="CPU, memory and throttling" /></div>}
|
|
85
|
-
<div className="metrics-chart-grid">
|
|
86
|
+
<div className={gke ? "metrics-chart-grid metrics-chart-pair" : "metrics-chart-grid"}>
|
|
86
87
|
{data?.panels.cpu && <WorkloadChart label="CPU usage" population={data.history.cpu?.mode === 'workload-history' ? 'workload' : 'per Pod'} panel={data.panels.cpu} window={data} scope={sameResourceScope ? undefined : data.history.cpu} referenceLines={data.history.cpu?.mode === 'current-pods' ? props.cpuReferenceLines : undefined} sharedNotice={!!resourceNotice} />}
|
|
87
|
-
{data?.panels.memory && <WorkloadChart label="Memory working set" population={data.history.memory?.mode === 'workload-history' ? 'workload' : 'per Pod'} panel={data.panels.memory} window={data} scope={sameResourceScope ? undefined : data.history.memory} referenceLines={data.history.memory?.mode === 'current-pods' ? props.memoryReferenceLines : undefined} sharedNotice={!!resourceNotice} />}
|
|
88
|
+
{data?.panels.memory && <WorkloadChart label={data.panels.memory.source === "gke" ? "Non-evictable memory" : "Memory working set"} population={data.history.memory?.mode === 'workload-history' ? 'workload' : 'per Pod'} panel={data.panels.memory} window={data} scope={sameResourceScope ? undefined : data.history.memory} referenceLines={data.history.memory?.mode === 'current-pods' ? props.memoryReferenceLines : undefined} sharedNotice={!!resourceNotice} />}
|
|
88
89
|
{data?.panels.throttling && <WorkloadChart
|
|
89
90
|
className="metrics-chart-wide"
|
|
90
91
|
label="CPU throttled periods"
|
|
@@ -411,6 +412,8 @@ function PodComparison({
|
|
|
411
412
|
const value = values[metric].get(pod);
|
|
412
413
|
return value == null ? "—" : formatMetricValue(value, unit);
|
|
413
414
|
};
|
|
415
|
+
const memoryLabel = memory?.source === "gke" ? "Non-evictable memory" : "Memory";
|
|
416
|
+
const showThrottle = !!throttle || cpu?.source !== "gke";
|
|
414
417
|
const comparisonPanels = [{ label: 'CPU', panel: cpu }, { label: 'Memory', panel: memory }, { label: 'Throttling', panel: throttle }];
|
|
415
418
|
const pending = comparisonPanels.filter(({ panel }) => panel?.state === 'detecting');
|
|
416
419
|
const notices = new Map<string, { labels: string[]; panel: WorkloadMetricPanel }>();
|
|
@@ -440,7 +443,7 @@ function PodComparison({
|
|
|
440
443
|
<thead className="text-theme-text-tertiary">
|
|
441
444
|
<tr>
|
|
442
445
|
<th className="py-2 font-medium">Pod</th>
|
|
443
|
-
{(["cpu", "memory", "throttling"] as const).map((metric) => (
|
|
446
|
+
{(["cpu", "memory", "throttling"] as const).filter((metric) => metric !== "throttling" || showThrottle).map((metric) => (
|
|
444
447
|
<th
|
|
445
448
|
key={metric}
|
|
446
449
|
className="py-2 pl-3 text-right font-medium"
|
|
@@ -450,7 +453,7 @@ function PodComparison({
|
|
|
450
453
|
{metric === "cpu"
|
|
451
454
|
? "CPU"
|
|
452
455
|
: metric === "memory"
|
|
453
|
-
?
|
|
456
|
+
? memoryLabel
|
|
454
457
|
: "Throttled"}
|
|
455
458
|
{sort === metric ? " ↓" : ""}
|
|
456
459
|
</button>
|
|
@@ -472,9 +475,9 @@ function PodComparison({
|
|
|
472
475
|
<td className="pl-3 text-right tabular-nums">
|
|
473
476
|
{show(pod, "memory", "bytes")}
|
|
474
477
|
</td>
|
|
475
|
-
<td className="pl-3 text-right tabular-nums">
|
|
478
|
+
{showThrottle && <td className="pl-3 text-right tabular-nums">
|
|
476
479
|
{show(pod, "throttling", "percent")}
|
|
477
|
-
</td>
|
|
480
|
+
</td>}
|
|
478
481
|
</tr>
|
|
479
482
|
))}
|
|
480
483
|
</tbody>
|
|
@@ -5,15 +5,19 @@ import { isClusterScopeWithheld, type ClusterScope } from "@skyhook-io/k8s-ui/ty
|
|
|
5
5
|
* `caveat` keeps the "may include another cluster" wording: an unlabeled
|
|
6
6
|
* store, older Radar (no clusterScope), or a chart that hasn't answered yet.
|
|
7
7
|
*/
|
|
8
|
-
export type NameMatchedScope = "scoped" | "asserted" | "withheld" | "caveat";
|
|
8
|
+
export type NameMatchedScope = "scoped" | "openobserve" | "asserted" | "withheld" | "caveat";
|
|
9
9
|
|
|
10
10
|
// Least certain first. A chart drawn without a cluster check outranks a
|
|
11
11
|
// withheld one: it shows numbers that may mix clusters, the withheld one none.
|
|
12
|
-
const RANK: NameMatchedScope[] = ["caveat", "withheld", "asserted", "scoped"];
|
|
12
|
+
const RANK: NameMatchedScope[] = ["caveat", "withheld", "asserted", "openobserve", "scoped"];
|
|
13
|
+
|
|
14
|
+
// Radar serving metrics from OpenObserve reports the single-cluster state
|
|
15
|
+
// (for older UIs) with this note: the source itself scopes every query.
|
|
16
|
+
export const OPENOBSERVE_NOTE = "Scoped to this cluster through OpenObserve";
|
|
13
17
|
|
|
14
18
|
function classify(scope: ClusterScope | null | undefined): NameMatchedScope {
|
|
15
19
|
if (scope?.state === "scoped_configured" || scope?.state === "scoped_verified") return "scoped";
|
|
16
|
-
if (scope?.state === "single_cluster_asserted") return "asserted";
|
|
20
|
+
if (scope?.state === "single_cluster_asserted") return scope.note?.startsWith(OPENOBSERVE_NOTE) ? "openobserve" : "asserted";
|
|
17
21
|
return isClusterScopeWithheld(scope) ? "withheld" : "caveat";
|
|
18
22
|
}
|
|
19
23
|
|
|
@@ -25,6 +29,7 @@ export function leastCertainScope(scopes: (ClusterScope | null | undefined)[]):
|
|
|
25
29
|
|
|
26
30
|
export const NAME_MATCHED_SUMMARY: Record<NameMatchedScope, string> = {
|
|
27
31
|
scoped: "matched by cluster label",
|
|
32
|
+
openobserve: "scoped through OpenObserve",
|
|
28
33
|
asserted: "operator declared single-cluster",
|
|
29
34
|
withheld: "identity unverified",
|
|
30
35
|
caveat: "identity unverified",
|
|
@@ -33,6 +38,7 @@ export const NAME_MATCHED_SUMMARY: Record<NameMatchedScope, string> = {
|
|
|
33
38
|
/** The sentence that replaces "may include another cluster", or undefined to keep it. */
|
|
34
39
|
export const NAME_MATCHED_CLUSTER_NOTE: Record<NameMatchedScope, string | undefined> = {
|
|
35
40
|
scoped: "They're kept to this cluster by its cluster labels.",
|
|
41
|
+
openobserve: "They're kept to this cluster through OpenObserve.",
|
|
36
42
|
asserted: "An operator declared this metrics store single-cluster, so they don't include another cluster.",
|
|
37
43
|
withheld: "Charts that couldn't be kept to this cluster say why in place of their data.",
|
|
38
44
|
caveat: undefined,
|