graph = {
const nodes = data.nodes.map(({id, group, workload}) => ({
id,
sourceLinks: [],
targetLinks: [],
group: _.get(workload, "namespace", id),
health: !!workload && !!workload.health ? workload.health.score : null,
latency: _.get(workload, "ingress.latency.request_p90_milliseconds", 0),
"5xx_responses": _.get(workload, "ingress.request_count.response_code_5xx", 0),
totalRequests: _.get(workload, "ingress.request_count.total", 0),
workload,
}));
const nodeById = new Map(nodes.map(d => [d.id, d]));
const links = data.links.map(({source, target, value}) => ({
source: nodeById.get(source),
target: nodeById.get(target),
value
}));
for (const link of links) {
const {source, target, value} = link;
source.sourceLinks.push(link);
target.targetLinks.push(link);
}
return {nodes: nodes.filter(n => !!_.get(n, "workload.namespace", "") ), links};
}