Skip to content

Instantly share code, notes, and snippets.

@intech
Created April 17, 2020 09:19
Show Gist options
  • Save intech/5461324937faf4e3b4d5d294af23b90d to your computer and use it in GitHub Desktop.
Save intech/5461324937faf4e3b4d5d294af23b90d to your computer and use it in GitHub Desktop.
With vault
"use strict";
const Vault = require("node-vault");
const url = require("url");
const _ = require("lodash");
// ENV
// VAULT=https://[email protected]/project/
module.exports = async () => {
const { VAULT } = process.env;
if(!VAULT) throw new Error("VAULT Env is not set!");
const { auth: token, protocol, host, path } = url.parse(VAULT);
const vault = Vault({
apiVersion: "v1",
token,
endpoint: [protocol, host].join("//"),
pathPrefix: path
});
const { data: env } = await vault.read("env");
const { data: config } = await vault.read("config");
console.log({ env, config });
// load env
process.env = { ...process.env, ...env };
// return config broker
return _.defaultsDeep(config, {
namespace: "TEST",
// disableBalancer: true,
logger: {
type: "Console",
options: {
level: "info",
colors: false,
moduleColors: false,
// Line formatter. It can be "json", "short", "simple", "full", a `Function` or a template string like "{timestamp} {level} {nodeID}/{mod}: {msg}"
formatter: "full",
objectPrinter: null,
autoPadding: false
}
},
tracing: {
enabled: false,
events: false,
stackTrace: true,
exporter: [
//"Console",
{
type: "Jaeger",
options: {
endpoint: process.env.JAEGER,
sampler: {
type: "Const",
options: {}
},
tracerOptions: {},
defaultTags: null
}
}
]
},
metrics: {
enabled: true,
reporter: [{
type: "Prometheus",
options: {
// HTTP port
port: 3030,
// HTTP URL path
path: "/metrics",
// Default labels which are appended to all metrics labels
defaultLabels: registry => ({
namespace: registry.broker.namespace,
nodeID: registry.broker.nodeID
})
}
}]
},
metricsRate: 1
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment