Skip to content

Commit ad72df2

Browse files
upcoming: [DI-29904] - Changes for logs integration with metrics (#13460)
* upcoming: [DI-29904] - Changes for logs integration with metrics * upcoming: [DI-29904] - Changeset * upcoming: [DI-29904] - Some quick refactorings * upcoming: [DI-29904] - Revert changes in dashboard select
1 parent ca6f063 commit ad72df2

7 files changed

Lines changed: 144 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
Logs service integration changes for onboarding with `CloudPulse Metrics` ([#13460](https://github.com/linode/manager/pull/13460))

packages/manager/src/features/CloudPulse/Utils/FilterConfig.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
PARENT_ENTITY_REGION,
1010
REGION,
1111
RESOURCE_ID,
12+
STATUS_CODE_PLACEHOLDER_TEXT,
1213
} from './constants';
1314
import { CloudPulseAvailableViews, CloudPulseSelectTypes } from './models';
1415
import { filterKubernetesClusters, getValidSortedEndpoints } from './utils';
@@ -657,6 +658,45 @@ export const NETLOADBALANCER_CONFIG: Readonly<CloudPulseServiceTypeFilterMap> =
657658
],
658659
serviceType: 'netloadbalancer',
659660
};
661+
662+
export const LOGS_CONFIG: Readonly<CloudPulseServiceTypeFilterMap> = {
663+
capability: capabilityServiceTypeMapping['logs'],
664+
filters: [
665+
{
666+
configuration: {
667+
filterKey: 'resource_id',
668+
filterType: 'string',
669+
isFilterable: true,
670+
isMetricsFilter: true,
671+
isMultiSelect: true,
672+
name: 'Stream Names',
673+
neededInViews: [CloudPulseAvailableViews.central],
674+
placeholder: 'Select Stream Names',
675+
priority: 2,
676+
},
677+
name: 'Stream Names',
678+
},
679+
{
680+
configuration: {
681+
filterKey: 'status_code',
682+
filterType: 'string',
683+
isFilterable: true,
684+
isMetricsFilter: false,
685+
name: 'Status Code',
686+
dimensionKey: 'status_code',
687+
neededInViews: [
688+
CloudPulseAvailableViews.central,
689+
CloudPulseAvailableViews.service,
690+
],
691+
isOptional: true,
692+
placeholder: STATUS_CODE_PLACEHOLDER_TEXT,
693+
priority: 2,
694+
},
695+
name: 'Status Code',
696+
},
697+
],
698+
serviceType: 'logs',
699+
};
660700
export const FILTER_CONFIG: Readonly<
661701
Map<number, CloudPulseServiceTypeFilterMap>
662702
> = new Map([
@@ -670,6 +710,7 @@ export const FILTER_CONFIG: Readonly<
670710
[8, FIREWALL_NODEBALANCER_CONFIG],
671711
[9, LKE_CONFIG],
672712
[10, ENDPOINT_DASHBOARD_CONFIG],
713+
[11, LOGS_CONFIG],
673714
]);
674715

