Skip to content
Merged
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
28 changes: 27 additions & 1 deletion config/sample-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ prometheus:
url: https://localhost:9090
timeout: 30s
skipTls: true
tokenPath: /tmp/oc-token.txt
# tokenPath: /tmp/oc-token.txt
alertManager:
# url: https://localhost:9094
metrics:
Expand Down Expand Up @@ -944,6 +944,7 @@ frontend:
name: Cluster
component: autocomplete
hint: Specify a cluster ID or name.
feature: multiCluster
- id: namespace
name: Namespace
component: autocomplete
Expand Down Expand Up @@ -1105,31 +1106,37 @@ frontend:
component: autocomplete
category: endpoint
hint: Specify a single zone.
feature: zones
- id: src_zone
name: Zone
component: autocomplete
category: source
hint: Specify a single zone.
feature: zones
- id: dst_zone
name: Zone
component: autocomplete
category: destination
hint: Specify a single zone.
feature: zones
- id: subnet_label
name: Subnet Label
component: autocomplete
category: endpoint
hint: Specify a subnet label, or an empty string to get unmatched sources.
feature: subnetLabels
- id: src_subnet_label
name: Subnet Label
component: autocomplete
category: source
hint: Specify a subnet label, or an empty string to get unmatched sources.
feature: subnetLabels
- id: dst_subnet_label
name: Subnet Label
component: autocomplete
category: destination
hint: Specify a subnet label, or an empty string to get unmatched destinations.
feature: subnetLabels
- id: resource
name: Resource
component: autocomplete
Expand Down Expand Up @@ -1329,14 +1336,17 @@ frontend:
name: Network Name
component: text
category: endpoint
feature: multiNetworks
- id: src_network
name: Network Name
component: text
category: source
feature: multiNetworks
- id: dst_network
name: Network Name
component: text
category: destination
feature: multiNetworks
- id: protocol
name: Protocol
component: autocomplete
Expand Down Expand Up @@ -1393,6 +1403,7 @@ frontend:
name: User Defined Network
component: autocomplete
hint: Specify a user defined network name.
feature: udnMapping
- id: id
name: Conversation Id
component: text
Expand All @@ -1407,6 +1418,7 @@ frontend:
- A _LINUX_TCP_STATES_H number like 1, 2, 3
- A _LINUX_TCP_STATES_H TCP name like ESTABLISHED, SYN_SENT, SYN_RECV
docUrl: https://github.com/torvalds/linux/blob/master/include/net/tcp_states.h
feature: pktDrop
- id: pkt_drop_cause
name: Packet drop latest cause
component: autocomplete
Expand All @@ -1417,18 +1429,22 @@ frontend:
- A _LINUX_DROPREASON_CORE_H number like 2, 3, 4
- A _LINUX_DROPREASON_CORE_H SKB_DROP_REASON name like NOT_SPECIFIED, NO_SOCKET, PKT_TOO_SMALL
docUrl: https://github.com/torvalds/linux/blob/master/include/net/dropreason-core.h
feature: pktDrop
- id: dns_id
name: DNS Id
component: number
hint: Specify a single DNS Id.
feature: dnsTracking
- id: dns_name
name: DNS Name
component: text
hint: Specify a single DNS name.
feature: dnsTracking
- id: dns_latency
name: DNS Latency
component: number
hint: Specify a DNS Latency in miliseconds.
feature: dnsTracking
- id: dns_flag_response_code
name: DNS Response Code
component: autocomplete
Expand All @@ -1439,46 +1455,56 @@ frontend:
- A IANA RCODE number like 0, 3, 9
- A IANA RCODE name like NoError, NXDomain, NotAuth
docUrl: https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6
feature: dnsTracking
- id: dns_errno
name: DNS Error
component: autocomplete
hint: Specify a single DNS error number.
feature: dnsTracking
- id: time_flow_rtt
name: Flow RTT
component: number
hint: Specify a TCP smoothed Round Trip Time in nanoseconds.
feature: flowRTT
- id: network_events
name: Network Events
component: text
hint: Specify a single network event.
feature: networkEvents
- id: xlat_zone_id
name: Xlat Zone Id
component: number
feature: packetTranslation
- id: xlat_src_address
name: Xlat source address
component: text
category: source
hint: Specify a single IP or range.
feature: packetTranslation
- id: xlat_dst_address
name: Xlat destination address
component: text
category: destination
hint: Specify a single IP or range.
feature: packetTranslation
- id: xlat_src_port
name: Xlat source port
component: autocomplete
category: source
hint: Specify a single port number or name.
feature: packetTranslation
- id: xlat_dst_port
name: Xlat destination port
component: autocomplete
category: destination
hint: Specify a single port number or name.
feature: packetTranslation
- id: ipsec_status
name: IPsec Status
component: text
placeholder: 'E.g: success, error'
hint: Status of the IPsec encryption (on egress, provided by the kernel function xfrm_output) or decryption (on ingress, via xfrm_input).
feature: ipsec
scopes:
- id: cluster
name: Cluster
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ type Filter struct {
Examples string `yaml:"examples,omitempty" json:"examples,omitempty"`
DocURL string `yaml:"docUrl,omitempty" json:"docUrl,omitempty"`
Placeholder string `yaml:"placeholder,omitempty" json:"placeholder,omitempty"`
Feature string `yaml:"feature,omitempty" json:"feature,omitempty"`
}

