Skip to content

Commit 4e976f1

Browse files
Merge pull request #104 from shwetaap/COO-550
fix(COO-550): Net flow Console URL to korrel8r query translation issues.
2 parents 64d079d + 20e11f6 commit 4e976f1

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

web/src/components/Korrel8rPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
Radio,
1515
TextArea,
1616
TextInput,
17-
Tooltip
17+
Tooltip,
1818
} from '@patternfly/react-core';
1919
import { CubesIcon, ExclamationCircleIcon } from '@patternfly/react-icons';
2020
import * as React from 'react';

web/src/korrel8r/netflow.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ export class NetflowNode extends Korrel8rNode {
4343
?.split(';')
4444
.map((filter) => {
4545
const [, key, operator, value] = filter.match(/^\s*([^!=\s]+)\s*(!?=~?)\s*(.+)\s*$/) || [];
46-
return urlToQueryName[key] ? `${urlToQueryName[key]}${operator}"${value}"` : '';
46+
// Removes surrounding quotes
47+
const trimmedValue = value?.replace(/^"(.*)"$/, '$1');
48+
return urlToQueryName[key] ? `${urlToQueryName[key]}${operator}"${trimmedValue}"` : '';
4749
})
4850
.filter((s) => s)
4951
.join(',');
50-
return new NetflowNode(url, `netflow:network:{${selectors || ''}}`);
52+
return new NetflowNode(url, `netflow:network:{${selectors || 'SrcK8S_Namespace=~".+"'}}`);
5153
}
5254

5355
static fromQuery(query: string): Korrel8rNode {
@@ -65,8 +67,14 @@ export class NetflowNode extends Korrel8rNode {
6567
})
6668
.filter((s) => s)
6769
.join(';');
70+
// Special case: omit filters if the query is exactly netflow:network:{SrcK8S_Namespace=~".+"}
71+
const isDefaultQuery = query === 'netflow:network:{SrcK8S_Namespace=~".+"}';
72+
73+
// Build the URL
6874
return new NetflowNode(
69-
`netflow-traffic?tenant=${clazz}${filters ? `&filters=${encodeURIComponent(filters)}` : ''}`,
75+
`netflow-traffic?tenant=${clazz}${
76+
!isDefaultQuery && filters ? `&filters=${encodeURIComponent(filters)}` : ''
77+
}`,
7078
query,
7179
);
7280
}

0 commit comments

Comments
 (0)