675716
/**

packages/manager/src/features/CloudPulse/Utils/constants.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export const INTERFACE_ID = 'interface_id';
5151

5252
export const FIREWALL = 'Firewall';
5353

54+
export const STATUS_CODE = 'status_code';
55+
5456
export const PORTS_HELPER_TEXT =
5557
'Enter one or more port numbers (1-65535) separated by commas.';
5658

@@ -72,6 +74,22 @@ export const PORTS_LEADING_COMMA_ERROR_MESSAGE =
7274
export const PORTS_LIMIT_ERROR_MESSAGE =
7375
'Port list must be 100 characters or less.';
7476

77+
export const STATUS_CODE_HELPER_TEXT =
78+
'Enter one or more Status Codes separated by commas.';
79+
80+
export const STATUS_CODE_ERROR_MESSAGE =
81+
'Enter valid status codes as integers separated by commas without spaces.';
82+
83+
export const STATUS_CODE_CONSECUTIVE_COMMAS_ERROR_MESSAGE =
84+
'Use a single comma to separate status codes.';
85+
export const STATUS_CODE_LEADING_COMMA_ERROR_MESSAGE =
86+
'First character must be an integer.';
87+
88+
export const STATUS_CODE_LIMIT_ERROR_MESSAGE =
89+
'Status code list must be 100 characters or less.';
90+
91+
export const STATUS_CODE_PLACEHOLDER_TEXT = 'e.g., 200,400';
92+
7593
export const PORTS_PLACEHOLDER_TEXT = 'e.g., 80,443,3000';
7694

7795
export const INTERFACE_IDS_HELPER_TEXT =

packages/manager/src/features/CloudPulse/Utils/utils.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ import {
2020
PORTS_LEADING_ZERO_ERROR_MESSAGE,
2121
PORTS_LIMIT_ERROR_MESSAGE,
2222
PORTS_RANGE_ERROR_MESSAGE,
23+
STATUS_CODE,
24+
STATUS_CODE_CONSECUTIVE_COMMAS_ERROR_MESSAGE,
25+
STATUS_CODE_ERROR_MESSAGE,
26+
STATUS_CODE_LEADING_COMMA_ERROR_MESSAGE,
27+
STATUS_CODE_LIMIT_ERROR_MESSAGE,
2328
} from './constants';
2429

2530
import type { FetchOptions } from '../Alerts/CreateAlert/Criteria/DimensionFilterValue/constants';
@@ -391,6 +396,31 @@ export const areValidInterfaceIds = (
391396
return undefined;
392397
};
393398

399+
export const areValidStatusCodes = (
400+
statusCodes: string
401+
): string | undefined => {
402+
if (statusCodes === '') {
403+
return undefined;
404+
}
405+
406+
if (statusCodes.length > 100) {
407+
return STATUS_CODE_LIMIT_ERROR_MESSAGE;
408+
}
409+
if (statusCodes.startsWith(',')) {
410+
return STATUS_CODE_LEADING_COMMA_ERROR_MESSAGE;
411+
}
412+
413+
if (statusCodes.includes(',,')) {
414+
return STATUS_CODE_CONSECUTIVE_COMMAS_ERROR_MESSAGE;
415+
}
416+
417+
if (!/^[\d,]+$/.test(statusCodes)) {
418+
return STATUS_CODE_ERROR_MESSAGE;
419+
}
420+
421+
return undefined;
422+
};
423+
394424
/**
395425
* @param filterKey
396426
* @returns validation function for the filter key
@@ -401,6 +431,7 @@ export const validationFunction: Record<
401431
> = {
402432
[PORT]: arePortsValid,
403433
[INTERFACE_ID]: areValidInterfaceIds,
434+
[STATUS_CODE]: areValidStatusCodes,
404435
};
405436

406437
/**

packages/manager/src/features/CloudPulse/shared/CloudPulseComponentRenderer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const Components: {
6464
associated_entity_region: CloudPulseRegionSelect,
6565
endpoint: CloudPulseEndpointsSelect,
6666
nodebalancer_id: CloudPulseFirewallNodebalancersSelect,
67+
status_code: CloudPulseTextFilter,
6768
};
6869

6970
const buildComponent = (props: CloudPulseComponentRendererProps) => {

packages/manager/src/features/CloudPulse/shared/CloudPulseDashboardFilterBuilder.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
REGION,
2121
RESOURCE_ID,
2222
RESOURCES,
23+
STATUS_CODE,
2324
TAGS,
2425
} from '../Utils/constants';
2526
import {
@@ -379,7 +380,8 @@ export const CloudPulseDashboardFilterBuilder = React.memo(
379380
);
380381
} else if (
381382
config.configuration.filterKey === PORT ||
382-
config.configuration.filterKey === INTERFACE_ID
383+
config.configuration.filterKey === INTERFACE_ID ||
384+
config.configuration.filterKey === STATUS_CODE
383385
) {
384386
return getTextFilterProperties(
385387
{

packages/manager/src/mocks/serverHandlers.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4072,6 +4072,16 @@ export const handlers = [
40724072
);
40734073
}
40744074

4075+
if (params.serviceType === 'logs') {
4076+
response.data.push(
4077+
dashboardFactory.build({
4078+
id: 11,
4079+
service_type: 'logs',
4080+
label: 'Log Delivery Status',
4081+
})
4082+
);
4083+
}
4084+
40754085
return HttpResponse.json(response);
40764086
}),
40774087
http.get(
@@ -4528,6 +4538,41 @@ export const handlers = [
45284538
];
45294539
serviceType = 'netloadbalancer';
45304540
dashboardLabel = 'Network Load Balancer';
4541+
} else if (id === '11') {
4542+
serviceType = 'logs';
4543+
dashboardLabel = 'Log Delivery Status';
4544+
widgets = [
4545+
{
4546+
metric: 'success_upload_count',
4547+
unit: 'Count',
4548+
label: 'Success Upload',
4549+
color: 'default',
4550+
size: 6,
4551+
chart_type: 'area',
4552+
y_label: 'success_upload_count',
4553+
aggregate_function: 'sum',
4554+
},
4555+
{
4556+
metric: 'error_upload_count',
4557+
unit: 'Count',
4558+
label: 'Error Upload',
4559+
color: 'default',
4560+
size: 6,
4561+
chart_type: 'area',
4562+
y_label: 'error_upload_count',
4563+
aggregate_function: 'sum',
4564+
},
4565+
{
4566+
metric: 'error_upload_rate',
4567+
unit: '%',
4568+
label: 'Error Rate',
4569+
color: 'default',
4570+
size: 12,
4571+
chart_type: 'area',
4572+
y_label: 'error_upload_rate',
4573+
aggregate_function: 'avg',
4574+
},
4575+
];
45314576
} else {
45324577
serviceType = 'linode';
45334578
dashboardLabel = 'Linode Service I/O Statistics';

0 commit comments

Comments
 (0)