Skip to content

Commit

Permalink
columns & filters fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Nov 9, 2023
1 parent be4ea45 commit 3a6e9a6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
23 changes: 12 additions & 11 deletions config/sample-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ loki:
- DstK8S_OwnerName
- FlowDirection
- Duplicate
- _RecordType
# - _RecordType
tenantID: netobserv
authCheck: none
useMocks: false
frontend:
recordTypes:
- flowLog
# - newConnection
# - heartbeat
# - endConnection
features:
# - pktDrop
# - dnsTracking
# - flowRTT
portNaming:
enable: true
portNames:
Expand Down Expand Up @@ -359,15 +366,15 @@ frontend:
tooltip: The type of the ICMP message
field: IcmpType
filter: icmp_type
default: true
default: false
width: 10
- id: IcmpCode
group: ICMP
name: Code
tooltip: The code of the ICMP message
field: IcmpCode
quickFilter: icmp_code
default: true
default: false
width: 10
- id: FlowDirection
name: Direction
Expand Down Expand Up @@ -431,6 +438,8 @@ frontend:
group: DNS
name: DNS Latency
tooltip: Time elapsed between DNS request and response.
field: DnsLatencyMs
filter: dns_latency
default: true
width: 5
- id: DNSResponseCode
Expand Down Expand Up @@ -722,10 +731,6 @@ frontend:
component: text
placeholder: 'E.g: br-ex, ovn-k8s-mp0'
hint: Specify a network interface.
- id: dscp
name: DSCP value
component: number
hint: Specify a Differentiated Services Code Point value as integer number.
- id: id
name: Conversation Id
component: text
Expand Down Expand Up @@ -800,7 +805,3 @@ frontend:
alertNamespaces:
- netobserv
sampling: 50
features:
- pktDrop
- dnsTracking
- flowRTT
2 changes: 1 addition & 1 deletion mocks/loki/flow_records.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
"values": [
[
"1689619351079000064",
"{\"SrcMac\":\"42:01:0A:00:00:01\",\"DstPort\":6443,\"SrcPort\":54082,\"Etype\":2048,\"SrcK8S_Type\":\"Node\",\"AgentIP\":\"10.0.0.5\",\"Bytes\":66,\"Packets\":1,\"SrcK8S_HostIP\":\"10.0.0.4\",\"SrcK8S_HostName\":\"ci-ln-hnd9rjk-72292-hnd5v-master-1\",\"SrcK8S_OwnerType\":\"Node\",\"Proto\":6,\"Flags\":16,\"SrcAddr\":\"10.0.0.4\",\"SrcK8S_Name\":\"ci-ln-hnd9rjk-72292-hnd5v-master-1\",\"DstMac\":\"42:01:0A:00:00:05\",\"TimeFlowStartMs\":1689619351079,\"Duplicate\":false,\"IfDirection\":0,\"TimeFlowEndMs\":1689619351079,\"TimeFlowRttNs\":1234,\"TimeReceived\":1689619351,\"DstAddr\":\"10.0.0.2\",\"Interface\":\"br-ex\"}"
"{\"SrcMac\":\"42:01:0A:00:00:01\",\"DstPort\":6443,\"SrcPort\":54082,\"Etype\":2048,\"SrcK8S_Type\":\"Node\",\"AgentIP\":\"10.0.0.5\",\"Bytes\":66,\"Packets\":1,\"SrcK8S_HostIP\":\"10.0.0.4\",\"SrcK8S_HostName\":\"ci-ln-hnd9rjk-72292-hnd5v-master-1\",\"SrcK8S_OwnerType\":\"Node\",\"Proto\":6,\"Flags\":16,\"SrcAddr\":\"10.0.0.4\",\"SrcK8S_Name\":\"ci-ln-hnd9rjk-72292-hnd5v-master-1\",\"DstMac\":\"42:01:0A:00:00:05\",\"TimeFlowStartMs\":1689619351079,\"Duplicate\":false,\"IfDirection\":0,\"TimeFlowEndMs\":1689619351079,\"TimeFlowRttNs\":1234,\"TimeReceived\":1689619351,\"DstAddr\":\"10.0.0.2\",\"Interface\":\"br-ex\",\"Dscp\":0,\"DnsLatencyMs\":10,\"DnsErrno\":0}"
],
[
"1689619350793999872",
Expand Down
11 changes: 10 additions & 1 deletion web/src/api/ipfix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ export interface Record {
}

export const getRecordValue = (record: Record, fieldOrLabel: string, defaultValue: string | number) => {
return record.fields[fieldOrLabel as keyof Fields] || record.labels[fieldOrLabel as keyof Labels] || defaultValue;
// check if label exists
if (record.labels[fieldOrLabel as keyof Labels] !== undefined) {
return record.labels[fieldOrLabel as keyof Labels];
}
// check if field exists
if (record.fields[fieldOrLabel as keyof Fields] !== undefined) {
return record.fields[fieldOrLabel as keyof Fields];
}
// fallback on default
return defaultValue;
};

export interface Labels {
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/netflow-record/record-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ export const RecordField: React.FC<{
return singleContainer(
typeof value === 'number' && !isNaN(value)
? simpleTextWithTooltip(
detailed ? `${value}: ${getDNSErrorDescription(value as DNS_ERRORS_VALUES)}` : String(value)
detailed && value ? `${value}: ${getDNSErrorDescription(value as DNS_ERRORS_VALUES)}` : String(value)
)
: emptyText()
);
Expand Down
8 changes: 7 additions & 1 deletion web/src/components/netflow-traffic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,13 @@ export const NetflowTraffic: React.FC<{
);

const getFilterDefs = React.useCallback(() => {
return getFilterDefinitions(config.filters, config.columns, t);
return getFilterDefinitions(config.filters, config.columns, t).filter(
fd =>
(isConnectionTracking() || fd.id !== 'id') &&
(isDNSTracking() || !fd.id.startsWith('dns_')) &&
(isPktDrop() || !fd.id.startsWith('pkt_drop_')) &&
(isFlowRTT() || fd.id !== 'time_flow_rtt')
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [config.columns, config.filters]);

Expand Down

0 comments on commit 3a6e9a6

Please sign in to comment.