@skyhook-io/radar-app 1.11.0 → 1.12.2
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/package.json +7 -7
- package/src/App.tsx +3 -2
- package/src/api/client.ts +36 -6
- package/src/components/ConnectionErrorView.test.tsx +53 -0
- package/src/components/ConnectionErrorView.tsx +15 -12
- package/src/components/ContextSwitcher.tsx +10 -13
- package/src/components/audit/UpgradeReadinessView.tsx +3 -3
- package/src/components/capacity/ClusterSchedulingCard.tsx +8 -9
- package/src/components/capacity/schedulingBar.test.ts +10 -0
- package/src/components/cost/ApplicationCostTab.test.ts +6 -0
- package/src/components/cost/ApplicationCostTab.tsx +28 -16
- package/src/components/cost/CostTrendChart.tsx +20 -10
- package/src/components/cost/CostView.tsx +79 -28
- package/src/components/cost/CurrentAllocationUse.tsx +6 -4
- package/src/components/cost/WorkloadCostTab.test.ts +10 -0
- package/src/components/cost/WorkloadCostTab.tsx +24 -12
- package/src/components/cost/format.test.ts +27 -8
- package/src/components/cost/format.ts +78 -27
- package/src/components/home/ClusterHealthCard.tsx +3 -0
- package/src/components/home/CostCard.tsx +12 -7
- package/src/components/home/mcpToolCatalog.ts +12 -0
- package/src/components/nav/PrimaryNavRail.tsx +2 -2
- package/src/components/rightsizing/RightsizingScanView.tsx +2 -2
- package/src/components/settings/SettingsDialog.tsx +160 -36
- package/src/components/settings/currency-options.test.ts +49 -0
- package/src/components/settings/currency-options.ts +38 -0
- package/src/components/ui/DiagnosticsOverlay.test.ts +40 -0
- package/src/components/ui/DiagnosticsOverlay.tsx +18 -6
- package/src/components/ui/command-items.ts +4 -14
- package/src/components/workload/WorkloadView.tsx +2 -1
- package/src/main.tsx +4 -114
- package/src/utils/context-name.test.ts +63 -0
- package/src/utils/context-name.ts +22 -0
- package/src/utils/wails-clipboard.test.ts +109 -0
- package/src/utils/wails-clipboard.ts +127 -0
|
@@ -6,6 +6,7 @@ describe('getWorkloadCostState', () => {
|
|
|
6
6
|
it('treats scaled-to-zero as a valid zero state', () => {
|
|
7
7
|
const current: OpenCostWorkloadDetailResponse = {
|
|
8
8
|
available: true,
|
|
9
|
+
currency: 'USD',
|
|
9
10
|
namespace: 'default',
|
|
10
11
|
kind: 'Deployment',
|
|
11
12
|
name: 'checkout',
|
|
@@ -24,6 +25,7 @@ describe('getWorkloadCostState', () => {
|
|
|
24
25
|
}
|
|
25
26
|
const trend: OpenCostWorkloadTrendResponse = {
|
|
26
27
|
available: false,
|
|
28
|
+
currency: 'USD',
|
|
27
29
|
reason: 'no_metrics',
|
|
28
30
|
namespace: 'default',
|
|
29
31
|
kind: 'Deployment',
|
|
@@ -37,6 +39,7 @@ describe('getWorkloadCostState', () => {
|
|
|
37
39
|
it('keeps current cost visible when only historical owner metrics are missing', () => {
|
|
38
40
|
const current: OpenCostWorkloadDetailResponse = {
|
|
39
41
|
available: true,
|
|
42
|
+
currency: 'USD',
|
|
40
43
|
namespace: 'default',
|
|
41
44
|
kind: 'Deployment',
|
|
42
45
|
name: 'checkout',
|
|
@@ -55,6 +58,7 @@ describe('getWorkloadCostState', () => {
|
|
|
55
58
|
}
|
|
56
59
|
const trend: OpenCostWorkloadTrendResponse = {
|
|
57
60
|
available: false,
|
|
61
|
+
currency: 'USD',
|
|
58
62
|
reason: 'no_metrics',
|
|
59
63
|
namespace: 'default',
|
|
60
64
|
kind: 'Deployment',
|
|
@@ -68,6 +72,7 @@ describe('getWorkloadCostState', () => {
|
|
|
68
72
|
it('keeps current cost visible while historical owner metrics are still loading', () => {
|
|
69
73
|
const current: OpenCostWorkloadDetailResponse = {
|
|
70
74
|
available: true,
|
|
75
|
+
currency: 'USD',
|
|
71
76
|
namespace: 'default',
|
|
72
77
|
kind: 'Deployment',
|
|
73
78
|
name: 'checkout',
|
|
@@ -91,6 +96,7 @@ describe('getWorkloadCostState', () => {
|
|
|
91
96
|
it('uses historical data when current metrics are absent but history exists', () => {
|
|
92
97
|
const current: OpenCostWorkloadDetailResponse = {
|
|
93
98
|
available: false,
|
|
99
|
+
currency: 'USD',
|
|
94
100
|
reason: 'no_metrics',
|
|
95
101
|
namespace: 'default',
|
|
96
102
|
kind: 'Deployment',
|
|
@@ -98,6 +104,7 @@ describe('getWorkloadCostState', () => {
|
|
|
98
104
|
}
|
|
99
105
|
const trend: OpenCostWorkloadTrendResponse = {
|
|
100
106
|
available: true,
|
|
107
|
+
currency: 'USD',
|
|
101
108
|
namespace: 'default',
|
|
102
109
|
kind: 'Deployment',
|
|
103
110
|
name: 'checkout',
|
|
@@ -118,6 +125,7 @@ describe('getWorkloadCostState', () => {
|
|
|
118
125
|
it('surfaces workload access and existence failures', () => {
|
|
119
126
|
const current: OpenCostWorkloadDetailResponse = {
|
|
120
127
|
available: false,
|
|
128
|
+
currency: 'USD',
|
|
121
129
|
reason: 'access_denied',
|
|
122
130
|
namespace: 'prod',
|
|
123
131
|
kind: 'Deployment',
|
|
@@ -126,6 +134,7 @@ describe('getWorkloadCostState', () => {
|
|
|
126
134
|
|
|
127
135
|
const missing: OpenCostWorkloadTrendResponse = {
|
|
128
136
|
available: false,
|
|
137
|
+
currency: 'USD',
|
|
129
138
|
reason: 'not_found',
|
|
130
139
|
namespace: 'prod',
|
|
131
140
|
kind: 'Deployment',
|
|
@@ -142,6 +151,7 @@ describe('getWorkloadCostState', () => {
|
|
|
142
151
|
it('shows Prometheus discovery as soon as one query reports it', () => {
|
|
143
152
|
const current: OpenCostWorkloadDetailResponse = {
|
|
144
153
|
available: false,
|
|
154
|
+
currency: 'USD',
|
|
145
155
|
reason: 'no_prometheus',
|
|
146
156
|
namespace: 'default',
|
|
147
157
|
kind: 'Deployment',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react'
|
|
2
|
-
import { AlertCircle,
|
|
2
|
+
import { AlertCircle, Coins, HelpCircle, Loader2, TrendingUp } from 'lucide-react'
|
|
3
3
|
import {
|
|
4
4
|
useOpenCostWorkload,
|
|
5
5
|
useOpenCostWorkloadTrend,
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { Tooltip } from '../ui/Tooltip'
|
|
13
13
|
import { CostTimeRangeSelector, StackedAreaChart } from './CostTrendChart'
|
|
14
14
|
import {
|
|
15
|
+
DEFAULT_COST_CURRENCY,
|
|
15
16
|
formatCostPerHour,
|
|
16
17
|
formatHistoricalSpend,
|
|
17
18
|
formatProjectedDailyRate,
|
|
@@ -110,10 +111,13 @@ export function WorkloadCostTab({ kind, namespace, name }: WorkloadCostTabProps)
|
|
|
110
111
|
const windowTotal = trend?.available ? (trend.windowTotalCost ?? 0) : 0
|
|
111
112
|
const cpuCost = current?.cpuCost ?? 0
|
|
112
113
|
const memoryCost = current?.memoryCost ?? 0
|
|
114
|
+
const currentCurrency = currentQuery.data?.currency ?? trend?.currency ?? DEFAULT_COST_CURRENCY
|
|
115
|
+
const trendCurrency = trend?.currency ?? currentQuery.data?.currency ?? DEFAULT_COST_CURRENCY
|
|
113
116
|
const windowSpendValue = formatHistoricalSpend(
|
|
114
117
|
points.length,
|
|
115
118
|
windowTotal,
|
|
116
119
|
trendLoading || state === 'partial_missing_history',
|
|
120
|
+
trendCurrency,
|
|
117
121
|
)
|
|
118
122
|
|
|
119
123
|
return (
|
|
@@ -127,10 +131,11 @@ export function WorkloadCostTab({ kind, namespace, name }: WorkloadCostTabProps)
|
|
|
127
131
|
<div className="text-sm font-semibold text-theme-text-primary">
|
|
128
132
|
Historical compute cost
|
|
129
133
|
</div>
|
|
130
|
-
<MetricInfoTooltip content="
|
|
134
|
+
<MetricInfoTooltip content="Values are based on OpenCost CPU and memory allocation over time, not raw utilization. OpenCost allocation uses the greater of requested or observed resources." />
|
|
131
135
|
</div>
|
|
132
136
|
<div className="text-xs text-theme-text-tertiary">
|
|
133
|
-
OpenCost CPU and memory allocation rate (
|
|
137
|
+
OpenCost CPU and memory allocation rate ({trendCurrency}/hr) attributed by workload
|
|
138
|
+
ownership
|
|
134
139
|
</div>
|
|
135
140
|
</div>
|
|
136
141
|
</div>
|
|
@@ -148,10 +153,10 @@ export function WorkloadCostTab({ kind, namespace, name }: WorkloadCostTabProps)
|
|
|
148
153
|
/>
|
|
149
154
|
<MetricBlock
|
|
150
155
|
label="Projected monthly"
|
|
151
|
-
value={hasCurrent ? formatProjectedMonthlyCost(hourly) : '—'}
|
|
156
|
+
value={hasCurrent ? formatProjectedMonthlyCost(hourly, currentCurrency) : '—'}
|
|
152
157
|
subvalue={
|
|
153
158
|
hasCurrent
|
|
154
|
-
? `${formatCostPerHour(hourly)} current rate`
|
|
159
|
+
? `${formatCostPerHour(hourly, currentCurrency)} current rate`
|
|
155
160
|
: 'Current allocation unavailable'
|
|
156
161
|
}
|
|
157
162
|
/>
|
|
@@ -163,7 +168,10 @@ export function WorkloadCostTab({ kind, namespace, name }: WorkloadCostTabProps)
|
|
|
163
168
|
Loading historical cost…
|
|
164
169
|
</div>
|
|
165
170
|
) : hasTrend ? (
|
|
166
|
-
<StackedAreaChart
|
|
171
|
+
<StackedAreaChart
|
|
172
|
+
series={[{ namespace: 'Allocation rate', dataPoints: points }]}
|
|
173
|
+
currency={trendCurrency}
|
|
174
|
+
/>
|
|
167
175
|
) : (
|
|
168
176
|
<div className="flex h-[240px] items-center justify-center rounded-md border border-dashed border-theme-border bg-theme-base/60 text-sm text-theme-text-tertiary">
|
|
169
177
|
No historical workload owner cost points for this range.
|
|
@@ -195,16 +203,17 @@ export function WorkloadCostTab({ kind, namespace, name }: WorkloadCostTabProps)
|
|
|
195
203
|
<MetricTile label="Replicas" value={hasCurrent ? String(current?.replicas ?? 0) : '—'} />
|
|
196
204
|
<MetricTile
|
|
197
205
|
label="Projected daily"
|
|
198
|
-
value={hasCurrent ? formatProjectedDailyRate(hourly) : '—'}
|
|
206
|
+
value={hasCurrent ? formatProjectedDailyRate(hourly, currentCurrency) : '—'}
|
|
199
207
|
subvalue={
|
|
200
208
|
hasCurrent
|
|
201
|
-
? `${formatCostPerHour(hourly)} current hourly rate`
|
|
209
|
+
? `${formatCostPerHour(hourly, currentCurrency)} current hourly rate`
|
|
202
210
|
: 'Current allocation unavailable'
|
|
203
211
|
}
|
|
204
212
|
/>
|
|
205
213
|
</div>
|
|
206
214
|
|
|
207
215
|
<CurrentAllocationUse
|
|
216
|
+
currency={currentCurrency}
|
|
208
217
|
dataAvailable={hasCurrent}
|
|
209
218
|
cpuCost={cpuCost}
|
|
210
219
|
memoryCost={memoryCost}
|
|
@@ -216,9 +225,12 @@ export function WorkloadCostTab({ kind, namespace, name }: WorkloadCostTabProps)
|
|
|
216
225
|
/>
|
|
217
226
|
|
|
218
227
|
<div className="text-xs text-theme-text-tertiary">
|
|
219
|
-
Powered by OpenCost via Prometheus.
|
|
220
|
-
|
|
221
|
-
|
|
228
|
+
Powered by OpenCost via Prometheus.{' '}
|
|
229
|
+
{currentCurrency !== DEFAULT_COST_CURRENCY && (
|
|
230
|
+
<>Labeled {currentCurrency}; no conversion. </>
|
|
231
|
+
)}
|
|
232
|
+
Historical spend uses the selected range; projected monthly values multiply the current
|
|
233
|
+
hourly allocation. Storage/PVC attribution remains at namespace and cluster level.
|
|
222
234
|
</div>
|
|
223
235
|
</div>
|
|
224
236
|
)
|
|
@@ -313,7 +325,7 @@ function WorkloadCostUnavailable({ state }: { state: CostUnavailableReason | 'lo
|
|
|
313
325
|
return (
|
|
314
326
|
<div className="flex h-full min-h-[320px] items-center justify-center">
|
|
315
327
|
<div className="flex max-w-md flex-col items-center gap-3 text-center text-theme-text-secondary">
|
|
316
|
-
<
|
|
328
|
+
<Coins className="h-8 w-8 text-theme-text-tertiary/50" />
|
|
317
329
|
<div className="text-sm">{message}</div>
|
|
318
330
|
</div>
|
|
319
331
|
</div>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
2
|
import {
|
|
3
|
+
formatCostAxis,
|
|
3
4
|
formatCostPerHour,
|
|
4
5
|
formatHistoricalSpend,
|
|
5
6
|
formatProjectedDailyRate,
|
|
@@ -9,19 +10,37 @@ import {
|
|
|
9
10
|
|
|
10
11
|
describe('cost formatters', () => {
|
|
11
12
|
it('formats projected run rates from hourly allocation', () => {
|
|
12
|
-
expect(formatProjectedDailyRate(0.1)).toBe('~$2.40/day')
|
|
13
|
-
expect(formatProjectedMonthlyCost(1)).toBe('~$730.00')
|
|
14
|
-
expect(formatProjectedMonthlyRate(0.1)).toBe('~$73.00/mo')
|
|
13
|
+
expect(formatProjectedDailyRate(0.1, 'USD')).toBe('~$2.40/day')
|
|
14
|
+
expect(formatProjectedMonthlyCost(1, 'USD')).toBe('~$730.00')
|
|
15
|
+
expect(formatProjectedMonthlyRate(0.1, 'USD')).toBe('~$73.00/mo')
|
|
15
16
|
})
|
|
16
17
|
|
|
17
18
|
it('keeps hourly rates explicit', () => {
|
|
18
|
-
expect(formatCostPerHour(0.1)).toBe('$0.100/hr')
|
|
19
|
+
expect(formatCostPerHour(0.1, 'USD')).toBe('$0.100/hr')
|
|
19
20
|
})
|
|
20
21
|
|
|
21
22
|
it('does not turn insufficient history into zero spend', () => {
|
|
22
|
-
expect(formatHistoricalSpend(1, 0, false)).toBe('—')
|
|
23
|
-
expect(formatHistoricalSpend(2, 0, false)).toBe('$0.00')
|
|
24
|
-
expect(formatHistoricalSpend(2, 1.25, false)).toBe('~$1.25')
|
|
25
|
-
expect(formatHistoricalSpend(2, 1.25, true)).toBe('—')
|
|
23
|
+
expect(formatHistoricalSpend(1, 0, false, 'USD')).toBe('—')
|
|
24
|
+
expect(formatHistoricalSpend(2, 0, false, 'USD')).toBe('$0.00')
|
|
25
|
+
expect(formatHistoricalSpend(2, 1.25, false, 'USD')).toBe('~$1.25')
|
|
26
|
+
expect(formatHistoricalSpend(2, 1.25, true, 'USD')).toBe('—')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('uses the configured currency and its major-unit precision', () => {
|
|
30
|
+
expect(formatProjectedDailyRate(0.1, 'EUR')).toBe('~€2.40/day')
|
|
31
|
+
expect(formatCostPerHour(0.1, 'GBP')).toBe('£0.100/hr')
|
|
32
|
+
expect(formatProjectedMonthlyCost(1, 'JPY')).toBe('~¥730')
|
|
33
|
+
expect(formatCostPerHour(0.1, 'JPY')).toBe('¥0.100/hr')
|
|
34
|
+
expect(formatHistoricalSpend(2, 0, false, 'JPY')).toBe('¥0')
|
|
35
|
+
expect(formatCostAxis(0.000001, 'GBP')).toBe('<£0.00001')
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('normalizes codes and labels malformed currencies without impersonating USD', () => {
|
|
39
|
+
expect(formatProjectedMonthlyCost(1, ' eur ')).toBe('~€730.00')
|
|
40
|
+
expect(formatProjectedMonthlyCost(1, 'not-a-code')).toBe('~NOT-A-CODE 730.00')
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('falls back to USD when an older backend omits currency', () => {
|
|
44
|
+
expect(formatProjectedMonthlyCost(1, undefined)).toBe('~$730.00')
|
|
26
45
|
})
|
|
27
46
|
})
|
|
@@ -1,46 +1,97 @@
|
|
|
1
1
|
export const COST_HOURS_PER_DAY = 24
|
|
2
2
|
export const COST_HOURS_PER_MONTH = 730
|
|
3
|
+
export const DEFAULT_COST_CURRENCY = 'USD'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
type CurrencyFormat = { formatter: Intl.NumberFormat; prefix: string }
|
|
6
|
+
|
|
7
|
+
const currencyFormatters = new Map<string, CurrencyFormat>()
|
|
8
|
+
|
|
9
|
+
function currencyFormatter(currency: string | undefined, digits?: number): CurrencyFormat {
|
|
10
|
+
const normalized = (currency ?? '').trim().toUpperCase() || DEFAULT_COST_CURRENCY
|
|
11
|
+
const key = `${normalized}:${digits ?? 'default'}`
|
|
12
|
+
const cached = currencyFormatters.get(key)
|
|
13
|
+
if (cached) return cached
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
const options: Intl.NumberFormatOptions = {
|
|
17
|
+
style: 'currency',
|
|
18
|
+
currency: normalized,
|
|
19
|
+
}
|
|
20
|
+
if (digits !== undefined) {
|
|
21
|
+
options.minimumFractionDigits = digits
|
|
22
|
+
options.maximumFractionDigits = digits
|
|
23
|
+
}
|
|
24
|
+
const formatter = new Intl.NumberFormat('en-US', options)
|
|
25
|
+
const result = { formatter, prefix: '' }
|
|
26
|
+
currencyFormatters.set(key, result)
|
|
27
|
+
return result
|
|
28
|
+
} catch {
|
|
29
|
+
const fallbackDigits = digits ?? 2
|
|
30
|
+
const options: Intl.NumberFormatOptions = {
|
|
31
|
+
minimumFractionDigits: fallbackDigits,
|
|
32
|
+
maximumFractionDigits: fallbackDigits,
|
|
33
|
+
}
|
|
34
|
+
const result = {
|
|
35
|
+
formatter: new Intl.NumberFormat('en-US', options),
|
|
36
|
+
prefix: `${normalized} `,
|
|
37
|
+
}
|
|
38
|
+
currencyFormatters.set(key, result)
|
|
39
|
+
return result
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function formatCurrency(value: number, currency: string | undefined, digits?: number): string {
|
|
44
|
+
const { formatter, prefix } = currencyFormatter(currency, digits)
|
|
45
|
+
return `${prefix}${formatter.format(value)}`
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function formatCostAxis(value: number, currency: string | undefined): string {
|
|
49
|
+
if (!Number.isFinite(value) || value <= 0) return formatCurrency(0, currency, 0)
|
|
50
|
+
if (value >= 1000) return `${formatCurrency(value / 1000, currency, 0)}k`
|
|
51
|
+
if (value >= 1) return formatCurrency(value, currency, 1)
|
|
52
|
+
if (value >= 0.01) return formatCurrency(value, currency, 2)
|
|
53
|
+
if (value >= 0.0001) return formatCurrency(value, currency, 4)
|
|
54
|
+
if (value >= 0.00001) return formatCurrency(value, currency, 5)
|
|
55
|
+
return `<${formatCurrency(0.00001, currency, 5)}`
|
|
12
56
|
}
|
|
13
57
|
|
|
14
|
-
export function formatCost(value: number): string {
|
|
15
|
-
if (!Number.isFinite(value) || value <= 0) return
|
|
16
|
-
if (value >= 1000) return
|
|
17
|
-
if (value >= 1) return
|
|
18
|
-
if (value >= 0.01) return
|
|
19
|
-
if (value >= 0.0001) return
|
|
20
|
-
return formatCostAxis(value)
|
|
58
|
+
export function formatCost(value: number, currency: string | undefined): string {
|
|
59
|
+
if (!Number.isFinite(value) || value <= 0) return formatCurrency(0, currency)
|
|
60
|
+
if (value >= 1000) return `${formatCurrency(value / 1000, currency, 1)}k`
|
|
61
|
+
if (value >= 1) return formatCurrency(value, currency)
|
|
62
|
+
if (value >= 0.01) return formatCurrency(value, currency, 3)
|
|
63
|
+
if (value >= 0.0001) return formatCurrency(value, currency, 4)
|
|
64
|
+
return formatCostAxis(value, currency)
|
|
21
65
|
}
|
|
22
66
|
|
|
23
|
-
export function formatCostPerHour(value: number): string {
|
|
24
|
-
return `${formatCost(value)}/hr`
|
|
67
|
+
export function formatCostPerHour(value: number, currency: string | undefined): string {
|
|
68
|
+
return `${formatCost(value, currency)}/hr`
|
|
25
69
|
}
|
|
26
70
|
|
|
27
|
-
export function formatHistoricalSpend(
|
|
71
|
+
export function formatHistoricalSpend(
|
|
72
|
+
pointCount: number,
|
|
73
|
+
windowTotalCost: number,
|
|
74
|
+
unavailable: boolean,
|
|
75
|
+
currency: string | undefined,
|
|
76
|
+
): string {
|
|
28
77
|
if (unavailable || pointCount < 2) return '—'
|
|
29
|
-
return windowTotalCost > 0
|
|
78
|
+
return windowTotalCost > 0
|
|
79
|
+
? `~${formatCost(windowTotalCost, currency)}`
|
|
80
|
+
: formatCost(0, currency)
|
|
30
81
|
}
|
|
31
82
|
|
|
32
|
-
export function formatProjectedDailyCost(hourlyCost: number): string {
|
|
33
|
-
return `~${formatCost(hourlyCost * COST_HOURS_PER_DAY)}`
|
|
83
|
+
export function formatProjectedDailyCost(hourlyCost: number, currency: string | undefined): string {
|
|
84
|
+
return `~${formatCost(hourlyCost * COST_HOURS_PER_DAY, currency)}`
|
|
34
85
|
}
|
|
35
86
|
|
|
36
|
-
export function formatProjectedDailyRate(hourlyCost: number): string {
|
|
37
|
-
return `${formatProjectedDailyCost(hourlyCost)}/day`
|
|
87
|
+
export function formatProjectedDailyRate(hourlyCost: number, currency: string | undefined): string {
|
|
88
|
+
return `${formatProjectedDailyCost(hourlyCost, currency)}/day`
|
|
38
89
|
}
|
|
39
90
|
|
|
40
|
-
export function formatProjectedMonthlyCost(hourlyCost: number): string {
|
|
41
|
-
return `~${formatCost(hourlyCost * COST_HOURS_PER_MONTH)}`
|
|
91
|
+
export function formatProjectedMonthlyCost(hourlyCost: number, currency: string | undefined): string {
|
|
92
|
+
return `~${formatCost(hourlyCost * COST_HOURS_PER_MONTH, currency)}`
|
|
42
93
|
}
|
|
43
94
|
|
|
44
|
-
export function formatProjectedMonthlyRate(hourlyCost: number): string {
|
|
45
|
-
return `${formatProjectedMonthlyCost(hourlyCost)}/mo`
|
|
95
|
+
export function formatProjectedMonthlyRate(hourlyCost: number, currency: string | undefined): string {
|
|
96
|
+
return `${formatProjectedMonthlyCost(hourlyCost, currency)}/mo`
|
|
46
97
|
}
|
|
@@ -90,6 +90,9 @@ function getPlatformInfo(platform: string): { name: string; icon: string | null
|
|
|
90
90
|
if (platformLower.includes('openshift')) {
|
|
91
91
|
return { name: 'OpenShift', icon: null }
|
|
92
92
|
}
|
|
93
|
+
if (platformLower.includes('rke2')) {
|
|
94
|
+
return { name: 'RKE2', icon: null }
|
|
95
|
+
}
|
|
93
96
|
if (platformLower.includes('rancher')) {
|
|
94
97
|
return { name: 'Rancher', icon: null }
|
|
95
98
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { OpenCostSummary } from '../../api/client'
|
|
2
2
|
import { useOpenCostSummary } from '../../api/client'
|
|
3
|
-
import {
|
|
3
|
+
import { Coins } from 'lucide-react'
|
|
4
4
|
import {
|
|
5
|
+
DEFAULT_COST_CURRENCY,
|
|
5
6
|
formatCostPerHour,
|
|
6
7
|
formatProjectedDailyRate,
|
|
7
8
|
formatProjectedMonthlyCost,
|
|
@@ -21,6 +22,7 @@ export function CostCard({ onNavigate }: { onNavigate?: () => void }) {
|
|
|
21
22
|
|
|
22
23
|
function CostCardContent({ data, onNavigate }: { data: OpenCostSummary; onNavigate?: () => void }) {
|
|
23
24
|
const hourlyCost = data.totalHourlyCost ?? 0
|
|
25
|
+
const currency = data.currency ?? DEFAULT_COST_CURRENCY
|
|
24
26
|
const namespaces = data.namespaces ?? []
|
|
25
27
|
const topNamespaces = namespaces.slice(0, 5)
|
|
26
28
|
|
|
@@ -35,7 +37,7 @@ function CostCardContent({ data, onNavigate }: { data: OpenCostSummary; onNaviga
|
|
|
35
37
|
<div className="flex flex-col h-full w-full">
|
|
36
38
|
<div className="flex items-center justify-between px-5 py-3 border-b border-theme-border/50">
|
|
37
39
|
<div className="flex items-center gap-2">
|
|
38
|
-
<
|
|
40
|
+
<Coins className="w-4 h-4 text-accent-text" />
|
|
39
41
|
<span className="text-xs font-semibold uppercase tracking-wider text-accent-text">Cost Insights</span>
|
|
40
42
|
{namespaces.length > 0 && (
|
|
41
43
|
<span className="badge-sm border border-theme-border bg-accent-muted text-accent-text">
|
|
@@ -50,14 +52,14 @@ function CostCardContent({ data, onNavigate }: { data: OpenCostSummary; onNaviga
|
|
|
50
52
|
<div className="flex items-baseline gap-3 mb-3">
|
|
51
53
|
<div className="flex items-baseline gap-1">
|
|
52
54
|
<span className="text-2xl font-bold text-theme-text-primary tabular-nums">
|
|
53
|
-
{formatProjectedMonthlyCost(hourlyCost)}
|
|
55
|
+
{formatProjectedMonthlyCost(hourlyCost, currency)}
|
|
54
56
|
</span>
|
|
55
57
|
<span className="text-xs text-theme-text-tertiary">/mo</span>
|
|
56
58
|
</div>
|
|
57
59
|
<div className="flex items-baseline gap-1.5 text-theme-text-secondary">
|
|
58
|
-
<span className="text-xs font-medium tabular-nums">{formatProjectedDailyRate(hourlyCost)}</span>
|
|
60
|
+
<span className="text-xs font-medium tabular-nums">{formatProjectedDailyRate(hourlyCost, currency)}</span>
|
|
59
61
|
<span className="text-[10px] text-theme-text-quaternary">·</span>
|
|
60
|
-
<span className="text-xs font-medium tabular-nums">{formatCostPerHour(hourlyCost)}</span>
|
|
62
|
+
<span className="text-xs font-medium tabular-nums">{formatCostPerHour(hourlyCost, currency)}</span>
|
|
61
63
|
</div>
|
|
62
64
|
</div>
|
|
63
65
|
|
|
@@ -72,7 +74,7 @@ function CostCardContent({ data, onNavigate }: { data: OpenCostSummary; onNaviga
|
|
|
72
74
|
<div className="h-full rounded-full bg-indigo-500/60" style={{ width: `${Math.max(pct, 2)}%` }} />
|
|
73
75
|
</div>
|
|
74
76
|
<span className="text-[10px] text-theme-text-tertiary tabular-nums w-20 text-right shrink-0">
|
|
75
|
-
{formatProjectedMonthlyRate(ns.hourlyCost)}
|
|
77
|
+
{formatProjectedMonthlyRate(ns.hourlyCost, currency)}
|
|
76
78
|
</span>
|
|
77
79
|
</div>
|
|
78
80
|
)
|
|
@@ -85,7 +87,10 @@ function CostCardContent({ data, onNavigate }: { data: OpenCostSummary; onNaviga
|
|
|
85
87
|
|
|
86
88
|
<div className="px-4 py-1.5 border-t border-theme-border/50 flex items-center justify-between">
|
|
87
89
|
<span className="text-[10px] text-theme-text-tertiary">
|
|
88
|
-
{
|
|
90
|
+
{currency} · projected monthly from {data.window ?? '1h'} window
|
|
91
|
+
{currency !== DEFAULT_COST_CURRENCY && (
|
|
92
|
+
<> · no conversion</>
|
|
93
|
+
)}
|
|
89
94
|
</span>
|
|
90
95
|
<span className="flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-accent-text">
|
|
91
96
|
OpenCost
|
|
@@ -147,6 +147,18 @@ export const MCP_TOOL_CATALOG: MCPToolInfo[] = [
|
|
|
147
147
|
{ arg: 'limit', desc: 'max findings (default 30, max 100)' },
|
|
148
148
|
],
|
|
149
149
|
},
|
|
150
|
+
{
|
|
151
|
+
name: 'get_cluster_upgrade_readiness',
|
|
152
|
+
desc: 'Upgrade impact analysis for a target Kubernetes minor: the evidenced check catalog (version skew, removed/deprecated APIs, node runtime, drain feasibility, webhook readiness) with per-check coverage and caveats, expandable into findings with evidence and remediation. The first call runs a live scan; results are briefly cached per caller.',
|
|
153
|
+
params: [
|
|
154
|
+
{ arg: 'target', desc: 'target Kubernetes minor (default: next minor above current)' },
|
|
155
|
+
{ arg: 'check', desc: 'check id to expand into findings' },
|
|
156
|
+
{ arg: 'level', desc: 'filter expanded findings: blocker, warning, or review' },
|
|
157
|
+
{ arg: 'offset', desc: 'page through findings beyond the per-call cap' },
|
|
158
|
+
{ arg: 'scan_id', desc: 'binds paging to one scan snapshot (required with offset)' },
|
|
159
|
+
{ arg: 'refresh', desc: 'bypass the cached scan after changing something' },
|
|
160
|
+
],
|
|
161
|
+
},
|
|
150
162
|
{
|
|
151
163
|
name: 'list_helm_releases',
|
|
152
164
|
desc: 'All Helm releases with status, resource health, storage namespace, Flux ownership, current lastOperation, and capped operation trails for failed upgrades, rollbacks, or stuck pending operations.',
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
GitBranch,
|
|
11
11
|
Boxes,
|
|
12
12
|
Activity,
|
|
13
|
-
|
|
13
|
+
Coins,
|
|
14
14
|
Gauge,
|
|
15
15
|
ShieldCheck,
|
|
16
16
|
Settings,
|
|
@@ -80,7 +80,7 @@ const NAV_ITEMS: NavItemDef[] = [
|
|
|
80
80
|
{ view: "gitops", icon: GitBranch, label: "GitOps" },
|
|
81
81
|
{ view: "checks", icon: ShieldCheck, label: "Checks" },
|
|
82
82
|
{ view: "capacity", icon: Gauge, label: "Capacity" },
|
|
83
|
-
{ view: "cost", icon:
|
|
83
|
+
{ view: "cost", icon: Coins, label: "Cost" },
|
|
84
84
|
];
|
|
85
85
|
|
|
86
86
|
interface PrimaryNavRailProps {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect, useMemo, useState } from 'react'
|
|
2
2
|
import { useNavigate, useSearchParams } from 'react-router-dom'
|
|
3
|
-
import { AlertTriangle,
|
|
3
|
+
import { AlertTriangle, Coins, ExternalLink, Gauge, Loader2, RefreshCw } from 'lucide-react'
|
|
4
4
|
import {
|
|
5
5
|
Collapse,
|
|
6
6
|
CollapseChevron,
|
|
@@ -194,7 +194,7 @@ export function RightsizingScanView({ namespaces }: RightsizingScanViewProps) {
|
|
|
194
194
|
<div className="flex-1 min-h-0 overflow-y-auto">
|
|
195
195
|
<div className="mx-auto flex w-full max-w-[1920px] flex-col gap-4 px-6 py-6">
|
|
196
196
|
<PageHeader
|
|
197
|
-
icon={
|
|
197
|
+
icon={Coins}
|
|
198
198
|
title="Cost Insights"
|
|
199
199
|
description="Understand current allocation and find CPU and memory requests worth tuning."
|
|
200
200
|
/>
|