-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
33 lines (28 loc) · 1.29 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const CronJob = require('cron').CronJob;
const pkg = require('./package.json');
const config = require('@toolisticon/ssl-hostinfo-prometheus-exporter').config;
const log = require('@toolisticon/ssl-hostinfo-prometheus-exporter').logger;
const updateHosts = require('@toolisticon/ssl-hostinfo-prometheus-exporter').updateHosts;
const updateRouteInfo = require('@toolisticon/ssl-hostinfo-prometheus-exporter').updateRouteInfo;
const startPrometheusListener = require('@toolisticon/ssl-hostinfo-prometheus-exporter').startPrometheusListener;
const routes = require('./lib/routes');
log.info('oc-routes-prometheus-exporter info', { version: pkg.version });
async function triggerUpdate () {
log.info('Start reading route information.');
// read hosts from route info
routes.list().then((routeList) => {
const hostnames = [];
// reconstruct hostname data on route update
routeList.forEach((route) => hostnames.push(route.spec.host), log.error);
updateHosts(hostnames);
routeList.forEach((route) => updateRouteInfo(route.spec.host, route.metadata), log.error);
}, log.error);
}
/* eslint no-new: "off" */
new CronJob(config.cron, () => {
log.info(`Triggering check`);
triggerUpdate();
}, null, true, 'UTC');
// trigger one update immediatly
triggerUpdate();
startPrometheusListener();