Skip to content

Commit

Permalink
feature filtering from config
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Jan 30, 2024
1 parent 7b7a896 commit a52607a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
8 changes: 8 additions & 0 deletions config/sample-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ frontend:
filter: cluster_name
default: false
width: 15
feature: multiCluster
- id: SrcK8S_Name
group: Source
name: Name
Expand Down Expand Up @@ -185,6 +186,7 @@ frontend:
filter: src_zone
default: false
width: 15
feature: zones
- id: DstK8S_Name
group: Destination
name: Name
Expand Down Expand Up @@ -304,6 +306,7 @@ frontend:
filter: dst_zone
default: false
width: 15
feature: zones
- id: K8S_Name
name: Names
calculated: getSrcOrDstValue(SrcK8S_Name,DstK8S_Name)
Expand Down Expand Up @@ -471,6 +474,7 @@ frontend:
filter: dns_id
default: false
width: 5
feature: dnsTracking
- id: DNSLatency
group: DNS
name: DNS Latency
Expand All @@ -479,6 +483,7 @@ frontend:
filter: dns_latency
default: true
width: 5
feature: dnsTracking
- id: DNSResponseCode
group: DNS
name: DNS Response Code
Expand All @@ -487,6 +492,7 @@ frontend:
filter: dns_flag_response_code
default: true
width: 5
feature: dnsTracking
- id: DNSErrNo
group: DNS
name: DNS Error
Expand All @@ -495,13 +501,15 @@ frontend:
filter: dns_errno
default: false
width: 5
feature: dnsTracking
- id: TimeFlowRttMs
name: Flow RTT
tooltip: TCP handshake Round Trip Time
field: TimeFlowRttNs
filter: time_flow_rtt
default: true
width: 5
feature: flowRTT
filters:
- id: cluster_name
name: Cluster
Expand Down
1 change: 1 addition & 0 deletions pkg/handler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type Column struct {
Filter string `yaml:"filter,omitempty" json:"filter,omitempty"`
Default bool `yaml:"default,omitempty" json:"default,omitempty"`
Width int `yaml:"width,omitempty" json:"width,omitempty"`
Feature string `yaml:"feature" json:"feature"`
}

type Filter struct {
Expand Down
8 changes: 2 additions & 6 deletions web/src/components/netflow-traffic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,11 @@ export const NetflowTraffic: React.FC<NetflowTrafficProps> = ({ forcedFilters, i
return columns.filter(
col =>
(!isSidePanel || !col.isCommon) &&
(isMultiCluster() || ![ColumnsId.clustername].includes(col.id)) &&
(isZones() || ![ColumnsId.srczone, ColumnsId.dstzone].includes(col.id)) &&
(isConnectionTracking() || ![ColumnsId.recordtype, ColumnsId.hashid].includes(col.id)) &&
(isDNSTracking() ||
![ColumnsId.dnsid, ColumnsId.dnslatency, ColumnsId.dnsresponsecode, ColumnsId.dnserrno].includes(col.id)) &&
(isFlowRTT() || ![ColumnsId.rttTime].includes(col.id))
(!col.feature || config.features.includes(col.feature))
);
},
[columns, isConnectionTracking, isDNSTracking, isFlowRTT, isMultiCluster, isZones]
[columns, config.features, isConnectionTracking]
);

const getSelectedColumns = React.useCallback(() => {
Expand Down
6 changes: 5 additions & 1 deletion web/src/utils/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { compareNumbers, compareStrings } from './base-compare';
import { compareIPs } from './ip';
import { comparePorts } from './port';
import { compareProtocols } from './protocol';
import { Feature } from '../model/config';

export enum ColumnsId {
starttime = 'StartTime',
Expand Down Expand Up @@ -92,6 +93,7 @@ export interface ColumnConfigDef {
filter?: string;
default?: boolean;
width?: number;
feature?: Feature;
}

export interface Column {
Expand All @@ -108,6 +110,7 @@ export interface Column {
sort(a: Record, b: Record, col: Column): number;
// width in "em"
width: number;
feature?: Feature;
}

export type ColumnSizeMap = {
Expand Down Expand Up @@ -339,7 +342,8 @@ export const getDefaultColumns = (columnDefs: ColumnConfigDef[]): Column[] => {
return 0;
}
},
width: d.width || 15
width: d.width || 15,
feature: d.feature
});
});
return columns;
Expand Down

0 comments on commit a52607a

Please sign in to comment.