|
|
@@ -68,20 +68,20 @@ type MetricsNGINXErrorsDataResponse = {
|
|
|
type MetricsOption = {
|
|
|
value: string;
|
|
|
label: string;
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
const resolutions: { [range: string]: string } = {
|
|
|
"1H": "15s",
|
|
|
"6H": "15s",
|
|
|
"1D": "15s",
|
|
|
- "1M": "5h",
|
|
|
+ "1M": "5h"
|
|
|
};
|
|
|
|
|
|
const secondsBeforeNow: { [range: string]: number } = {
|
|
|
"1H": 60 * 60,
|
|
|
"6H": 60 * 60 * 6,
|
|
|
"1D": 60 * 60 * 24,
|
|
|
- "1M": 60 * 60 * 24 * 30,
|
|
|
+ "1M": 60 * 60 * 24 * 30
|
|
|
};
|
|
|
|
|
|
export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
@@ -103,47 +103,49 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
metricsOptions: [
|
|
|
{ value: "cpu", label: "CPU Utilization (vCPUs)" },
|
|
|
{ value: "memory", label: "RAM Utilization (Mi)" },
|
|
|
- { value: "network", label: "Network Received Bytes (Ki)" },
|
|
|
- ],
|
|
|
+ { value: "network", label: "Network Received Bytes (Ki)" }
|
|
|
+ ]
|
|
|
};
|
|
|
|
|
|
componentDidMount() {
|
|
|
// get all controllers and read in a list of pods
|
|
|
let { currentChart } = this.props;
|
|
|
let { currentCluster, currentProject, setCurrentError } = this.context;
|
|
|
-
|
|
|
+
|
|
|
if (currentChart.chart?.metadata?.name == "ingress-nginx") {
|
|
|
- api.getNGINXIngresses(
|
|
|
- "<token>",
|
|
|
+ api
|
|
|
+ .getNGINXIngresses(
|
|
|
+ "<token>",
|
|
|
{
|
|
|
- cluster_id: currentCluster.id,
|
|
|
+ cluster_id: currentCluster.id
|
|
|
},
|
|
|
{
|
|
|
- id: currentProject.id,
|
|
|
+ id: currentProject.id
|
|
|
}
|
|
|
- ).then((res) => {
|
|
|
- let metricsOptions = this.state.metricsOptions
|
|
|
- metricsOptions.push({
|
|
|
- value: "nginx:errors",
|
|
|
- label: "5XX Error Percentage"
|
|
|
+ )
|
|
|
+ .then(res => {
|
|
|
+ let metricsOptions = this.state.metricsOptions;
|
|
|
+ metricsOptions.push({
|
|
|
+ value: "nginx:errors",
|
|
|
+ label: "5XX Error Percentage"
|
|
|
+ });
|
|
|
+
|
|
|
+ let ingressOptions = [] as any[];
|
|
|
+ res.data.map((ingress: string) => {
|
|
|
+ ingressOptions.push({ value: ingress, label: ingress });
|
|
|
+ });
|
|
|
+
|
|
|
+ // iterate through the controllers to get the list of pods
|
|
|
+ this.setState({
|
|
|
+ metricsOptions,
|
|
|
+ ingressOptions,
|
|
|
+ selectedIngress: ingressOptions[0].value
|
|
|
+ });
|
|
|
})
|
|
|
-
|
|
|
- let ingressOptions = [] as any[];
|
|
|
- res.data.map((ingress: string) => {
|
|
|
- ingressOptions.push({ value: ingress, label: ingress });
|
|
|
+ .catch(err => {
|
|
|
+ setCurrentError(JSON.stringify(err));
|
|
|
+ this.setState({ controllerOptions: [] as any[] });
|
|
|
});
|
|
|
-
|
|
|
- // iterate through the controllers to get the list of pods
|
|
|
- this.setState({
|
|
|
- metricsOptions,
|
|
|
- ingressOptions,
|
|
|
- selectedIngress: ingressOptions[0].value,
|
|
|
- });
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- setCurrentError(JSON.stringify(err));
|
|
|
- this.setState({ controllerOptions: [] as any[] });
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
api
|
|
|
@@ -152,15 +154,15 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
{
|
|
|
namespace: currentChart.namespace,
|
|
|
cluster_id: currentCluster.id,
|
|
|
- storage: StorageType.Secret,
|
|
|
+ storage: StorageType.Secret
|
|
|
},
|
|
|
{
|
|
|
id: currentProject.id,
|
|
|
name: currentChart.name,
|
|
|
- revision: currentChart.version,
|
|
|
+ revision: currentChart.version
|
|
|
}
|
|
|
)
|
|
|
- .then((res) => {
|
|
|
+ .then(res => {
|
|
|
// TODO -- check at least one controller returned
|
|
|
let controllerOptions = [] as any[];
|
|
|
res.data.map((controller: any) => {
|
|
|
@@ -171,12 +173,12 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
// iterate through the controllers to get the list of pods
|
|
|
this.setState({
|
|
|
controllerOptions,
|
|
|
- selectedController: controllerOptions[0].value,
|
|
|
+ selectedController: controllerOptions[0].value
|
|
|
});
|
|
|
|
|
|
this.getPods();
|
|
|
})
|
|
|
- .catch((err) => {
|
|
|
+ .catch(err => {
|
|
|
setCurrentError(JSON.stringify(err));
|
|
|
this.setState({ controllerOptions: [] as any[] });
|
|
|
});
|
|
|
@@ -232,8 +234,8 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
}
|
|
|
|
|
|
if (this.state.selectedMetric == "nginx:errors") {
|
|
|
- pods = [this.state.selectedIngress]
|
|
|
- shouldsum = false
|
|
|
+ pods = [this.state.selectedIngress];
|
|
|
+ shouldsum = false;
|
|
|
}
|
|
|
|
|
|
api
|
|
|
@@ -247,13 +249,13 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
namespace: currentChart.namespace,
|
|
|
startrange: start,
|
|
|
endrange: end,
|
|
|
- resolution: resolutions[this.state.selectedRange],
|
|
|
+ resolution: resolutions[this.state.selectedRange]
|
|
|
},
|
|
|
{
|
|
|
- id: currentProject.id,
|
|
|
+ id: currentProject.id
|
|
|
}
|
|
|
)
|
|
|
- .then((res) => {
|
|
|
+ .then(res => {
|
|
|
// transform the metrics to expected form
|
|
|
if (kind == "cpu") {
|
|
|
let data = res.data as MetricsCPUDataResponse;
|
|
|
@@ -269,7 +271,7 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
) => {
|
|
|
return {
|
|
|
date: d.date,
|
|
|
- value: parseFloat(d.cpu),
|
|
|
+ value: parseFloat(d.cpu)
|
|
|
};
|
|
|
}
|
|
|
);
|
|
|
@@ -288,7 +290,7 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
) => {
|
|
|
return {
|
|
|
date: d.date,
|
|
|
- value: parseFloat(d.memory) / (1024 * 1024), // put units in Mi
|
|
|
+ value: parseFloat(d.memory) / (1024 * 1024) // put units in Mi
|
|
|
};
|
|
|
}
|
|
|
);
|
|
|
@@ -307,7 +309,7 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
) => {
|
|
|
return {
|
|
|
date: d.date,
|
|
|
- value: parseFloat(d.bytes) / 1024, // put units in Ki
|
|
|
+ value: parseFloat(d.bytes) / 1024 // put units in Ki
|
|
|
};
|
|
|
}
|
|
|
);
|
|
|
@@ -326,7 +328,7 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
) => {
|
|
|
return {
|
|
|
date: d.date,
|
|
|
- value: parseFloat(d.error_pct), // put units in Ki
|
|
|
+ value: parseFloat(d.error_pct) // put units in Ki
|
|
|
};
|
|
|
}
|
|
|
);
|
|
|
@@ -334,7 +336,7 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
this.setState({ data: tData });
|
|
|
}
|
|
|
})
|
|
|
- .catch((err) => {
|
|
|
+ .catch(err => {
|
|
|
setCurrentError(JSON.stringify(err));
|
|
|
// this.setState({ controllers: [], loading: false });
|
|
|
});
|
|
|
@@ -364,13 +366,13 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
"<token>",
|
|
|
{
|
|
|
cluster_id: currentCluster.id,
|
|
|
- selectors,
|
|
|
+ selectors
|
|
|
},
|
|
|
{
|
|
|
- id: currentProject.id,
|
|
|
+ id: currentProject.id
|
|
|
}
|
|
|
)
|
|
|
- .then((res) => {
|
|
|
+ .then(res => {
|
|
|
let pods = [{ value: "All", label: "All (Summed)" }] as any[];
|
|
|
res?.data?.forEach((pod: any) => {
|
|
|
let name = pod?.metadata?.name;
|
|
|
@@ -381,7 +383,7 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
|
|
|
this.getMetrics();
|
|
|
})
|
|
|
- .catch((err) => {
|
|
|
+ .catch(err => {
|
|
|
console.log(err);
|
|
|
setCurrentError(JSON.stringify(err));
|
|
|
return;
|
|
|
@@ -417,7 +419,7 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
onClick={() =>
|
|
|
this.setState({
|
|
|
selectedMetric: option.value,
|
|
|
- selectedMetricLabel: option.label,
|
|
|
+ selectedMetricLabel: option.label
|
|
|
})
|
|
|
}
|
|
|
lastItem={i === this.state.metricsOptions.length - 1}
|
|
|
@@ -434,23 +436,23 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
if (this.state.selectedMetric == "nginx:errors") {
|
|
|
return (
|
|
|
<>
|
|
|
- <DropdownOverlay
|
|
|
- onClick={() => this.setState({ showMetricsSettings: false })}
|
|
|
- />
|
|
|
- <DropdownAlt dropdownWidth="330px" dropdownMaxHeight="300px">
|
|
|
- <Label>Additional Settings</Label>
|
|
|
- <SelectRow
|
|
|
- label="Target Ingress"
|
|
|
- value={this.state.selectedIngress}
|
|
|
- setActiveValue={(x: any) =>
|
|
|
- this.setState({ selectedIngress: x })
|
|
|
- }
|
|
|
- options={this.state.ingressOptions}
|
|
|
- width="100%"
|
|
|
+ <DropdownOverlay
|
|
|
+ onClick={() => this.setState({ showMetricsSettings: false })}
|
|
|
/>
|
|
|
- </DropdownAlt>
|
|
|
- </>
|
|
|
- )
|
|
|
+ <DropdownAlt dropdownWidth="330px" dropdownMaxHeight="300px">
|
|
|
+ <Label>Additional Settings</Label>
|
|
|
+ <SelectRow
|
|
|
+ label="Target Ingress"
|
|
|
+ value={this.state.selectedIngress}
|
|
|
+ setActiveValue={(x: any) =>
|
|
|
+ this.setState({ selectedIngress: x })
|
|
|
+ }
|
|
|
+ options={this.state.ingressOptions}
|
|
|
+ width="100%"
|
|
|
+ />
|
|
|
+ </DropdownAlt>
|
|
|
+ </>
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
@@ -490,7 +492,7 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
<MetricSelector
|
|
|
onClick={() =>
|
|
|
this.setState({
|
|
|
- dropdownExpanded: !this.state.dropdownExpanded,
|
|
|
+ dropdownExpanded: !this.state.dropdownExpanded
|
|
|
})
|
|
|
}
|
|
|
>
|
|
|
@@ -514,7 +516,7 @@ export default class MetricsSection extends Component<PropsType, StateType> {
|
|
|
{ value: "1H", label: "1H" },
|
|
|
{ value: "6H", label: "6H" },
|
|
|
{ value: "1D", label: "1D" },
|
|
|
- { value: "1M", label: "1M" },
|
|
|
+ { value: "1M", label: "1M" }
|
|
|
]}
|
|
|
currentTab={this.state.selectedRange}
|
|
|
setCurrentTab={(x: string) => this.setState({ selectedRange: x })}
|