@eeacms/volto-globalsearch 1.0.21 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +37 -0
- package/RELEASE.md +14 -14
- package/cypress.config.js +3 -3
- package/package.json +3 -3
- package/src/config/facets.js +53 -1
- package/src/config/healthcheck.js +199 -208
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [1.1.0](https://github.com/eea/volto-globalsearch/compare/1.0.22...1.1.0) - 16 January 2024
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- Release 1.1.0 [Alin Voinea - [`822ac10`](https://github.com/eea/volto-globalsearch/commit/822ac1049228c132637fd019f233ae7bc63ff9a8)]
|
|
12
|
+
- updated facets [Zoltan Szabo - [`7206aed`](https://github.com/eea/volto-globalsearch/commit/7206aed30bf3a178c4660a4a280821bee5e4a19b)]
|
|
13
|
+
- added facet for publisher [Zoltan Szabo - [`68dc66a`](https://github.com/eea/volto-globalsearch/commit/68dc66a612286a7767bbed289e1743aac23adc4e)]
|
|
14
|
+
- updated default facets config [Zoltan Szabo - [`adbd434`](https://github.com/eea/volto-globalsearch/commit/adbd434c6baedaf98cd3145e75e368c92101758d)]
|
|
15
|
+
- added new facets [Zoltan Szabo - [`acc6ba8`](https://github.com/eea/volto-globalsearch/commit/acc6ba8e4ee8c911343ac129f4ae3fcc99355ff7)]
|
|
16
|
+
### [1.0.22](https://github.com/eea/volto-globalsearch/compare/1.0.21...1.0.22) - 12 December 2023
|
|
17
|
+
|
|
18
|
+
#### :house: Internal changes
|
|
19
|
+
|
|
20
|
+
- chore: husky, lint-staged use fixed versions [valentinab25 - [`866609d`](https://github.com/eea/volto-globalsearch/commit/866609d540bd0efe4bab088305bb2127105d8df7)]
|
|
21
|
+
- chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`e09f5e2`](https://github.com/eea/volto-globalsearch/commit/e09f5e2c1161b4b867c04eb1c0421274bd6c7110)]
|
|
22
|
+
|
|
23
|
+
#### :hammer_and_wrench: Others
|
|
24
|
+
|
|
25
|
+
- removed try/catch [Zoltan Szabo - [`86cec5d`](https://github.com/eea/volto-globalsearch/commit/86cec5d49d06d41541dc6d42464e9b95769da745)]
|
|
26
|
+
- avoid async promise executor functions [Zoltan Szabo - [`61012e3`](https://github.com/eea/volto-globalsearch/commit/61012e331776fadaa9eafe9f7667b18d08b2351a)]
|
|
7
27
|
### [1.0.21](https://github.com/eea/volto-globalsearch/compare/1.0.20...1.0.21) - 29 September 2023
|
|
8
28
|
|
|
9
29
|
#### :house: Internal changes
|
package/README.md
CHANGED
|
@@ -76,6 +76,43 @@ Go to http://localhost:3000
|
|
|
76
76
|
|
|
77
77
|
1. Happy editing!
|
|
78
78
|
|
|
79
|
+
# Customizing the volto-searchblock
|
|
80
|
+
|
|
81
|
+
## Modifying Clusters
|
|
82
|
+
|
|
83
|
+
To customize the behavior of the `volto-searchblock` in your volto theme addon, you can modify clusters by following these steps:
|
|
84
|
+
|
|
85
|
+
1. Find or create `index.js` in the `src/config`
|
|
86
|
+
|
|
87
|
+
In your theme addon, create the `src/config/index.js` file. You can refer to the [example file](https://github.com/eea/volto-marine-theme/blob/eea-design/src/config/index.js) in the `volto-marine-theme` repository.
|
|
88
|
+
|
|
89
|
+
2. Locate and Modify Clusters
|
|
90
|
+
|
|
91
|
+
Clusters are found in `config.searchui.<name_of_search>.runtime_mappings`. For example, in the case of the `volto-marine-theme`, the `<name_of_search>` was `marinemeasure`, and clusters are located in `config.searchui.marinemeasure.runtime_mappings`.
|
|
92
|
+
|
|
93
|
+
3. Use `build_runtime_mappings`
|
|
94
|
+
|
|
95
|
+
You have to pass the clusters transformed by build_runtime_mappings function. Import the `build_runtime_mappings` as follows:
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
import { build_runtime_mappings } from '@eeacms/volto-globalsearch/utils';
|
|
99
|
+
```
|
|
100
|
+
5. Default Clusters
|
|
101
|
+
|
|
102
|
+
Default clusters are defined [here](https://github.com/eea/volto-globalsearch/blob/master/src/config/clusters.js). Decide whether you want to override all clusters or modify specific ones.
|
|
103
|
+
If you decided to modify them, you can import them in your addon as follows:
|
|
104
|
+
```javascript
|
|
105
|
+
import { clusters } from '@eeacms/volto-globalsearch/config/clusters';
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
6. Example Modification
|
|
109
|
+
|
|
110
|
+
Here's an example of how the Publications cluster was modified in the CountryFactsheet by keeping the rest as default: https://github.com/eea/volto-marine-theme/pull/43/files.
|
|
111
|
+
|
|
112
|
+
7. Cluster Structure
|
|
113
|
+
|
|
114
|
+
Be aware that a cluster contains the `values` key that holds the `content types` on which the cluster will act.
|
|
115
|
+
|
|
79
116
|
## Release
|
|
80
117
|
|
|
81
118
|
See [RELEASE.md](https://github.com/eea/volto-globalsearch/blob/master/RELEASE.md).
|
package/RELEASE.md
CHANGED
|
@@ -20,9 +20,9 @@ You need to first install the [release-it](https://github.com/release-it/release
|
|
|
20
20
|
```
|
|
21
21
|
npm install -g release-it
|
|
22
22
|
```
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
Release-it uses the configuration written in the [`.release-it.json`](./.release-it.json) file located in the root of the repository.
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
Release-it is a tool that automates 4 important steps in the release process:
|
|
27
27
|
|
|
28
28
|
1. Version increase in `package.json` ( increased from the current version in `package.json`)
|
|
@@ -30,45 +30,45 @@ Release-it is a tool that automates 4 important steps in the release process:
|
|
|
30
30
|
3. GitHub release on the commit with the changelog and package.json modification on the develop branch
|
|
31
31
|
4. NPM release ( by default it's disabled, but can be enabled in the configuration file )
|
|
32
32
|
|
|
33
|
-
To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)
|
|
33
|
+
To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)
|
|
34
34
|
|
|
35
35
|
```
|
|
36
36
|
export GITHUB_TOKEN=XXX-XXXXXXXXXXXXXXXXXXXXXX
|
|
37
37
|
```
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
To configure npm, you can use the `npm login` command or use a configuration file with a TOKEN :
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
```
|
|
42
42
|
echo "//registry.npmjs.org/:_authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" > .npmrc
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
#### Using release-it tool
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
There are 3 yarn scripts that can be run to do the release
|
|
48
48
|
|
|
49
49
|
##### yarn release-beta
|
|
50
50
|
|
|
51
|
-
Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).
|
|
51
|
+
Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).
|
|
52
52
|
|
|
53
53
|
```
|
|
54
|
-
? Select increment (next version):
|
|
55
|
-
❯ prepatch (0.1.1-beta.0)
|
|
56
|
-
preminor (0.2.0-beta.0)
|
|
57
|
-
premajor (1.0.0-beta.0)
|
|
58
|
-
Other, please specify...
|
|
54
|
+
? Select increment (next version):
|
|
55
|
+
❯ prepatch (0.1.1-beta.0)
|
|
56
|
+
preminor (0.2.0-beta.0)
|
|
57
|
+
premajor (1.0.0-beta.0)
|
|
58
|
+
Other, please specify...
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
##### yarn release-major-beta
|
|
62
62
|
|
|
63
63
|
Same as `yarn release-beta`, but with premajor version pre-selected.
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
##### yarn release
|
|
66
66
|
|
|
67
67
|
Generic command, does not automatically add the `beta` to version, but you can still manually write it if you choose Other.
|
|
68
68
|
|
|
69
69
|
#### Important notes
|
|
70
70
|
|
|
71
|
-
> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST.
|
|
71
|
+
> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST.
|
|
72
72
|
|
|
73
73
|
> Do not keep Pull Requests from develop to master branches open when you are doing beta releases from the develop branch. As long as a PR to master is open, an automatic script will run on every commit and will update both the version and the changelog to a production-ready state - ( MAJOR.MINOR.PATCH mandatory format for version).
|
|
74
74
|
|
package/cypress.config.js
CHANGED
|
@@ -2,12 +2,12 @@ const { defineConfig } = require('cypress');
|
|
|
2
2
|
|
|
3
3
|
module.exports = defineConfig({
|
|
4
4
|
viewportWidth: 1280,
|
|
5
|
-
defaultCommandTimeout:
|
|
5
|
+
defaultCommandTimeout: 8888,
|
|
6
6
|
chromeWebSecurity: false,
|
|
7
7
|
reporter: 'junit',
|
|
8
|
-
video:
|
|
8
|
+
video: false,
|
|
9
9
|
retries: {
|
|
10
|
-
runMode:
|
|
10
|
+
runMode: 2,
|
|
11
11
|
openMode: 0,
|
|
12
12
|
},
|
|
13
13
|
reporterOptions: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-globalsearch",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "@eeacms/volto-globalsearch: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@cypress/code-coverage": "^3.10.0",
|
|
29
29
|
"@plone/scripts": "*",
|
|
30
30
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
31
|
-
"husky": "
|
|
32
|
-
"lint-staged": "
|
|
31
|
+
"husky": "^8.0.3",
|
|
32
|
+
"lint-staged": "^14.0.1",
|
|
33
33
|
"md5": "^2.3.0"
|
|
34
34
|
},
|
|
35
35
|
"lint-staged": {
|
package/src/config/facets.js
CHANGED
|
@@ -12,6 +12,7 @@ import topicsBlacklist from './json/topicsBlacklist.json';
|
|
|
12
12
|
import { getTodayWithTime } from '../utils';
|
|
13
13
|
|
|
14
14
|
const languageCodes = [
|
|
15
|
+
'en',
|
|
15
16
|
'ar',
|
|
16
17
|
'sr',
|
|
17
18
|
'sq',
|
|
@@ -22,7 +23,6 @@ const languageCodes = [
|
|
|
22
23
|
'da',
|
|
23
24
|
'nl',
|
|
24
25
|
'el',
|
|
25
|
-
'en',
|
|
26
26
|
'et',
|
|
27
27
|
'fi',
|
|
28
28
|
'fr',
|
|
@@ -273,6 +273,58 @@ const facets = [
|
|
|
273
273
|
facetValues: languageCodes,
|
|
274
274
|
sortOn: 'custom',
|
|
275
275
|
sortOnCustomLabel: 'Alphabetical',
|
|
276
|
+
sortOrder: 'ascending',
|
|
277
|
+
}),
|
|
278
|
+
multiTermFacet({
|
|
279
|
+
field: 'dpsir.keyword',
|
|
280
|
+
isFilterable: false,
|
|
281
|
+
isMulti: true,
|
|
282
|
+
label: 'DPSIR',
|
|
283
|
+
}),
|
|
284
|
+
multiTermFacet({
|
|
285
|
+
field: 'typology.keyword',
|
|
286
|
+
isFilterable: false,
|
|
287
|
+
isMulti: true,
|
|
288
|
+
label: 'Typology',
|
|
289
|
+
}),
|
|
290
|
+
multiTermFacet({
|
|
291
|
+
field: 'un_sdgs.keyword',
|
|
292
|
+
isFilterable: false,
|
|
293
|
+
isMulti: true,
|
|
294
|
+
label: 'UN SDGs',
|
|
295
|
+
}),
|
|
296
|
+
multiTermFacet({
|
|
297
|
+
field: 'data_provenances_organisations.keyword',
|
|
298
|
+
isFilterable: true,
|
|
299
|
+
isMulti: true,
|
|
300
|
+
label: 'Data sources',
|
|
301
|
+
}),
|
|
302
|
+
multiTermFacet({
|
|
303
|
+
field: 'creators.keyword',
|
|
304
|
+
isFilterable: true,
|
|
305
|
+
isMulti: true,
|
|
306
|
+
label: 'Creators',
|
|
307
|
+
authOnly: true,
|
|
308
|
+
}),
|
|
309
|
+
multiTermFacet({
|
|
310
|
+
field: 'contributors.keyword',
|
|
311
|
+
isFilterable: true,
|
|
312
|
+
isMulti: true,
|
|
313
|
+
label: 'Contributors',
|
|
314
|
+
}),
|
|
315
|
+
multiTermFacet({
|
|
316
|
+
field: 'subject.keyword_lc',
|
|
317
|
+
isFilterable: true,
|
|
318
|
+
isMulti: true,
|
|
319
|
+
label: 'Tags',
|
|
320
|
+
sortOn: 'value',
|
|
321
|
+
sortOrder: 'ascending',
|
|
322
|
+
}),
|
|
323
|
+
multiTermFacet({
|
|
324
|
+
field: 'publishers.keyword',
|
|
325
|
+
isFilterable: false,
|
|
326
|
+
isMulti: true,
|
|
327
|
+
label: 'Publishers',
|
|
276
328
|
}),
|
|
277
329
|
];
|
|
278
330
|
|
|
@@ -24,18 +24,12 @@ export function buildQuery(query, values) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async function executeQuery(q, appConfig, params = {}, callback) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// console.log(JSON.stringify(resp.body));
|
|
34
|
-
resolve(callback(resp.body, params));
|
|
35
|
-
} catch (e) {
|
|
36
|
-
reject({ error: e.message });
|
|
37
|
-
}
|
|
38
|
-
});
|
|
27
|
+
params['index_name'] = 'status_' + appConfig['index_name'];
|
|
28
|
+
const query = buildQuery(q, params);
|
|
29
|
+
//console.log(JSON.stringify(query));
|
|
30
|
+
const resp = await runRequest(query, appConfig);
|
|
31
|
+
// console.log(JSON.stringify(resp.body));
|
|
32
|
+
return Promise.resolve(callback(resp.body, params));
|
|
39
33
|
}
|
|
40
34
|
|
|
41
35
|
export function getlastandnext_started_execution(body, params = {}) {
|
|
@@ -105,130 +99,129 @@ export function getlatesttasks_for_site(body, params = {}) {
|
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
export async function getStatus(appConfig, params) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
);
|
|
102
|
+
let resp = 'OK';
|
|
103
|
+
let error = null;
|
|
104
|
+
// console.log('=======================================');
|
|
105
|
+
// console.log('STEP 1');
|
|
106
|
+
const step1 = await executeQuery(
|
|
107
|
+
last_scheduled_started_indexing,
|
|
108
|
+
appConfig,
|
|
109
|
+
{},
|
|
110
|
+
getlastandnext_started_execution,
|
|
111
|
+
);
|
|
119
112
|
|
|
120
|
-
|
|
113
|
+
// console.log(step1);
|
|
121
114
|
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
// const last_successful_schedule = step1.last_started;
|
|
116
|
+
let next_schedule = step1.next_execution_date;
|
|
124
117
|
|
|
125
|
-
|
|
126
|
-
|
|
118
|
+
const now = params.now || Date.now() - 60 * 1000;
|
|
119
|
+
if (now >= next_schedule) {
|
|
120
|
+
try {
|
|
121
|
+
// console.log('=======================================');
|
|
122
|
+
// console.log('STEP 2');
|
|
123
|
+
const step2 = await executeQuery(
|
|
124
|
+
failed_scheduled_atempts_since_last_started,
|
|
125
|
+
appConfig,
|
|
126
|
+
step1,
|
|
127
|
+
getlastfailed_execution,
|
|
128
|
+
);
|
|
129
|
+
next_schedule = step2.next_execution_date;
|
|
130
|
+
// console.log(step2);
|
|
131
|
+
} catch {
|
|
132
|
+
resp = 'CRITICAL';
|
|
133
|
+
error = 'Failed to get status info from elasticsearch';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (error === null) {
|
|
137
|
+
if (now > next_schedule) {
|
|
138
|
+
resp = 'CRITICAL';
|
|
139
|
+
error = 'Airflow stopped indexing, no new schedules in the queue';
|
|
140
|
+
} else {
|
|
127
141
|
try {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const step2 = await executeQuery(
|
|
131
|
-
failed_scheduled_atempts_since_last_started,
|
|
142
|
+
const step3 = await executeQuery(
|
|
143
|
+
last_sync_task_since_last_start,
|
|
132
144
|
appConfig,
|
|
133
145
|
step1,
|
|
134
|
-
|
|
146
|
+
getlastsynctaskssincestarted,
|
|
135
147
|
);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
all_sites_status[step3.sites[i]] = 'OK';
|
|
172
|
-
// console.log(step4);
|
|
173
|
-
} catch {
|
|
174
|
-
// console.log('=======================================');
|
|
175
|
-
// console.log('STEP 5');
|
|
176
|
-
const step5 = await executeQuery(
|
|
177
|
-
latest_tasks_for_site,
|
|
178
|
-
appConfig,
|
|
179
|
-
{
|
|
180
|
-
site_name: step3.sites[i],
|
|
181
|
-
last_started: step1['last_started'],
|
|
182
|
-
THRESHOLD_WARNING: parseInt(
|
|
183
|
-
params.FAILED_SYNC_THRESHOLD_WARNING,
|
|
184
|
-
),
|
|
185
|
-
THRESHOLD_OK: parseInt(params.FAILED_SYNC_THRESHOLD_OK),
|
|
186
|
-
},
|
|
187
|
-
getlatesttasks_for_site,
|
|
188
|
-
);
|
|
189
|
-
all_sites_status[step3.sites[i]] = step5;
|
|
190
|
-
}
|
|
148
|
+
// console.log(step3.sites);
|
|
149
|
+
const all_sites_status = {};
|
|
150
|
+
for (let i = 0; i < step3.sites.length; i++) {
|
|
151
|
+
try {
|
|
152
|
+
// console.log('=======================================');
|
|
153
|
+
// console.log('STEP 4');
|
|
154
|
+
// const step4 =
|
|
155
|
+
await executeQuery(
|
|
156
|
+
started_or_finished_site_since_last_started,
|
|
157
|
+
appConfig,
|
|
158
|
+
{
|
|
159
|
+
site_name: step3.sites[i],
|
|
160
|
+
last_started: step1['last_started'],
|
|
161
|
+
},
|
|
162
|
+
getlastsuccessfultasks_for_site,
|
|
163
|
+
);
|
|
164
|
+
all_sites_status[step3.sites[i]] = 'OK';
|
|
165
|
+
// console.log(step4);
|
|
166
|
+
} catch {
|
|
167
|
+
// console.log('=======================================');
|
|
168
|
+
// console.log('STEP 5');
|
|
169
|
+
const step5 = await executeQuery(
|
|
170
|
+
latest_tasks_for_site,
|
|
171
|
+
appConfig,
|
|
172
|
+
{
|
|
173
|
+
site_name: step3.sites[i],
|
|
174
|
+
last_started: step1['last_started'],
|
|
175
|
+
THRESHOLD_WARNING: parseInt(
|
|
176
|
+
params.FAILED_SYNC_THRESHOLD_WARNING,
|
|
177
|
+
),
|
|
178
|
+
THRESHOLD_OK: parseInt(params.FAILED_SYNC_THRESHOLD_OK),
|
|
179
|
+
},
|
|
180
|
+
getlatesttasks_for_site,
|
|
181
|
+
);
|
|
182
|
+
all_sites_status[step3.sites[i]] = step5;
|
|
191
183
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
184
|
+
}
|
|
185
|
+
// console.log(all_sites_status);
|
|
186
|
+
const oks = [];
|
|
187
|
+
const warnings = [];
|
|
188
|
+
const criticals = [];
|
|
189
|
+
for (let i = 0; i < step3.sites.length; i++) {
|
|
190
|
+
if (all_sites_status[step3.sites[i]] === 'OK') {
|
|
191
|
+
oks.push(step3.sites[i]);
|
|
192
|
+
}
|
|
193
|
+
if (all_sites_status[step3.sites[i]] === 'WARNING') {
|
|
194
|
+
warnings.push(step3.sites[i]);
|
|
195
|
+
}
|
|
196
|
+
if (all_sites_status[step3.sites[i]] === 'CRITICAL') {
|
|
197
|
+
criticals.push(step3.sites[i]);
|
|
198
|
+
}
|
|
199
|
+
if (criticals.length > 0) {
|
|
200
|
+
error =
|
|
201
|
+
'Clusters with too many fails: ' +
|
|
202
|
+
criticals.concat(warnings).join(', ');
|
|
203
|
+
resp = 'CRITICAL';
|
|
204
|
+
} else {
|
|
205
|
+
if (warnings.length > 0) {
|
|
207
206
|
error =
|
|
208
207
|
'Clusters with too many fails: ' +
|
|
209
208
|
criticals.concat(warnings).join(', ');
|
|
210
|
-
resp = '
|
|
211
|
-
} else {
|
|
212
|
-
if (warnings.length > 0) {
|
|
213
|
-
error =
|
|
214
|
-
'Clusters with too many fails: ' +
|
|
215
|
-
criticals.concat(warnings).join(', ');
|
|
216
|
-
resp = 'WARNING';
|
|
217
|
-
}
|
|
209
|
+
resp = 'WARNING';
|
|
218
210
|
}
|
|
219
211
|
}
|
|
220
|
-
} catch {
|
|
221
|
-
error = 'Failed to get status info from elasticsearch';
|
|
222
212
|
}
|
|
213
|
+
} catch {
|
|
214
|
+
error = 'Failed to get status info from elasticsearch';
|
|
223
215
|
}
|
|
224
216
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
217
|
+
}
|
|
218
|
+
const status = { status: resp };
|
|
219
|
+
if (error !== null) {
|
|
220
|
+
status.error = error;
|
|
221
|
+
}
|
|
222
|
+
return Promise.resolve(status);
|
|
231
223
|
}
|
|
224
|
+
|
|
232
225
|
export default async function healthcheck(appConfig, params) {
|
|
233
226
|
// is index ok?
|
|
234
227
|
// return index update date
|
|
@@ -236,103 +229,101 @@ export default async function healthcheck(appConfig, params) {
|
|
|
236
229
|
// nlpservice provides answer based on extracted term
|
|
237
230
|
// number of documents with error in data raw, type of error
|
|
238
231
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
documentCountThreshold
|
|
250
|
-
|
|
251
|
-
queryTimeSecondsThreshold_OK
|
|
252
|
-
|
|
253
|
-
queryTimeSecondsThreshold_WARNING
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
failedSyncThreshold_OK
|
|
257
|
-
|
|
258
|
-
failedSyncThreshold_WARNING
|
|
259
|
-
failedSyncThreshold_WARNING || default_failedSyncThreshold_WARNING;
|
|
232
|
+
try {
|
|
233
|
+
let {
|
|
234
|
+
documentCountThreshold,
|
|
235
|
+
queryTimeSecondsThreshold_OK,
|
|
236
|
+
queryTimeSecondsThreshold_WARNING,
|
|
237
|
+
failedSyncThreshold_OK,
|
|
238
|
+
failedSyncThreshold_WARNING,
|
|
239
|
+
now,
|
|
240
|
+
} = params;
|
|
241
|
+
documentCountThreshold =
|
|
242
|
+
documentCountThreshold || default_documentCountThreshold;
|
|
243
|
+
queryTimeSecondsThreshold_OK =
|
|
244
|
+
queryTimeSecondsThreshold_OK || default_queryTimeSecondsThreshold_OK;
|
|
245
|
+
queryTimeSecondsThreshold_WARNING =
|
|
246
|
+
queryTimeSecondsThreshold_WARNING ||
|
|
247
|
+
default_queryTimeSecondsThreshold_WARNING;
|
|
248
|
+
failedSyncThreshold_OK =
|
|
249
|
+
failedSyncThreshold_OK || default_failedSyncThreshold_OK;
|
|
250
|
+
failedSyncThreshold_WARNING =
|
|
251
|
+
failedSyncThreshold_WARNING || default_failedSyncThreshold_WARNING;
|
|
260
252
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
253
|
+
const airflow_params = {
|
|
254
|
+
FAILED_SYNC_THRESHOLD_WARNING: failedSyncThreshold_WARNING,
|
|
255
|
+
FAILED_SYNC_THRESHOLD_OK: failedSyncThreshold_OK,
|
|
256
|
+
now: now,
|
|
257
|
+
};
|
|
266
258
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
259
|
+
///////////////////
|
|
260
|
+
const body_total = buildRequest({ filters: [] }, appConfig);
|
|
261
|
+
//console.log(body_total);
|
|
262
|
+
const resp_total = await runRequest(body_total, appConfig);
|
|
263
|
+
const total = resp_total.body.hits.total.value;
|
|
264
|
+
const total_status =
|
|
265
|
+
total > documentCountThreshold
|
|
266
|
+
? { status: 'OK' }
|
|
267
|
+
: {
|
|
268
|
+
status: 'CRITICAL',
|
|
269
|
+
error:
|
|
270
|
+
'The number of documents in elasticsearch dropped drastically',
|
|
271
|
+
};
|
|
272
|
+
const body_nlp = buildRequest(
|
|
273
|
+
{ filters: [], searchTerm: 'what is bise?' },
|
|
274
|
+
appConfig,
|
|
275
|
+
);
|
|
276
|
+
const resp_nlp = await runRequest(body_nlp, appConfig);
|
|
277
|
+
const elapsed = resp_nlp.body.elapsed;
|
|
286
278
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
});
|
|
279
|
+
let total_elapsed = 0;
|
|
280
|
+
Object.keys(elapsed).forEach((key) => {
|
|
281
|
+
elapsed[key].forEach((nlp_step) => {
|
|
282
|
+
Object.keys(nlp_step).forEach((step_name) => {
|
|
283
|
+
total_elapsed += nlp_step[step_name].delta;
|
|
293
284
|
});
|
|
294
285
|
});
|
|
286
|
+
});
|
|
295
287
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
288
|
+
const elapsed_status =
|
|
289
|
+
total_elapsed < queryTimeSecondsThreshold_OK
|
|
290
|
+
? { status: 'OK' }
|
|
291
|
+
: total_elapsed < queryTimeSecondsThreshold_WARNING
|
|
292
|
+
? { status: 'WARNING', error: 'Slow response from NLP' }
|
|
293
|
+
: { status: 'CRITICAL', error: 'Slow response from NLP' };
|
|
302
294
|
|
|
303
|
-
|
|
295
|
+
const airflow_status = await getStatus(appConfig, airflow_params);
|
|
304
296
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
297
|
+
let status = { status: 'OK' };
|
|
298
|
+
if (
|
|
299
|
+
elapsed_status.status === 'WARNING' ||
|
|
300
|
+
airflow_status.status === 'WARNING'
|
|
301
|
+
) {
|
|
302
|
+
status = { status: 'WARNING' };
|
|
303
|
+
}
|
|
304
|
+
if (
|
|
305
|
+
total_status.status === 'CRITICAL' ||
|
|
306
|
+
elapsed_status.status === 'CRITICAL' ||
|
|
307
|
+
airflow_status.status === 'CRITICAL'
|
|
308
|
+
) {
|
|
309
|
+
status = { status: 'CRITICAL' };
|
|
310
|
+
}
|
|
319
311
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
if (elapsed_status.error) {
|
|
325
|
-
errors_list.push(elapsed_status.error);
|
|
326
|
-
}
|
|
327
|
-
if (airflow_status.error) {
|
|
328
|
-
errors_list.push(airflow_status.error);
|
|
329
|
-
}
|
|
330
|
-
if (errors_list.length > 0) {
|
|
331
|
-
status.error = errors_list.join('\n');
|
|
332
|
-
}
|
|
333
|
-
resolve(status);
|
|
334
|
-
} catch (e) {
|
|
335
|
-
reject({ status: 'Critical', error: e.message });
|
|
312
|
+
const errors_list = [];
|
|
313
|
+
if (total_status.error) {
|
|
314
|
+
errors_list.push(total_status.error);
|
|
336
315
|
}
|
|
337
|
-
|
|
316
|
+
if (elapsed_status.error) {
|
|
317
|
+
errors_list.push(elapsed_status.error);
|
|
318
|
+
}
|
|
319
|
+
if (airflow_status.error) {
|
|
320
|
+
errors_list.push(airflow_status.error);
|
|
321
|
+
}
|
|
322
|
+
if (errors_list.length > 0) {
|
|
323
|
+
status.error = errors_list.join('\n');
|
|
324
|
+
}
|
|
325
|
+
return Promise.resolve(status);
|
|
326
|
+
} catch (e) {
|
|
327
|
+
return Promise.reject({ status: 'Critical', error: e.message });
|
|
328
|
+
}
|
|
338
329
|
}
|