diff --git a/.gitignore b/.gitignore index ff146e0..69a22fa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules sonar-scanner.properties .scannerwork/ artifacts +.idea diff --git a/deployment/remediations-consumer-clowdapp.yaml b/deployment/remediations-consumer-clowdapp.yaml index ed6f82d..04209d7 100644 --- a/deployment/remediations-consumer-clowdapp.yaml +++ b/deployment/remediations-consumer-clowdapp.yaml @@ -99,7 +99,7 @@ objects: - name: METRICS_PREFIX value: remediations_cleaner_ - name: METRICS_PUSH_GATEWAY - value: http://${PROMETHEUS_PUSHGATEWAY} + value: ${METRICS_GW_SCHEME}${PROMETHEUS_PUSHGATEWAY} - name: METRICS_PUSH_GATEWAY_ENABLED value: ${METRICS_PUSH_GATEWAY_ENABLED} resources: @@ -146,6 +146,10 @@ parameters: name: IMAGE_TAG required: true - name: PROMETHEUS_PUSHGATEWAY +- name: METRICS_GW_SCHEME + value: 'http://' +- name: PROMETHEUS_PUSHGATEWAY + value: 'localhost:9091' - name: METRICS_PUSH_GATEWAY_ENABLED value: 'true' - description: Cpu limit of cleaner job diff --git a/src/cleaner/probes.ts b/src/cleaner/probes.ts index 1e62e63..dd7772c 100644 --- a/src/cleaner/probes.ts +++ b/src/cleaner/probes.ts @@ -41,11 +41,12 @@ export async function pushMetrics () { const asyncGateway = P.promisifyAll(gateway); const jobName = `${config.namespace}|${os.hostname}`; - logger.info({jobName}, 'pushing metrics'); - const resp = await asyncGateway.pushAsync({jobName}); if (resp.statusCode !== 200) { throw new Error(`failed to push metrics ${resp.statusCode}`); } + log.info('metrics sent'); + } else { + log.info(`metrics not enabled(METRICS_PUSH_GATEWAY_ENABLED = ${config.metrics.pushGatewayEnabled})`); } } diff --git a/src/cleaner/run.ts b/src/cleaner/run.ts index dd94719..ebb8b40 100644 --- a/src/cleaner/run.ts +++ b/src/cleaner/run.ts @@ -18,7 +18,6 @@ async function run () { } finally { try { await probes.pushMetrics(); - log.info('metrics sent'); } finally { await stop(); }