Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions config/sample-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,15 @@ frontend:
default: false
width: 5
feature: dnsTracking
- id: DNSName
group: DNS
name: DNS Name
tooltip: DNS name.
field: DnsName
filter: dns_name
default: false
width: 15
feature: dnsTracking
- id: DNSLatency
group: DNS
name: DNS Latency
Expand Down Expand Up @@ -1168,6 +1177,10 @@ frontend:
name: DNS Id
component: number
hint: Specify a single DNS Id.
- id: dns_name
name: DNS Name
component: text
hint: Specify a single DNS name.
- id: dns_latency
name: DNS Latency
component: number
Expand Down Expand Up @@ -1522,6 +1535,10 @@ frontend:
- name: DnsId
type: number
description: DNS record id
- id: dns_name
name: DNS Name
component: text
hint: Specify a single DNS name.
- name: DnsLatencyMs
type: number
description: Time between a DNS request and response, in milliseconds
Expand Down
5 changes: 4 additions & 1 deletion pkg/loki/flow_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,14 @@ func (q *FlowQueryBuilder) appendFilter(sb *strings.Builder, field string) {

func (q *FlowQueryBuilder) appendDNSFilter(sb *strings.Builder) {
// ensure at least one Dns field is specified except DnsErrno
// |~`"DnsId`|~`"DnsLatencyMs`|~`"DnsFlagsResponseCode"`
// |~`"DnsId`|~`"DnsName`|~`"DnsLatencyMs`|~`"DnsFlagsResponseCode"`
sb.WriteString("|~`")
sb.WriteString(`"DnsId`)
sb.WriteString("`")
sb.WriteString("|~`")
sb.WriteString(`"DnsName`)
sb.WriteString("`")
sb.WriteString("|~`")
sb.WriteString(`"DnsLatencyMs`)
sb.WriteString("`")
sb.WriteString("|~`")
Expand Down
1 change: 1 addition & 0 deletions pkg/model/fields/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const (
IfDirections = "IfDirections"
NetworkEvents = "NetworkEvents"
DNSID = "DnsId"
DNSName = "DnsName"
DNSLatency = "DnsLatencyMs"
DNSErrNo = "DnsErrno"
DNSCode = "DnsFlagsResponseCode"
Expand Down
6 changes: 5 additions & 1 deletion web/locales/en/plugin__netobserv-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,14 @@
"Overall": "Overall",
"donut or lines": "donut or lines",
"The {{function}} {{metric}} with overall over the selected interval": "The {{function}} {{metric}} with overall over the selected interval",
"Top {{limit}} DNS name with total": "Top {{limit}} DNS name with total",
"Top {{limit}} DNS name": "Top {{limit}} DNS name",
"Total DNS name": "Total DNS name",
"Total DNS flow count": "Total DNS flow count",
"The top DNS name extracted from DNS headers compared to total over the selected interval": "The top DNS name extracted from DNS headers compared to total over the selected interval",
"Top {{limit}} DNS response code with total": "Top {{limit}} DNS response code with total",
"Top {{limit}} DNS response code": "Top {{limit}} DNS response code",
"Total DNS response code": "Total DNS response code",
"Total DNS flow count": "Total DNS flow count",
"The top DNS response code extracted from DNS response headers compared to total over the selected interval": "The top DNS response code extracted from DNS response headers compared to total over the selected interval",
"rates": "rates",
"with total": "with total",
Expand Down
1 change: 1 addition & 0 deletions web/src/api/ipfix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export interface Flow {
PktDropBytes_AB?: number;
PktDropBytes_BA?: number;
DnsId?: number;
DnsName?: string;
DnsFlags?: number;
DnsFlagsResponseCode?: string;
DnsLatencyMs?: number;
Expand Down
1 change: 1 addition & 0 deletions web/src/api/loki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export type NetflowMetrics = {
totalDroppedRateMetric?: TotalRateMetrics;
droppedStateMetrics?: GenericMetric[];
droppedCauseMetrics?: GenericMetric[];
dnsNameMetrics?: GenericMetric[];
dnsRCodeMetrics?: GenericMetric[];
dnsLatencyMetrics?: FunctionMetrics;
rttMetrics?: FunctionMetrics;
Expand Down
16 changes: 16 additions & 0 deletions web/src/components/__tests-data__/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,17 @@ export const ColumnConfigSampleDefs = [
default: false,
width: 5
},
{
id: 'DNSName',
group: 'DNS',
name: 'DNS Name',
tooltip: 'DNS name.',
field: 'DnsName',
filter: 'dns_name',
feature: 'dnsTracking',
default: false,
width: 15
},
{
id: 'DNSLatency',
group: 'DNS',
Expand Down Expand Up @@ -769,6 +780,11 @@ export const FieldConfigSample = [
type: 'number',
description: 'DNS record id'
},
{
name: 'DnsName',
type: 'text',
description: 'DNS name'
},
{
name: 'DnsLatencyMs',
type: 'number',
Expand Down
6 changes: 6 additions & 0 deletions web/src/components/__tests-data__/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ export const FilterConfigSampleDefs = [
component: 'number',
hint: 'Specify a single DNS Id.'
},
{
id: 'dns_name',
name: 'DNS Name',
component: 'text',
hint: 'Specify a single DNS Name.'
},
{
id: 'dns_latency',
name: 'DNS Latency',
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/__tests__/netflow-traffic.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ describe('<NetflowTraffic />', () => {
// 2 queries for packet dropped states & causes
{ ...defaultQuery, function: 'rate', type: 'PktDropPackets', aggregateBy: 'PktDropLatestState' },
{ ...defaultQuery, function: 'rate', type: 'PktDropPackets', aggregateBy: 'PktDropLatestDropCause' },
// 2 queries for dns response codes count
// 3 queries for dns names, response codes and total
{ ...defaultQuery, function: 'count', type: 'DnsFlows', aggregateBy: 'DnsName' },
{ ...defaultQuery, function: 'count', type: 'DnsFlows', aggregateBy: 'DnsFlagsResponseCode' },
{ ...defaultQuery, function: 'count', type: 'DnsFlows', aggregateBy: 'app' }
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe('<NetflowOverview />', () => {
await waitForRender(wrapper);

const containerDiv = wrapper.find(EmptyState);
// 12 panels are expected here according to getDefaultOverviewPanels isSelected items
expect(containerDiv.length).toEqual(12);
// 13 panels are expected here according to getDefaultOverviewPanels isSelected items
expect(containerDiv.length).toEqual(13);
});

it('should render panels', async () => {
Expand Down
20 changes: 18 additions & 2 deletions web/src/components/tabs/netflow-overview/netflow-overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,15 @@ export const NetflowOverview: React.FC<NetflowOverviewProps> = React.forwardRef(
if (dnsPanels.some(p => p.id.includes('rcode_dns_latency_flows'))) {
promises.push(
...[
//get dns names
getFlowGenericMetrics(
{ ...fq, aggregateBy: 'DnsName', function: 'count', type: 'DnsFlows' },
range
).then(res => {
currentMetrics = { ...currentMetrics, dnsNameMetrics: res.metrics };
setMetrics(currentMetrics);
return res.stats;
}),
//get dns response codes
getFlowGenericMetrics(
{ ...fq, aggregateBy: 'DnsFlagsResponseCode', function: 'count', type: 'DnsFlows' },
Expand All @@ -286,6 +295,7 @@ export const NetflowOverview: React.FC<NetflowOverviewProps> = React.forwardRef(
setMetrics({
...currentMetrics,
dnsLatencyMetrics: undefined,
dnsNameMetrics: undefined,
dnsRCodeMetrics: undefined,
totalDnsLatencyMetric: undefined,
totalDnsCountMetric: undefined
Expand Down Expand Up @@ -525,6 +535,10 @@ export const NetflowOverview: React.FC<NetflowOverviewProps> = React.forwardRef(
return props.metrics.droppedCauseMetrics?.sort((a, b) => getStat(b.stats, 'sum') - getStat(a.stats, 'sum')) || [];
}, [props.metrics.droppedCauseMetrics]);

const getTopKDnsNameMetrics = React.useCallback(() => {
return props.metrics.dnsNameMetrics?.sort((a, b) => getStat(b.stats, 'sum') - getStat(a.stats, 'sum')) || [];
}, [props.metrics.dnsNameMetrics]);

const getTopKDnsRCodeMetrics = React.useCallback(() => {
return props.metrics.dnsRCodeMetrics?.sort((a, b) => getStat(b.stats, 'sum') - getStat(a.stats, 'sum')) || [];
}, [props.metrics.dnsRCodeMetrics]);
Expand Down Expand Up @@ -924,9 +938,10 @@ export const NetflowOverview: React.FC<NetflowOverviewProps> = React.forwardRef(
doubleWidth: options.graph!.type !== 'donut'
};
}
case 'name_dns_latency_flows':
case 'rcode_dns_latency_flows': {
const metricType = 'DnsFlows'; // TODO: consider adding packets graphs here
const topKMetrics = getTopKDnsRCodeMetrics();
const metricType = id === 'name_dns_latency_flows' ? 'DnsName' : 'DnsFlows'; // TODO: consider adding packets graphs here
const topKMetrics = id === 'name_dns_latency_flows' ? getTopKDnsNameMetrics() : getTopKDnsRCodeMetrics();
const namedTotalMetric = getDnsCountTotalMetric();
const options = getKebabOptions(id, {
showNoError: true,
Expand Down Expand Up @@ -1060,6 +1075,7 @@ export const NetflowOverview: React.FC<NetflowOverviewProps> = React.forwardRef(
getNamedTotalMetric,
getNamedTotalRateMetric,
getNoInternalTopKRateMetrics,
getTopKDnsNameMetrics,
getTopKDnsRCodeMetrics,
getTopKDroppedCauseMetrics,
getTopKDroppedStateMetrics,
Expand Down
1 change: 1 addition & 0 deletions web/src/utils/flows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const electMostRelevant = (flowsFor5Tuples: Record[]): Record => {
return (
flowsFor5Tuples.find(
f =>
f.fields.DnsName !== undefined ||
f.fields.DnsId !== undefined ||
f.fields.PktDropBytes !== undefined ||
f.fields.PktDropPackets !== undefined ||
Expand Down
13 changes: 12 additions & 1 deletion web/src/utils/overview-panels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type OverviewPanelId =
| `${OverviewPanelRateMetric}`
| `state_dropped_packet_rates`
| `cause_dropped_packet_rates`
| 'name_dns_latency_flows'
| 'rcode_dns_latency_flows'
| `custom_${StatFunction}_${AggregateBy}_${MetricType}`
| `custom_${AggregateBy}_${MetricType}`
Expand Down Expand Up @@ -71,6 +72,7 @@ export const defaultPanelIds: OverviewPanelId[] = [
'cause_dropped_packet_rates',
'top_avg_dns_latency',
'top_p90_dns_latency',
'name_dns_latency_flows',
'rcode_dns_latency_flows',
'bottom_min_rtt',
'top_avg_rtt',
Expand Down Expand Up @@ -104,7 +106,7 @@ export const getDefaultOverviewPanels = (customIds?: string[]): OverviewPanel[]
ids = ids.concat(['state_dropped_packet_rates', 'cause_dropped_packet_rates']);
break;
case 'dns_latency':
ids = ids.concat(['rcode_dns_latency_flows']);
ids = ids.concat(['name_dns_latency_flows', 'rcode_dns_latency_flows']);
break;
}

Expand Down Expand Up @@ -303,6 +305,15 @@ export const getOverviewPanelInfo = (
})
};
}
case 'name_dns_latency_flows':
return {
title: t('Top {{limit}} DNS name with total', { limit }),
topTitle: t('Top {{limit}} DNS name', { limit }),
totalTitle: t('Total DNS name'),
chartType: t('donut or bars and lines'),
subtitle: t('Total DNS flow count'),
tooltip: t('The top DNS name extracted from DNS headers compared to total over the selected interval')
};
case 'rcode_dns_latency_flows':
return {
title: t('Top {{limit}} DNS response code with total', { limit }),
Expand Down