liveperson-functions-cli
Version:
LivePerson Functions CLI
77 lines • 2.86 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const metrics_controller_1 = require("../controller/metrics.controller");
const utils_1 = require("../shared/utils");
const printer_1 = require("../view/printer");
class Metrics extends core_1.Command {
constructor() {
super(...arguments);
this.errorMessage = new printer_1.ErrorMessage();
this.metricsController = new metrics_controller_1.MetricsController();
}
/**
* Runs the invoke command and parses the passed function and flag
* @returns {Promise<void>} - invoke command
* @memberof Invoke
*/
async run() {
try {
const { flags: inputFlags } = await this.parse(Metrics);
const [lambdaFunction] = (0, utils_1.parseInput)(Metrics.flags, this.argv);
await this.metricsController.getMetrics({ lambdaFunction, inputFlags });
}
catch (error) {
this.errorMessage.print(error.message || error.errorMsg);
this.exit(1);
}
}
}
exports.default = Metrics;
Metrics.description = 'Download invocation metrics';
Metrics.flags = {
help: core_1.Flags.help({ char: 'h' }),
start: core_1.Flags.string({
char: 's',
description: 'start timestamp',
exclusive: ['last'],
}),
end: core_1.Flags.string({
char: 'e',
description: 'end timestamp (defaults to current timestamp)',
}),
last: core_1.Flags.string({
char: 'l',
description: 'An alternative to start flag, metrics for the period of the last x hours|days, options: xh, xd; eg. last 12h, 7d',
exclusive: ['start'],
}),
output: core_1.Flags.string({
char: 'o',
description: 'Optional: output formatting for file saving purposes',
options: ['csv', 'json'],
}),
};
Metrics.args = [
{
name: 'function-name',
required: true,
description: 'name of lambda',
default: null,
},
];
Metrics.examples = [
'> <%= config.bin %> metrics exampleFunction --last=7d',
'> <%= config.bin %> metrics exampleFunction --start=1626156400000',
'> <%= config.bin %> metrics exampleFunction --end=1626156400000 --last=7d',
'> <%= config.bin %> metrics exampleFunction --start=1626156400000 --end=1626157400000',
'',
'For redirecting metrics to a file:',
'lpf metrics exampleFunction --start=1626156400000 --output="csv" >> exampleFunction.csv',
'',
"The metrics are aggregated into buckets. These buckets' sizes can be chosen as 5m, 1h, 1d",
'',
'Fetching metrics via cronjob every 24 hours and write it to a file:',
'MacOS:',
'0 0 * * * <%= config.bin %> lpf metrics exampleFunction -l=1d -o=csv >> exampleFunction.csv',
];
//# sourceMappingURL=metrics.js.map