Skip to content

Commit e96b558

Browse files
committed
More accurate slowness warnings
- message is different depending on "match" - fixed indexed filter is resource, not name - side stuff: added a note in the readme for initial repo setup
1 parent a324d99 commit e96b558

File tree

4 files changed

+45
-13
lines changed

4 files changed

+45
-13
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
Based on [Openshift Console dynamic plugin](https://github.com/openshift/console/tree/master/frontend/packages/console-dynamic-plugin-sdk), this plugin implement the console elements for Network Observability.
66

7+
## First setup
8+
9+
You will need Go, Node.js and npm in order to run the `make` commands described below. You can take a look at the [Dockerfile](./Dockerfile) to get known working versions of these tools. In particular, node and npm are known to often break builds if you don't use the expected versions (even patch versions for npm). You can use [nvm](https://github.com/nvm-sh/nvm) to manage installed node / npm versions.
10+
11+
Once these tools are installed, run the following command:
12+
13+
```bash
14+
make install-frontend
15+
```
16+
717
## Building, linting, testing
818

919
To build the plugin, run:

web/locales/en/plugin__network-observability-plugin.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,10 @@
154154
"Expand": "Expand",
155155
"Actions": "Actions",
156156
"View": "View",
157-
"Network Traffic": "Network Traffic",
157+
"When in \"Match any\" mode, try using only Namespace, Owner or Resource filters (which use indexed fields), or decrease limit / range, to improve the query performance": "When in \"Match any\" mode, try using only Namespace, Owner or Resource filters (which use indexed fields), or decrease limit / range, to improve the query performance",
158+
"Add Namespace, Owner or Resource filters (which use indexed fields), or decrease limit / range, to improve the query performance": "Add Namespace, Owner or Resource filters (which use indexed fields), or decrease limit / range, to improve the query performance",
158159
"Add more filters or decrease limit / range to improve the query performance": "Add more filters or decrease limit / range to improve the query performance",
160+
"Network Traffic": "Network Traffic",
159161
"Query limit reached": "Query limit reached",
160162
"Filtered flows count": "Filtered flows count",
161163
"{{count}} flows": "{{count}} flows",

web/src/components/netflow-traffic.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ import { DefaultOptions, TopologyGroupTypes, TopologyOptions } from '../model/to
4747
import { Column, getDefaultColumns } from '../utils/columns';
4848
import { TimeRange } from '../utils/datetime';
4949
import { getHTTPErrorDetails } from '../utils/errors';
50-
import { DisabledFilters, Filter, hasIndexFields, getDisabledFiltersRecord, getEnabledFilters } from '../model/filters';
50+
import {
51+
DisabledFilters,
52+
Filter,
53+
hasIndexFields,
54+
getDisabledFiltersRecord,
55+
getEnabledFilters,
56+
hasNonIndexFields
57+
} from '../model/filters';
5158
import {
5259
LOCAL_STORAGE_COLS_KEY,
5360
LOCAL_STORAGE_DISABLED_FILTERS_KEY,
@@ -675,6 +682,20 @@ export const NetflowTraffic: React.FC<{
675682
});
676683
}, [isFullScreen]);
677684

685+
const slownessReason = React.useCallback(() => {
686+
if (match === 'any' && hasNonIndexFields(filters)) {
687+
return t(
688+
'When in "Match any" mode, try using only Namespace, Owner or Resource filters (which use indexed fields), or decrease limit / range, to improve the query performance'
689+
);
690+
}
691+
if (match === 'all' && !hasIndexFields(filters)) {
692+
return t(
693+
'Add Namespace, Owner or Resource filters (which use indexed fields), or decrease limit / range, to improve the query performance'
694+
);
695+
}
696+
return t('Add more filters or decrease limit / range to improve the query performance');
697+
}, [match, filters]);
698+
678699
return !_.isEmpty(extensions) ? (
679700
<PageSection id="pageSection" className={isTab ? 'tab' : ''}>
680701
{
@@ -754,9 +775,7 @@ export const NetflowTraffic: React.FC<{
754775
variant="warning"
755776
actionClose={<AlertActionCloseButton onClose={() => setWarningMessage(undefined)} />}
756777
>
757-
{hasIndexFields(filters)
758-
? t('Add more filters or decrease limit / range to improve the query performance')
759-
: t('Add Namespace, Owner or Resource filters (which use indexed fields) to improve the query performance')}
778+
{slownessReason()}
760779
</Alert>
761780
)}
762781
</PageSection>

web/src/model/filters.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,14 @@ export const getDisabledFiltersRecord = (filters: Filter[]) => {
127127
return disabledFilters;
128128
};
129129

130+
const isIndexed = (f: Filter) => {
131+
return f.def.id.includes('namespace') || f.def.id.includes('owner') || f.def.id.includes('resource');
132+
};
133+
130134
export const hasIndexFields = (filters: Filter[]) => {
131-
return (
132-
filters.find(
133-
f =>
134-
f.def.id.includes('namespace') ||
135-
f.def.id.includes('owner') ||
136-
['name', 'src_name', 'dst_name'].includes(f.def.id.toString())
137-
) !== undefined
138-
);
135+
return filters.some(isIndexed);
136+
};
137+
138+
export const hasNonIndexFields = (filters: Filter[]) => {
139+
return filters.some(f => !isIndexed(f));
139140
};

0 commit comments

Comments
 (0)