Skip to content

Commit 6d5d41f

Browse files
committed
add DNS name
1 parent b208728 commit 6d5d41f

File tree

10 files changed

+76
-5
lines changed

10 files changed

+76
-5
lines changed

config/sample-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,15 @@ frontend:
709709
default: false
710710
width: 5
711711
feature: dnsTracking
712+
- id: DNSName
713+
group: DNS
714+
name: DNS Name
715+
tooltip: DNS name.
716+
field: DnsName
717+
filter: dns_name
718+
default: false
719+
width: 15
720+
feature: dnsTracking
712721
- id: DNSLatency
713722
group: DNS
714723
name: DNS Latency
@@ -1168,6 +1177,10 @@ frontend:
11681177
name: DNS Id
11691178
component: number
11701179
hint: Specify a single DNS Id.
1180+
- id: dns_name
1181+
name: DNS Name
1182+
component: text
1183+
hint: Specify a single DNS name.
11711184
- id: dns_latency
11721185
name: DNS Latency
11731186
component: number
@@ -1522,6 +1535,10 @@ frontend:
15221535
- name: DnsId
15231536
type: number
15241537
description: DNS record id
1538+
- id: dns_name
1539+
name: DNS Name
1540+
component: text
1541+
hint: Specify a single DNS name.
15251542
- name: DnsLatencyMs
15261543
type: number
15271544
description: Time between a DNS request and response, in milliseconds

