@whitewater-guide/gorge 3.0.0-beta.2 → 3.0.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/README.md +52 -9
- package/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Harvested data is stored in database and can be queried later.
|
|
|
13
13
|
- [Launching](#launching)
|
|
14
14
|
- [Working with API](#working-with-api)
|
|
15
15
|
- [Available scripts](#available-scripts)
|
|
16
|
+
- [Health notifications](#health-notifications)
|
|
16
17
|
- [Other](#other)
|
|
17
18
|
- [Development](#development)
|
|
18
19
|
- [Inside container](#inside-container)
|
|
@@ -89,6 +90,7 @@ Here is the list of available flags:
|
|
|
89
90
|
--db-chunk-size int measurements will be saved to db in chunks of this size. When set to 0, they will be saved in one chunk, which can cause errors
|
|
90
91
|
--debug enables debug mode, sets log level to debug
|
|
91
92
|
--endpoint string endpoint path (default "/")
|
|
93
|
+
--hooks-health-cron string cron expression for running health notifier (default "0 0 * * *")
|
|
92
94
|
--hooks-health-headers strings headers to set on request, in 'Header: Value' format, similar to curl (default [])
|
|
93
95
|
--hooks-health-threshold int hours required to pass since last successful execution to consider job unhealthy (default 48)
|
|
94
96
|
--hooks-health-url string external endpoint to call with list of unhealthy jobs
|
|
@@ -225,11 +227,11 @@ Below is the list of endpoints exposed by gorge server. You can use `request.htt
|
|
|
225
227
|
},
|
|
226
228
|
"status": {
|
|
227
229
|
// information about running job
|
|
228
|
-
"
|
|
229
|
-
"
|
|
230
|
+
"lastRun": "2020-02-25T17:44:00Z", // latest execution timestamp
|
|
231
|
+
"lastSuccess": "2020-02-25T17:44:00Z", // latest successful (>0 measurements harvested) execution timestamp (optional)
|
|
230
232
|
"count": 10, // number of measurements harvested during latest execution
|
|
231
|
-
"
|
|
232
|
-
"error": "somethin went wrong" // latest execution error
|
|
233
|
+
"nextRun": "2020-02-25T17:46:00Z", // next execution timestamp
|
|
234
|
+
"error": "somethin went wrong" // latest execution error (optional)
|
|
233
235
|
}
|
|
234
236
|
}
|
|
235
237
|
]
|
|
@@ -270,10 +272,10 @@ Below is the list of endpoints exposed by gorge server. You can use `request.htt
|
|
|
270
272
|
[
|
|
271
273
|
{
|
|
272
274
|
"010802": {
|
|
273
|
-
"
|
|
274
|
-
"
|
|
275
|
-
"count":
|
|
276
|
-
"
|
|
275
|
+
"lastRun": "2020-02-24T18:00:00Z",
|
|
276
|
+
"lastSuccess": "2020-02-24T18:00:00Z",
|
|
277
|
+
"count": 10,
|
|
278
|
+
"nextRun": "2020-02-25T18:00:00Z"
|
|
277
279
|
}
|
|
278
280
|
]
|
|
279
281
|
```
|
|
@@ -353,6 +355,48 @@ Below is the list of endpoints exposed by gorge server. You can use `request.htt
|
|
|
353
355
|
|
|
354
356
|
List of available scripts is [here](scripts/README.md)
|
|
355
357
|
|
|
358
|
+
### Health notifications
|
|
359
|
+
|
|
360
|
+
Gorge can call your webhooks when some of the running scripts haven't harvested any data for a period of time.
|
|
361
|
+
|
|
362
|
+
To configure healthcheck, use `--health--xxx` cli arguments. For example:
|
|
363
|
+
|
|
364
|
+
```yml
|
|
365
|
+
command:
|
|
366
|
+
[
|
|
367
|
+
|
|
368
|
+
'--hooks-health-cron',
|
|
369
|
+
'0 0 * * *', # check health every midnight
|
|
370
|
+
|
|
371
|
+
'--hooks-health-threshold',
|
|
372
|
+
'48', # scripts that haven't harvested anything within last 48 hours are considered unhealthy
|
|
373
|
+
|
|
374
|
+
'--hooks-health-url',
|
|
375
|
+
'http://host.docker.internal:3333/gorge/health', # so POST request will be made to this endpoint
|
|
376
|
+
|
|
377
|
+
'--hooks-health-headers',
|
|
378
|
+
'x-api-key: __test_gorge_health_key__', # multiple headers can be set on this request
|
|
379
|
+
]
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Example of this POST request payload:
|
|
383
|
+
|
|
384
|
+
```json
|
|
385
|
+
[
|
|
386
|
+
{
|
|
387
|
+
"id": "2f915d20-ffe6-11e8-8919-9f370230d1ae",
|
|
388
|
+
"script": "chile",
|
|
389
|
+
"lastRun": "2021-12-13T07:57:59Z"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"id": "e3c0c89a-7c72-11e9-8abd-cfc3ab2b843d",
|
|
393
|
+
"script": "quebec",
|
|
394
|
+
"lastRun": "2021-12-13T07:57:00Z",
|
|
395
|
+
"lastSuccess": "2021-12-10T09:22:00Z"
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
```
|
|
399
|
+
|
|
356
400
|
### Other
|
|
357
401
|
|
|
358
402
|
There're Typescript type definitions for the API available on [NPM](https://www.npmjs.com/package/@whitewater-guide/gorge)
|
|
@@ -419,7 +463,6 @@ Here are some recommendations for writing scripts for new sources
|
|
|
419
463
|
|
|
420
464
|
## TODO
|
|
421
465
|
|
|
422
|
-
- Notify when some script seem to be broken
|
|
423
466
|
- Virtual gauges
|
|
424
467
|
- Statuses
|
|
425
468
|
- What happens when one component is broken?
|
package/index.d.ts
CHANGED