Skip to content

Commit 4ef9d01

Browse files
committed
added estimation & recommendation
1 parent 1482210 commit 4ef9d01

File tree

3 files changed

+89
-12
lines changed

3 files changed

+89
-12
lines changed

web/locales/en/plugin__netobserv-plugin.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,13 @@
167167
"Nodes": "Nodes",
168168
"Namespaces": "Namespaces",
169169
"Pods": "Pods",
170-
"Estimation": "Estimation",
171-
"Sampling": "Sampling",
170+
"Recommendations": "Recommendations",
172171
"vCPU": "vCPU",
173172
"Memory": "Memory",
174-
"Storage": "Storage",
175-
"Latency overhead": "Latency overhead",
173+
"LokiStack size": "LokiStack size",
174+
"Kafka": "Kafka",
175+
"Estimation": "Estimation",
176+
"Sampling": "Sampling",
176177
"(current)": "(current)",
177178
"There is some issue in this form view. Please select \"YAML view\" for full control.": "There is some issue in this form view. Please select \"YAML view\" for full control.",
178179
"Note: Some fields may not be represented in this form view. Please select \"YAML view\" for full control.": "Note: Some fields may not be represented in this form view. Please select \"YAML view\" for full control.",
@@ -201,6 +202,7 @@
201202
"Filters": "Filters",
202203
"Options": "Options",
203204
"Pipeline": "Pipeline",
205+
"Storage": "Storage",
204206
"Integration": "Integration",
205207
"Consumption": "Consumption",
206208
"Review": "Review",

web/moduleMapper/dummy.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,29 @@ export function usePrometheusPoll(props: PrometheusPollProps) {
301301
},
302302
value: [
303303
1745832954.698,
304-
"2670.494073495783"
304+
"2000"
305+
]
306+
},
307+
{
308+
metric: {
309+
node: "node-2",
310+
namespace: "ns-2",
311+
pod: "pod-1",
312+
},
313+
value: [
314+
1745832954.698,
315+
"100"
316+
]
317+
},
318+
{
319+
metric: {
320+
node: "node-3",
321+
namespace: "ns-1",
322+
pod: "pod-1",
323+
},
324+
value: [
325+
1745832954.698,
326+
"400"
305327
]
306328
},
307329
],

web/src/components/forms/consumption.tsx

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const Consumption: FC<ResourceCalculatorProps> = ({ flowCollector, setSam
3636

3737
const getSamplings = React.useCallback(() => {
3838
const current = getCurrentSampling();
39-
let samplings = [1, 50, 100, 250];
39+
let samplings = [1, 25, 50, 100, 125, 150];
4040
if (!samplings.includes(current)) {
4141
samplings.push(current);
4242
samplings = _.sortBy(samplings);
@@ -70,6 +70,37 @@ export const Consumption: FC<ResourceCalculatorProps> = ({ flowCollector, setSam
7070
[receivedPackets, rpError, rpLoaded]
7171
);
7272

73+
const getEstimation = React.useCallback(
74+
(sampling: number) => {
75+
// eslint-disable-next-line max-len
76+
// taken from https://docs.redhat.com/en/documentation/openshift_container_platform/4.18/html/network_observability/configuring-network-observability-operators#network-observability-total-resource-usage-table_network_observability
77+
78+
// TODO: rely on more than nodes here
79+
const nodes = labelsCount('node');
80+
const estimatedCPU = nodes <= 25 ? -0.0096 * sampling + 1.8296 : -0.1347 * sampling + 12.1247;
81+
const estimatedMemory = nodes <= 25 ? -0.1224 * sampling + 22.1224 : -0.4898 * sampling + 87.4898;
82+
return {
83+
cpu: estimatedCPU > 0 ? estimatedCPU.toFixed(2) : '< 0.1',
84+
memory: estimatedMemory > 0 ? estimatedMemory.toFixed(0) : '< 1'
85+
};
86+
},
87+
[labelsCount]
88+
);
89+
90+
const getRecommendations = React.useCallback(() => {
91+
// eslint-disable-next-line max-len
92+
// taken from https://docs.redhat.com/en/documentation/openshift_container_platform/4.18/html/network_observability/configuring-network-observability-operators
93+
const nodes = labelsCount('node');
94+
return [
95+
{
96+
cpu: nodes <= 10 ? 4 : 16,
97+
memory: nodes <= 10 ? 16 : 64,
98+
lokistackSize: nodes <= 10 ? '1x.extra-small' : nodes <= 25 ? '1x.small' : '1x.medium',
99+
kafka: nodes <= 10 ? 'n/a' : nodes <= 25 ? '6 consumers' : '18 consumers'
100+
}
101+
];
102+
}, [labelsCount]);
103+
73104
return (
74105
<Flex direction={{ default: 'column' }}>
75106
<FlexItem className="calculator-item">
@@ -99,6 +130,31 @@ export const Consumption: FC<ResourceCalculatorProps> = ({ flowCollector, setSam
99130
</Tbody>
100131
</Table>
101132
</FlexItem>
133+
<FlexItem>
134+
<Text component={TextVariants.h2}>{t('Recommendations')}</Text>
135+
<Table>
136+
<Thead>
137+
<Tr>
138+
<Th>{t('vCPU')}</Th>
139+
<Th>{t('Memory')}</Th>
140+
<Th>{t('LokiStack size')}</Th>
141+
<Th>{t('Kafka')}</Th>
142+
</Tr>
143+
</Thead>
144+
<Tbody>
145+
{getRecommendations().map((reco, i) => {
146+
return (
147+
<Tr key={i}>
148+
<Td>{`${reco.cpu}vCPUs`}</Td>
149+
<Td>{`${reco.memory}GiB`}</Td>
150+
<Td>{reco.lokistackSize}</Td>
151+
<Td>{reco.kafka}</Td>
152+
</Tr>
153+
);
154+
})}
155+
</Tbody>
156+
</Table>
157+
</FlexItem>
102158
<FlexItem>
103159
<Text component={TextVariants.h2}>{t('Estimation')}</Text>
104160
<Table>
@@ -107,13 +163,12 @@ export const Consumption: FC<ResourceCalculatorProps> = ({ flowCollector, setSam
107163
<Th>{t('Sampling')}</Th>
108164
<Th>{t('vCPU')}</Th>
109165
<Th>{t('Memory')}</Th>
110-
<Th>{t('Storage')}</Th>
111-
<Th>{t('Latency overhead')}</Th>
112166
</Tr>
113167
</Thead>
114168
<Tbody>
115169
{getSamplings().map((sampling, i) => {
116170
const current = getCurrentSampling() === sampling;
171+
const estimate = getEstimation(sampling);
117172
return (
118173
<Tr
119174
key={i}
@@ -123,10 +178,8 @@ export const Consumption: FC<ResourceCalculatorProps> = ({ flowCollector, setSam
123178
onClick={() => setSampling && setSampling(sampling)}
124179
>
125180
<Td>{`${sampling} ${current ? t('(current)') : ''}`}</Td>
126-
<Td></Td>
127-
<Td></Td>
128-
<Td></Td>
129-
<Td></Td>
181+
<Td>{`${estimate.cpu}vCPUs`}</Td>
182+
<Td>{`${estimate.memory}GiB`}</Td>
130183
</Tr>
131184
);
132185
})}

0 commit comments

Comments
 (0)