Compare commits

..

No commits in common. "f87c27791ca62ce10f5727e3e2b401dc0dd1f133" and "9fe16c64fa3ba3d1b78aad5a777b86fafb98a779" have entirely different histories.

3 changed files with 24 additions and 43 deletions

View File

@ -10,13 +10,13 @@ const isTest = process.env.CI === 'true';
class Metrics {
constructor(config, logger) {
const { redisConfig, crrSites, internalStart } = config;
const { redisConfig, validSites, internalStart } = config;
this._logger = logger;
this._redisClient = new RedisClient(redisConfig, this._logger);
// Redis expiry increased by an additional interval so we can reference
// the immediate older data for average throughput calculation
this._statsClient = new StatsModel(this._redisClient, INTERVAL, EXPIRY);
this._crrSites = crrSites;
this._validSites = validSites;
this._internalStart = internalStart;
}
@ -34,7 +34,7 @@ class Metrics {
return async.map(ops, (op, done) => {
const hasGlobalKey = this._hasGlobalKey(op);
if (site === 'all') {
const queryStrings = this._crrSites.map(s => {
const queryStrings = this._validSites.map(s => {
if (bucketName && objectKey && versionId) {
return `${s}:${bucketName}:${objectKey}:` +
`${versionId}:${op}`;
@ -50,7 +50,7 @@ class Metrics {
}
// Query only a single given site or storage class
// First, validate the site or storage class
if (!this._crrSites.includes(site)) {
if (!this._validSites.includes(site)) {
// escalate error to log later
return done({
message: 'invalid site name provided',

View File

@ -5,17 +5,10 @@
/**
* The metrics route model.
* @param {Object} redisKeys - The Redis keys used for Backbeat metrics
* @param {Object} locations - Locations by service
* @param {Array} locations.crr - The list of replication location names
* @param {Array} locations.ingestion - The list of ingestion location names
* @param {Array} allLocations - The list of replication location names
* @return {Array} The array of route objects
*/
function routes(redisKeys, locations) {
/* eslint-disable no-param-reassign */
locations.crr = locations.crr || [];
locations.ingestion = locations.ingestion || [];
/* eslint-enable no-param-reassign */
function routes(redisKeys, allLocations) {
return [
// Route: /_/healthcheck
{
@ -30,7 +23,7 @@ function routes(redisKeys, locations) {
httpMethod: 'GET',
category: 'metrics',
type: 'pending',
extensions: { crr: [...locations.crr, 'all'] },
extensions: { crr: [...allLocations, 'all'] },
method: 'getPending',
dataPoints: [redisKeys.opsPending, redisKeys.bytesPending],
},
@ -39,7 +32,7 @@ function routes(redisKeys, locations) {
httpMethod: 'GET',
category: 'metrics',
type: 'backlog',
extensions: { crr: [...locations.crr, 'all'] },
extensions: { crr: [...allLocations, 'all'] },
method: 'getBacklog',
dataPoints: [redisKeys.opsPending, redisKeys.bytesPending],
},
@ -48,7 +41,7 @@ function routes(redisKeys, locations) {
httpMethod: 'GET',
category: 'metrics',
type: 'completions',
extensions: { crr: [...locations.crr, 'all'] },
extensions: { crr: [...allLocations, 'all'] },
method: 'getCompletions',
dataPoints: [redisKeys.opsDone, redisKeys.bytesDone],
},
@ -57,7 +50,7 @@ function routes(redisKeys, locations) {
httpMethod: 'GET',
category: 'metrics',
type: 'failures',
extensions: { crr: [...locations.crr, 'all'] },
extensions: { crr: [...allLocations, 'all'] },
method: 'getFailedMetrics',
dataPoints: [redisKeys.opsFail, redisKeys.bytesFail],
},
@ -66,7 +59,7 @@ function routes(redisKeys, locations) {
httpMethod: 'GET',
category: 'metrics',
type: 'throughput',
extensions: { crr: [...locations.crr, 'all'] },
extensions: { crr: [...allLocations, 'all'] },
method: 'getThroughput',
dataPoints: [redisKeys.opsDone, redisKeys.bytesDone],
},
@ -75,7 +68,7 @@ function routes(redisKeys, locations) {
httpMethod: 'GET',
category: 'metrics',
type: 'all',
extensions: { crr: [...locations.crr, 'all'] },
extensions: { crr: [...allLocations, 'all'] },
method: 'getAllMetrics',
dataPoints: [redisKeys.ops, redisKeys.opsDone, redisKeys.opsFail,
redisKeys.bytes, redisKeys.bytesDone, redisKeys.bytesFail,
@ -87,7 +80,7 @@ function routes(redisKeys, locations) {
category: 'metrics',
type: 'progress',
level: 'object',
extensions: { crr: [...locations.crr] },
extensions: { crr: [...allLocations] },
method: 'getObjectProgress',
dataPoints: [redisKeys.objectBytes, redisKeys.objectBytesDone],
},
@ -97,7 +90,7 @@ function routes(redisKeys, locations) {
category: 'metrics',
type: 'throughput',
level: 'object',
extensions: { crr: [...locations.crr] },
extensions: { crr: [...allLocations] },
method: 'getObjectThroughput',
dataPoints: [redisKeys.objectBytesDone],
},
@ -131,54 +124,42 @@ function routes(redisKeys, locations) {
method: 'monitoringHandler',
},
// Route: /_/crr/pause/<location>
// Route: /_/ingestion/pause/<location>
// Where <location> is an optional field
{
httpMethod: 'POST',
type: 'pause',
extensions: {
crr: [...locations.crr, 'all'],
ingestion: [...locations.ingestion, 'all'],
},
method: 'pauseService',
extensions: { crr: [...allLocations, 'all'] },
method: 'pauseCRRService',
},
// Route: /_/crr/resume/<location>
// Route: /_/ingestion/resume/<location>
// Route: /_/crr/resume/<location>/schedule
// Where <location> is an optional field unless "schedule" route
{
httpMethod: 'POST',
type: 'resume',
extensions: {
crr: [...locations.crr, 'all'],
ingestion: [...locations.ingestion, 'all'],
},
method: 'resumeService',
extensions: { crr: [...allLocations, 'all'] },
method: 'resumeCRRService',
},
{
httpMethod: 'DELETE',
type: 'resume',
extensions: { crr: [...locations.crr, 'all'] },
extensions: { crr: [...allLocations, 'all'] },
method: 'deleteScheduledResumeService',
},
// Route: /_/crr/resume/<location>
{
httpMethod: 'GET',
type: 'resume',
extensions: { crr: [...locations.crr, 'all'] },
extensions: { crr: [...allLocations, 'all'] },
method: 'getResumeCRRSchedule',
},
// Route: /_/crr/status/<location>
// Route: /_/ingestion/status/<location>
// Where <location> is an optional field
{
httpMethod: 'GET',
type: 'status',
extensions: {
crr: [...locations.crr, 'all'],
ingestion: [...locations.ingestion, 'all'],
},
method: 'getServiceStatus',
extensions: { crr: [...allLocations, 'all'] },
method: 'getCRRServiceStatus',
},
];
}

View File

@ -25,7 +25,7 @@ const redisClient = new RedisClient(config, fakeLogger);
const sites = ['site1', 'site2'];
const metrics = new backbeat.Metrics({
redisConfig: config,
crrSites: ['site1', 'site2', 'all'],
validSites: ['site1', 'site2', 'all'],
internalStart: Date.now() - (EXPIRY * 1000), // 24 hours ago.
}, fakeLogger);
@ -46,7 +46,7 @@ describe('Metrics class', () => {
opsPending: 'bb:crr:bytespending',
bytesPending: 'bb:crr:opspending',
};
const routes = backbeat.routes(redisKeys, { crr: sites });
const routes = backbeat.routes(redisKeys, sites);
const details = routes.find(route =>
route.category === 'metrics' && route.type === 'all');
details.site = 'all';