UNPKG

@toolisticon/oc-routes-prometheus-exporter

Version:

[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE) [![CI](https://github.com/toolisticon/oc-routes-prometheus-exporter/actions/workflows/build.yml/badge.svg)](https://github.com/toolisticon/oc-routes-prometheus-exporter/act

34 lines (28 loc) 1.32 kB
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();