Skip to content
Merged
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-12716-added-1755528765131.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming
---

CloudPulse metric label support for Linode Interface firewall entities ([#12716](https://github.com/linode/manager/pull/12716))
18 changes: 17 additions & 1 deletion packages/manager/src/mocks/serverHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
entityTransferFactory,
eventFactory,
firewallDeviceFactory,
firewallEntityfactory,
firewallFactory,
imageFactory,
incidentResponseFactory,
Expand Down Expand Up @@ -1100,7 +1101,21 @@ export const handlers = [
return HttpResponse.json({});
}),
http.get('*/v4beta/networking/firewalls', () => {
const firewalls = firewallFactory.buildList(10);
const firewalls = [
...firewallFactory.buildList(10),
firewallFactory.build({
entities: [
firewallEntityfactory.build({
type: 'linode_interface',
parent_entity: firewallEntityfactory.build({
type: 'linode',
id: 123,
label: 'Linode-123',
}),
}),
],
}),
];
firewallFactory.resetSequenceNumber();
return HttpResponse.json(makeResourcePage(firewalls));
}),
Expand Down Expand Up @@ -3360,6 +3375,7 @@ export const handlers = [
metric: {
entity_id: '456',
metric_name: 'average_cpu_usage',
linode_id: '123',
node_id: 'primary-2',
},
values: [
Expand Down
19 changes: 12 additions & 7 deletions packages/manager/src/queries/cloudpulse/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';

import { queryFactory } from './queries';

import type { Filter, Params } from '@linode/api-v4';
import type { Filter, FirewallDeviceEntity, Params } from '@linode/api-v4';
import type { CloudPulseResources } from 'src/features/CloudPulse/shared/CloudPulseResourcesSelect';

export const useResourcesQuery = (
Expand All @@ -20,13 +20,18 @@ export const useResourcesQuery = (

// handle separately for firewall resource type
if (resourceType === 'firewall') {
resource.entities?.forEach(
(entity: { id: number; label: string; type: string }) => {
if (entity.type === 'linode') {
entities[String(entity.id)] = entity.label;
}
resource.entities?.forEach((entity: FirewallDeviceEntity) => {
if (entity.type === 'linode' && entity.label) {
entities[String(entity.id)] = entity.label;
}
);
if (
entity.type === 'linode_interface' &&
entity.parent_entity?.label
) {
entities[String(entity.parent_entity.id)] =
entity.parent_entity.label;
}
});
}
return {
engineType: resource.engine,
Expand Down