Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
MonPote committed Jun 29, 2023
1 parent e2fae4b commit 4d1521d
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 243 deletions.
265 changes: 53 additions & 212 deletions ui/src/alert-configuration/ConfigureAlerting.test.tsx

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion ui/src/alert-configuration/ConfigureAlerting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ export default function ConfigureAlerting() {
const labelWidth = 270;

const disableFormButton =
editAlertMutation.isLoading || sendTestAlertMutation.isLoading;
editAlertMutation.isLoading ||
sendTestAlertMutation.isLoading ||
!formState.isDirty;

if (alertConfiguration.status === 'loading') {
return <div>Loading...</div>;
Expand Down
6 changes: 3 additions & 3 deletions ui/src/alert-configuration/domain/AlertConfigurationDomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const SMTPAuthTypes = [
'NO_AUTHENTICATION',
] as const;

export type AuthType = typeof SMTPAuthTypes[number];
export type AuthType = (typeof SMTPAuthTypes)[number];

export type CRAMMD5Credentials = {
type: 'CRAM-MD5';
Expand Down Expand Up @@ -218,7 +218,7 @@ export const useTestAlertConfiguration = ({
});

const hasFailedToSendTestAlert = !!logsData?.find(
logLine => logLine.level === 'ERROR',
(logLine) => logLine.level === 'ERROR',
);

const overOneMinute = testDateRef.current < new Date(Date.now() - 60_000);
Expand All @@ -235,7 +235,7 @@ export const useTestAlertConfiguration = ({
logs = {
status: 'error',
title: 'Unable to fetch logs',
reason: 'TODO',
reason: 'Unable to fetch logs',
};
}

Expand Down
2 changes: 1 addition & 1 deletion ui/src/alert-configuration/test-yaml/simple-cram-md5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
email_configs:
- smarthost: smtp4dev.default.svc.cluster.local:25
require_tls: true
from: admin@scality.com
from: lion@scality.com
to: Renard <renard@scality.com>, Chat <chat@scality.com>, Lapin <lapin@scality.com>
send_resolved: true
html: TEMPLATE DELETED
Expand Down
2 changes: 1 addition & 1 deletion ui/src/alert-configuration/test-yaml/simple-login.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
email_configs:
- smarthost: smtp4dev.default.svc.cluster.local:25
require_tls: true
from: admin@scality.com
from: lion@scality.com
to: Renard <renard@scality.com>, Chat <chat@scality.com>, Lapin <lapin@scality.com>
send_resolved: true
html: TEMPLATE DELETED
Expand Down
2 changes: 1 addition & 1 deletion ui/src/alert-configuration/test-yaml/simple-noauth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
email_configs:
- smarthost: smtp4dev.default.svc.cluster.local:25
require_tls: true
from: admin@scality.com
from: lion@scality.com
to: Renard <renard@scality.com>, Chat <chat@scality.com>, Lapin <lapin@scality.com>
send_resolved: true
html: TEMPLATE DELETED
2 changes: 1 addition & 1 deletion ui/src/alert-configuration/test-yaml/simple-plain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
email_configs:
- smarthost: smtp4dev.default.svc.cluster.local:25
require_tls: true
from: admin@scality.com
from: lion@scality.com
to: Renard <renard@scality.com>, Chat <chat@scality.com>, Lapin <lapin@scality.com>
send_resolved: true
html: TEMPLATE DELETED
Expand Down
1 change: 0 additions & 1 deletion ui/src/services/loki/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export function getAlertsLoki(
end: string,
): Promise<LokiQueryResult> {
if (!lokiApiClient) {
console.log('getAlertsLoki?');
throw new Error('lokiApiClient should be defined');
}

Expand Down
37 changes: 15 additions & 22 deletions ui/src/services/platformlibrary/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const _getPromRangeMatrixQuery = (
queryKey: string[],
prometheusQuery: string,
{ startingTimeISO, currentTimeISO, frequency }: TimeSpanProps,
): typeof useQuery => {
) => {
queryKey.push(startingTimeISO);
return {
queryKey,
Expand All @@ -41,7 +41,7 @@ const _getInstantValueQuery = (
queryKey: string[],
prometheusQuery: string,
timestamp: string,
): typeof useQuery => {
) => {
return {
queryKey,
queryFn: () => {
Expand Down Expand Up @@ -809,7 +809,7 @@ export const getVolumeUsageQuery = (
pvcName: string,
namespace: string,
timespanProps: TimeSpanProps,
): typeof useQuery => {
) => {
const prometheusFilters = `{namespace="${namespace}",persistentvolumeclaim="${pvcName}"}`;
const volumeUsageQuery = `kubelet_volume_stats_used_bytes${prometheusFilters} / kubelet_volume_stats_capacity_bytes${prometheusFilters} * 100`;
return _getPromRangeMatrixQuery(
Expand All @@ -830,7 +830,7 @@ export const getVolumeThroughputReadQuery = (
instanceIp: string,
deviceName: string,
timespanProps: TimeSpanProps,
): typeof useQuery => {
) => {
const prometheusFilters = getNodeDevicePrometheusFilter(
instanceIp,
deviceName,
Expand All @@ -846,7 +846,7 @@ export const getVolumeThroughputWriteQuery = (
instanceIp: string,
deviceName: string,
timespanProps: TimeSpanProps,
): typeof useQuery => {
) => {
const prometheusFilters = getNodeDevicePrometheusFilter(
instanceIp,
deviceName,
Expand All @@ -858,19 +858,15 @@ export const getVolumeThroughputWriteQuery = (
timespanProps,
);
};
export const getNodesThroughputReadQuery = (
timespanProps: TimeSpanProps,
): typeof useQuery => {
export const getNodesThroughputReadQuery = (timespanProps: TimeSpanProps) => {
const nodesThroughputReadQuery = `sum(sum(irate(node_disk_read_bytes_total[1m])) by (instance, device))by(instance)`;
return _getPromRangeMatrixQuery(
['NodesThroughputReadQuery'],
nodesThroughputReadQuery,
timespanProps,
);
};
export const getNodesThroughputWriteQuery = (
timespanProps: TimeSpanProps,
): typeof useQuery => {
export const getNodesThroughputWriteQuery = (timespanProps: TimeSpanProps) => {
const nodesThroughputWriteQuery = `sum(sum(irate(node_disk_written_bytes_total[1m])) by (instance, device))by(instance)`;
return _getPromRangeMatrixQuery(
['NodesThroughputWriteQuery'],
Expand All @@ -881,7 +877,7 @@ export const getNodesThroughputWriteQuery = (
export const getNodesThroughputWriteQuantileQuery = (
timespanProps: TimeSpanProps,
quantile: number,
): typeof useQuery => {
) => {
const nodesThroughputWritePromQL = `quantile(${quantile},sum(sum(irate(node_disk_written_bytes_total[1m])) by (instance, device))by(instance))`;
return _getPromRangeMatrixQuery(
['NodesThroughputWriteQuantile', quantile],
Expand All @@ -892,7 +888,7 @@ export const getNodesThroughputWriteQuantileQuery = (
export const getNodesThroughputReadQuantileQuery = (
timespanProps: TimeSpanProps,
quantile: number,
): typeof useQuery => {
) => {
const nodesThroughputReadPromQL = `quantile(${quantile},sum(sum(irate(node_disk_read_bytes_total[1m])) by (instance, device))by(instance))`;
return _getPromRangeMatrixQuery(
['NodesThroughputReadQueryQuantile', quantile],
Expand Down Expand Up @@ -944,7 +940,7 @@ export const getVolumeIOPSReadQuery = (
instanceIp: string,
deviceName: string,
timespanProps: TimeSpanProps,
): typeof useQuery => {
) => {
const prometheusFilters = getNodeDevicePrometheusFilter(
instanceIp,
deviceName,
Expand All @@ -960,7 +956,7 @@ export const getVolumeIOPSWriteQuery = (
instanceIp: string,
deviceName: string,
timespanProps: TimeSpanProps,
): typeof useQuery => {
) => {
const prometheusFilters = getNodeDevicePrometheusFilter(
instanceIp,
deviceName,
Expand All @@ -976,7 +972,7 @@ export const getVolumeLatencyWriteQuery = (
instanceIp: string,
deviceName: string,
timespanProps: TimeSpanProps,
): typeof useQuery => {
) => {
const prometheusFilters = getNodeDevicePrometheusFilter(
instanceIp,
deviceName,
Expand All @@ -995,7 +991,7 @@ export const getVolumeLatencyReadQuery = (
instanceIp: string,
deviceName: string,
timespanProps: TimeSpanProps,
): typeof useQuery => {
) => {
const prometheusFilters = getNodeDevicePrometheusFilter(
instanceIp,
deviceName,
Expand All @@ -1015,8 +1011,7 @@ export const getAlertsHistoryQuery = ({
startingTimeISO,
currentTimeISO,
frequency,
}: TimeSpanProps): typeof useQuery => {
console.log('getAlertsHistoryQuery');
}: TimeSpanProps) => {
const query = `sum(alertmanager_alerts)`;
const alertManagerDowntimePromise = queryPrometheusRange(
startingTimeISO,
Expand Down Expand Up @@ -1123,9 +1118,7 @@ function convertSegmentToAlert(segment) {

// Call Prometheus endpoint to get the segments {description: string, startsAt: string, endsAt: string, severity: string}
// for Cluster alert which will be used by Global Health Component
export const getClusterAlertSegmentQuery = (
duration: number,
): typeof useQuery => {
export const getClusterAlertSegmentQuery = (duration: number) => {
// We add watchdog alert to identify unavailble segments
const query = `sum by(alertname) (ALERTS{alertname=~'ClusterAtRisk|ClusterDegraded|Watchdog', alertstate='firing'})`;
// set the frequency to 60s only for global health component to get the precise segments
Expand Down

0 comments on commit 4d1521d

Please sign in to comment.