Skip to content

Commit

Permalink
Modify prometheus push gateway to match scrape model (hyperledger-cal…
Browse files Browse the repository at this point in the history
  • Loading branch information
nklincoln authored and danielporto committed Nov 3, 2020
1 parent ab419fc commit 37a523e
Show file tree
Hide file tree
Showing 10 changed files with 219 additions and 200 deletions.
6 changes: 6 additions & 0 deletions packages/caliper-core/lib/common/config/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const nconf = require('nconf');
nconf.formats.yaml = require('nconf-yaml');

const keys = {
Auth: {
PrometheusPush: {
UserName: 'caliper-auth-prometheuspush-username',
Password: 'caliper-auth-prometheuspush-password'
}
},
Bind: {
Sut: 'caliper-bind-sut',
Args: 'caliper-bind-args',
Expand Down
10 changes: 9 additions & 1 deletion packages/caliper-core/lib/common/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
#

caliper:
# Settings related to the authorization
auth:
# Prometheus Push Gateway
prometheuspush:
# username
username:
# password
password:
# Settings related to the binding command
bind:
# The binding specification of the SUT in the <SUT type>:<SDK version> format
Expand Down Expand Up @@ -61,7 +69,7 @@ caliper:
# Configurations related to caliper test monitors
monitor:
# Default update interval
defaultinterval: 5000
defaultinterval: 10000
# Default scrape port for prometheus tx observer
prometheusscrapeport: 3000
# Configurations related to the logging mechanism
Expand Down
146 changes: 0 additions & 146 deletions packages/caliper-core/lib/common/prometheus/prometheus-push-client.js

This file was deleted.

29 changes: 25 additions & 4 deletions packages/caliper-core/lib/common/utils/caliper-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@

'use strict';

const loggingUtil = require('./logging-util.js');
const Config = require('../config/config-util');

const {exec, spawn} = require('child_process');
const path = require('path');
require('winston-daily-rotate-file');
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
const loggingUtil = require('./logging-util.js');
const Config = require('../config/config-util');
const url = require('url');
require('winston-daily-rotate-file');

const BuiltinConnectors = new Map([
['burrow', '@hyperledger/caliper-burrow'],
Expand Down Expand Up @@ -588,6 +590,25 @@ class CaliperUtils {
return value / 1000;
}

/**
* Augment the passed URL with basic auth if the settings are present
* @param {string} urlPath the URL to augment
* @param {string} component the component being augmented
* @returns {string} the URL to be used, which may have been augmented with basic auth
*/
static augmentUrlWithBasicAuth(urlPath, component) {
const username = Config.get(Config.keys.Auth[component].UserName, undefined);
const password = Config.get(Config.keys.Auth[component].Password, undefined);
if (username && password) {
const myURL = new url.URL(urlPath);
myURL.username = username;
myURL.password = password;
return url.format(myURL);
} else {
return urlPath;
}
}

}

module.exports = CaliperUtils;
3 changes: 3 additions & 0 deletions packages/caliper-core/lib/common/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ module.exports = {
TxsSubmitted: 'txsSubmitted',
TxsFinished: 'txsFinished'
}
},
AuthComponents: {
PushGateway: 'PrometheusPush'
}
};
Loading

0 comments on commit 37a523e

Please sign in to comment.