type Scope struct {
Expand Down
25 changes: 16 additions & 9 deletions web/src/components/__tests-data__/filters.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable max-len */
import { Filter, FilterCompare, FilterId, FilterValue } from '../../model/filters';
import { Filter, FilterCompare, FilterConfigDef, FilterId, FilterValue } from '../../model/filters';
import { findFilter, getFilterDefinitions } from '../../utils/filter-definitions';
import { ColumnConfigSampleDefs } from './columns';

export const FilterConfigSampleDefs = [
export const FilterConfigSampleDefs: FilterConfigDef[] = [
{
id: 'namespace',
name: 'Namespace',
Expand Down Expand Up @@ -275,19 +275,22 @@ export const FilterConfigSampleDefs = [
id: 'zone',
name: 'Zone',
component: 'autocomplete',
category: 'endpoint'
category: 'endpoint',
feature: 'zones'
},
{
id: 'src_zone',
name: 'Zone',
component: 'autocomplete',
category: 'source'
category: 'source',
feature: 'zones'
},
{
id: 'dst_zone',
name: 'Zone',
component: 'autocomplete',
category: 'destination'
category: 'destination',
feature: 'zones'
},
{
id: 'protocol',
Expand Down Expand Up @@ -344,19 +347,22 @@ export const FilterConfigSampleDefs = [
id: 'dns_id',
name: 'DNS Id',
component: 'number',
hint: 'Specify a single DNS Id.'
hint: 'Specify a single DNS Id.',
feature: 'dnsTracking'
},
{
id: 'dns_name',
name: 'DNS Name',
component: 'text',
hint: 'Specify a single DNS Name.'
hint: 'Specify a single DNS Name.',
feature: 'dnsTracking'
},
{
id: 'dns_latency',
name: 'DNS Latency',
component: 'number',
hint: 'Specify a DNS Latency in miliseconds.'
hint: 'Specify a DNS Latency in miliseconds.',
feature: 'dnsTracking'
},
{
id: 'dns_flag_response_code',
Expand All @@ -365,7 +371,8 @@ export const FilterConfigSampleDefs = [
hint: 'Specify a single DNS RCODE name.',
examples:
'Specify a single DNS RCODE name like:\n - A IANA RCODE number like 0, 3, 9\n - A IANA RCODE name like NoError, NXDomain, NotAuth',
docUrl: 'https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6'
docUrl: 'https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6',
feature: 'dnsTracking'
},
{
id: 'time_flow_rtt',
Expand Down
2 changes: 2 additions & 0 deletions web/src/model/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from 'lodash';
import { TFunction } from 'react-i18next';
import { isEqual } from '../utils/base-compare';
import { undefinedValue } from '../utils/filter-definitions';
import { Feature } from './config';
import { Match } from './flow-query';

export type FiltersEncoder = (values: FilterValue[], compare: FilterCompare, matchAny: boolean) => string;
Expand Down Expand Up @@ -88,6 +89,7 @@ export interface FilterConfigDef {
examples?: string;
docUrl?: string;
placeholder?: string;
feature?: Feature;
}

export interface FilterDefinition {
Expand Down
27 changes: 21 additions & 6 deletions web/src/utils/__tests__/filter-definitions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ColumnConfigSampleDefs } from '../../components/__tests-data__/columns';
import { FilterDefinitionSample } from '../../components/__tests-data__/filters';
import { FilterConfigSampleDefs, FilterDefinitionSample } from '../../components/__tests-data__/filters';
import { Config, Feature } from '../../model/config';
import { checkFilterAvailable, findFilter } from '../filter-definitions';

Expand Down Expand Up @@ -142,7 +142,12 @@ describe('Check availability for prometheus only', () => {

describe('Check availability against features', () => {
const getConfig = (feats: Feature[]): Config => {
return { features: feats, dataSources: ['loki'], columns: ColumnConfigSampleDefs } as Config;
return {
features: feats,
dataSources: ['loki'],
columns: ColumnConfigSampleDefs,
filters: FilterConfigSampleDefs
} as Config;
};

it('with standard filters', () => {
Expand All @@ -163,15 +168,25 @@ describe('Check availability against features', () => {
});

it('with AZ filters', () => {
const azFilter = findFilter(FilterDefinitionSample, 'src_zone')!;
const srcZoneFilter = findFilter(FilterDefinitionSample, 'src_zone')!;
const zoneFilter = findFilter(FilterDefinitionSample, 'zone')!;

let available = checkFilterAvailable(azFilter, getConfig([]), 'auto');
// Test that zone filters are unavailable without zones feature
let available = checkFilterAvailable(srcZoneFilter, getConfig([]), 'auto');
expect(available).toBe(false);
available = checkFilterAvailable(zoneFilter, getConfig([]), 'auto');
expect(available).toBe(false);

available = checkFilterAvailable(azFilter, getConfig(['dnsTracking']), 'auto');
// Test that zone filters are unavailable with other features
available = checkFilterAvailable(srcZoneFilter, getConfig(['dnsTracking']), 'auto');
expect(available).toBe(false);
available = checkFilterAvailable(zoneFilter, getConfig(['dnsTracking']), 'auto');
expect(available).toBe(false);

available = checkFilterAvailable(azFilter, getConfig(['zones']), 'auto');
// Test that zone filters are available with zones feature
available = checkFilterAvailable(srcZoneFilter, getConfig(['zones']), 'auto');
expect(available).toBe(true);
available = checkFilterAvailable(zoneFilter, getConfig(['zones']), 'auto');
expect(available).toBe(true);
});

Expand Down
5 changes: 5 additions & 0 deletions web/src/utils/filter-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ export const checkFilterAvailable = (fd: FilterDefinition, config: Config, dataS
}

// Check against enabled features
const filterConfig = config.filters.find(f => f.id === fd.id);
if (filterConfig?.feature) {
return config.features.includes(filterConfig.feature);
}

const colConfig = config.columns.find(c => c.filter === fd.id);
if (colConfig?.feature) {
return config.features.includes(colConfig?.feature);
Expand Down