Skip to content

Commit

Permalink
bytes / packets zeros
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Aug 7, 2023
1 parent c15abab commit 6e698a5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
11 changes: 0 additions & 11 deletions pkg/loki/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,6 @@ func (f *lineFilter) asLabelFilters() []labelFilter {
return lfs
}

func numberMatchLineFilter(key string, strictKey bool, value string) lineFilter {
return lineFilter{
key: key,
strictKey: strictKey,
values: []lineMatch{{
valueType: typeNumber,
value: value,
}},
}
}

func regexMatchLineFilter(key string, strictKey bool, value string) lineFilter {
return lineFilter{
key: key,
Expand Down
5 changes: 3 additions & 2 deletions pkg/loki/flow_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ func NewFlowQueryBuilder(cfg *Config, start, end, limit string, reporter constan

lineFilters := []lineFilter{}
if packetLoss == constants.PacketLossDropped {
// match 0 packet sent and 1+ packets dropped
// match records that doesn't contains "Packets" field and 1+ packets dropped
// as FLP will ensure the filtering
lineFilters = append(lineFilters,
numberMatchLineFilter(fields.Packets, true, "0"),
notContainsKeyLineFilter(fields.Packets),
regexMatchLineFilter(fields.PktDropPackets, true, "[1-9][0-9]*"),
)
} else if packetLoss == constants.PacketLossHasDrop {
Expand Down
4 changes: 2 additions & 2 deletions web/src/api/ipfix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ export interface Fields {
/** TCP flags */
Flags?: number;
/** Number of packets in this flow */
Packets: number;
Packets?: number;
/** In conversation tracking, A to B packets counter per conversation */
Packets_AB?: number;
/** In conversation tracking, B to A packets counter per conversation */
Packets_BA?: number;
/** Number of bytes in this flow */
Bytes: number;
Bytes?: number;
/** In conversation tracking, A to B bytes counter per conversation */
Bytes_AB?: number;
/** In conversation tracking, B to A bytes counter per conversation */
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/query-summary/flows-query-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const FlowsQuerySummaryContent: React.FC<{
const rangeInSeconds = rangeToSeconds(range);

const counters = React.useCallback(() => {
const bytes = filteredFlows.map(f => f.fields.Bytes).reduce((a, b) => a + b, 0);
const packets = filteredFlows.map(f => f.fields.Packets).reduce((a, b) => a + b, 0);
const bytes = filteredFlows.map(f => f.fields.Bytes || 0).reduce((a, b) => a + b, 0);
const packets = filteredFlows.map(f => f.fields.Packets || 0).reduce((a, b) => a + b, 0);

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions web/src/utils/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ export const getExtraColumns = (t: TFunction): Column[] => {
tooltip: t('The total aggregated number of bytes.'),
fieldName: 'Bytes',
isSelected: true,
value: f => (f.fields.PktDropBytes ? [f.fields.Bytes, f.fields.PktDropBytes] : f.fields.Bytes),
value: f => (f.fields.PktDropBytes ? [f.fields.Bytes || 0, f.fields.PktDropBytes] : f.fields.Bytes || 0),
sort: (a, b, col) => compareNumbers(col.value(a) as number, col.value(b) as number),
width: 5
},
Expand All @@ -769,7 +769,7 @@ export const getExtraColumns = (t: TFunction): Column[] => {
tooltip: t('The total aggregated number of packets.'),
fieldName: 'Packets',
isSelected: true,
value: f => (f.fields.PktDropPackets ? [f.fields.Packets, f.fields.PktDropPackets] : f.fields.Packets),
value: f => (f.fields.PktDropPackets ? [f.fields.Packets || 0, f.fields.PktDropPackets] : f.fields.Packets || 0),
sort: (a, b, col) => compareNumbers(col.value(a) as number, col.value(b) as number),
width: 5
},
Expand Down

0 comments on commit 6e698a5

Please sign in to comment.