pkg/loki/flow_query.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,14 @@ func (q *FlowQueryBuilder) appendFilter(sb *strings.Builder, field string) {
207207

208208
func (q *FlowQueryBuilder) appendDNSFilter(sb *strings.Builder) {
209209
// ensure at least one Dns field is specified except DnsErrno
210-
// |~`"DnsId`|~`"DnsLatencyMs`|~`"DnsFlagsResponseCode"`
210+
// |~`"DnsId`|~`"DnsName`|~`"DnsLatencyMs`|~`"DnsFlagsResponseCode"`
211211
sb.WriteString("|~`")
212212
sb.WriteString(`"DnsId`)
213213
sb.WriteString("`")
214214
sb.WriteString("|~`")
215+
sb.WriteString(`"DnsName`)
216+
sb.WriteString("`")
217+
sb.WriteString("|~`")
215218
sb.WriteString(`"DnsLatencyMs`)
216219
sb.WriteString("`")
217220
sb.WriteString("|~`")

pkg/model/fields/fields.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const (
5050
IfDirections = "IfDirections"
5151
NetworkEvents = "NetworkEvents"
5252
DNSID = "DnsId"
53+
DNSName = "DnsName"
5354
DNSLatency = "DnsLatencyMs"
5455
DNSErrNo = "DnsErrno"
5556
DNSCode = "DnsFlagsResponseCode"

web/locales/en/plugin__netobserv-plugin.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,14 @@
572572
"Overall": "Overall",
573573
"donut or lines": "donut or lines",
574574
"The {{function}} {{metric}} with overall over the selected interval": "The {{function}} {{metric}} with overall over the selected interval",
575+
"Top {{limit}} DNS name with total": "Top {{limit}} DNS name with total",
576+
"Top {{limit}} DNS name": "Top {{limit}} DNS name",
577+
"Total DNS name": "Total DNS name",
578+
"Total DNS flow count": "Total DNS flow count",
579+
"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",
575580
"Top {{limit}} DNS response code with total": "Top {{limit}} DNS response code with total",
576581
"Top {{limit}} DNS response code": "Top {{limit}} DNS response code",
577582
"Total DNS response code": "Total DNS response code",
578-
"Total DNS flow count": "Total DNS flow count",
579583
"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",
580584
"rates": "rates",
581585
"with total": "with total",

web/src/api/ipfix.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export interface Flow {
8181
PktDropBytes_AB?: number;
8282
PktDropBytes_BA?: number;
8383
DnsId?: number;
84+
DnsName?: string;
8485
DnsFlags?: number;
8586
DnsFlagsResponseCode?: string;
8687
DnsLatencyMs?: number;

web/src/api/loki.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export type NetflowMetrics = {
137137
totalDroppedRateMetric?: TotalRateMetrics;
138138
droppedStateMetrics?: GenericMetric[];
139139
droppedCauseMetrics?: GenericMetric[];
140+
dnsNameMetrics?: GenericMetric[];
140141
dnsRCodeMetrics?: GenericMetric[];
141142
dnsLatencyMetrics?: FunctionMetrics;
142143
rttMetrics?: FunctionMetrics;

web/src/components/__tests-data__/columns.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,17 @@ export const ColumnConfigSampleDefs = [
500500
default: false,
501501
width: 5
502502
},
503+
{
504+
id: 'DNSName',
505+
group: 'DNS',
506+
name: 'DNS Name',
507+
tooltip: 'DNS name.',
508+
field: 'DnsName',
509+
filter: 'dns_name',
510+
feature: 'dnsTracking',
511+
default: false,
512+
width: 15
513+
},
503514
{
504515
id: 'DNSLatency',
505516
group: 'DNS',

web/src/components/__tests-data__/filters.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ export const FilterConfigSampleDefs = [
250250
name: 'DNS Id',
251251
component: 'number',
252252
hint: 'Specify a single DNS Id.'
253+
},
254+
{
255+
id: 'dns_name',
256+
name: 'DNS Name',
257+
component: 'text',
258+
hint: 'Specify a single DNS Name.'
253259
},
254260
{
255261
id: 'dns_latency',

web/src/components/tabs/netflow-overview/netflow-overview.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ export const NetflowOverview: React.FC<NetflowOverviewProps> = React.forwardRef(
263263
if (dnsPanels.some(p => p.id.includes('rcode_dns_latency_flows'))) {
264264
promises.push(
265265
...[
266+
//get dns names
267+
getFlowGenericMetrics(
268+
{ ...fq, aggregateBy: 'DnsName', function: 'count', type: 'DnsFlows' },
269+
range
270+
).then(res => {
271+
currentMetrics = { ...currentMetrics, dnsNameMetrics: res.metrics };
272+
setMetrics(currentMetrics);
273+
return res.stats;
274+
}),
266275
//get dns response codes
267276
getFlowGenericMetrics(
268277
{ ...fq, aggregateBy: 'DnsFlagsResponseCode', function: 'count', type: 'DnsFlows' },
@@ -286,6 +295,7 @@ export const NetflowOverview: React.FC<NetflowOverviewProps> = React.forwardRef(
286295
setMetrics({
287296
...currentMetrics,
288297
dnsLatencyMetrics: undefined,
298+
dnsNameMetrics: undefined,
289299
dnsRCodeMetrics: undefined,
290300
totalDnsLatencyMetric: undefined,
291301
totalDnsCountMetric: undefined
@@ -525,6 +535,10 @@ export const NetflowOverview: React.FC<NetflowOverviewProps> = React.forwardRef(
525535
return props.metrics.droppedCauseMetrics?.sort((a, b) => getStat(b.stats, 'sum') - getStat(a.stats, 'sum')) || [];
526536
}, [props.metrics.droppedCauseMetrics]);
527537

538+
const getTopKDnsNameMetrics = React.useCallback(() => {
539+
return props.metrics.dnsNameMetrics?.sort((a, b) => getStat(b.stats, 'sum') - getStat(a.stats, 'sum')) || [];
540+
}, [props.metrics.dnsNameMetrics]);
541+
528542
const getTopKDnsRCodeMetrics = React.useCallback(() => {
529543
return props.metrics.dnsRCodeMetrics?.sort((a, b) => getStat(b.stats, 'sum') - getStat(a.stats, 'sum')) || [];
530544
}, [props.metrics.dnsRCodeMetrics]);
@@ -924,9 +938,10 @@ export const NetflowOverview: React.FC<NetflowOverviewProps> = React.forwardRef(
924938
doubleWidth: options.graph!.type !== 'donut'
925939
};
926940
}
941+
case 'name_dns_latency_flows':
927942
case 'rcode_dns_latency_flows': {
928-
const metricType = 'DnsFlows'; // TODO: consider adding packets graphs here
929-
const topKMetrics = getTopKDnsRCodeMetrics();
943+
const metricType = id === 'name_dns_latency_flows' ? 'DnsName' : 'DnsFlows'; // TODO: consider adding packets graphs here
944+
const topKMetrics = id === 'name_dns_latency_flows' ? getTopKDnsNameMetrics() : getTopKDnsRCodeMetrics();
930945
const namedTotalMetric = getDnsCountTotalMetric();
931946
const options = getKebabOptions(id, {
932947
showNoError: true,
@@ -1060,6 +1075,7 @@ export const NetflowOverview: React.FC<NetflowOverviewProps> = React.forwardRef(
10601075
getNamedTotalMetric,
10611076
getNamedTotalRateMetric,
10621077
getNoInternalTopKRateMetrics,
1078+
getTopKDnsNameMetrics,
10631079
getTopKDnsRCodeMetrics,
10641080
getTopKDroppedCauseMetrics,
10651081
getTopKDroppedStateMetrics,

web/src/utils/overview-panels.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export type OverviewPanelId =
4040
| `${OverviewPanelRateMetric}`
4141
| `state_dropped_packet_rates`
4242
| `cause_dropped_packet_rates`
43+
| 'name_dns_latency_flows'
4344
| 'rcode_dns_latency_flows'
4445
| `custom_${StatFunction}_${AggregateBy}_${MetricType}`
4546
| `custom_${AggregateBy}_${MetricType}`
@@ -71,6 +72,7 @@ export const defaultPanelIds: OverviewPanelId[] = [
7172
'cause_dropped_packet_rates',
7273
'top_avg_dns_latency',
7374
'top_p90_dns_latency',
75+
'name_dns_latency_flows',
7476
'rcode_dns_latency_flows',
7577
'bottom_min_rtt',
7678
'top_avg_rtt',
@@ -104,7 +106,7 @@ export const getDefaultOverviewPanels = (customIds?: string[]): OverviewPanel[]
104106
ids = ids.concat(['state_dropped_packet_rates', 'cause_dropped_packet_rates']);
105107
break;
106108
case 'dns_latency':
107-
ids = ids.concat(['rcode_dns_latency_flows']);
109+
ids = ids.concat(['name_dns_latency_flows', 'rcode_dns_latency_flows']);
108110
break;
109111
}
110112

@@ -303,6 +305,15 @@ export const getOverviewPanelInfo = (
303305
})
304306
};
305307
}
308+
case 'name_dns_latency_flows':
309+
return {
310+
title: t('Top {{limit}} DNS name with total', { limit }),
311+
topTitle: t('Top {{limit}} DNS name', { limit }),
312+
totalTitle: t('Total DNS name'),
313+
chartType: t('donut or bars and lines'),
314+
subtitle: t('Total DNS flow count'),
315+
tooltip: t('The top DNS name extracted from DNS headers compared to total over the selected interval')
316+
};
306317
case 'rcode_dns_latency_flows':
307318
return {
308319
title: t('Top {{limit}} DNS response code with total', { limit }),

0 commit comments

Comments
 (0)