Compare commits

...

3 Commits

Author SHA1 Message Date
anurag4DSB 52e95354a3 lint changes
Signed-off-by: anurag4DSB <anurag.213@gmail.com>
2018-04-16 17:58:28 -07:00
anurag4DSB 161141f9d5 Added metrics for cloudserver
Signed-off-by: anurag4DSB <anurag.213@gmail.com>
2018-04-16 17:58:28 -07:00
anurag4DSB 92c3e69356 started setting up metrics for cloudserver 2018-04-16 17:58:28 -07:00
40 changed files with 148 additions and 5 deletions

View File

@ -4,6 +4,7 @@ const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const { deleteBucket } = require('./apiUtils/bucket/bucketDeletion');
const { metadataValidateBucket } = require('../metadata/metadataUtils');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
/**
* bucketDelete - DELETE bucket (currently supports only non-versioned buckets)
@ -50,6 +51,8 @@ function bucketDelete(authInfo, request, log, cb) {
authInfo,
bucket: bucketName,
});
monitoring.deleteRequest.inc();
monitoring.currentBucketNumber.dec();
return cb(null, corsHeaders);
});
});

View File

@ -5,6 +5,7 @@ const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const { isBucketAuthorized } = require('./apiUtils/authorization/aclChecks');
const metadata = require('../metadata/wrapper');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
const requestType = 'bucketOwnerAction';
@ -62,6 +63,7 @@ function bucketDeleteCors(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.deleteRequest.inc();
return callback(err, corsHeaders);
});
});

View File

@ -2,6 +2,7 @@ const metadata = require('../metadata/wrapper');
const { metadataValidateBucket } = require('../metadata/metadataUtils');
const { pushMetric } = require('../utapi/utilities');
const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const monitoring = require('../utilities/monitoringHandler');
/**
* bucketDeleteLifecycle - Delete the bucket Lifecycle configuration
@ -48,6 +49,8 @@ function bucketDeleteLifecycle(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.deleteRequest.inc();
monitoring.currentLifecycleBucketNumber.dec();
return callback(null, corsHeaders);
});
});

View File

@ -2,6 +2,7 @@ const metadata = require('../metadata/wrapper');
const { metadataValidateBucket } = require('../metadata/metadataUtils');
const { pushMetric } = require('../utapi/utilities');
const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const monitoring = require('../utilities/monitoringHandler');
/**
* bucketDeleteReplication - Delete the bucket replication configuration
@ -48,6 +49,7 @@ function bucketDeleteReplication(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.deleteRequest.inc();
return callback(null, corsHeaders);
});
});

View File

@ -5,6 +5,7 @@ const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const { isBucketAuthorized } = require('./apiUtils/authorization/aclChecks');
const metadata = require('../metadata/wrapper');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
const requestType = 'bucketOwnerAction';
@ -54,6 +55,7 @@ function bucketDeleteWebsite(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.deleteRequest.inc();
return callback(null, corsHeaders);
});
});

View File

@ -8,6 +8,7 @@ const escapeForXml = s3middleware.escapeForXml;
const { pushMetric } = require('../utapi/utilities');
const validateSearchParams = require('../api/apiUtils/bucket/validateSearch');
const parseWhere = require('../api/apiUtils/bucket/parseWhere');
const monitoring = require('../utilities/monitoringHandler');
const versionIdUtils = versioning.VersionID;
/* Sample XML response for GET bucket objects:
@ -214,6 +215,7 @@ function handleResult(listParams, requestMaxKeys, encoding, authInfo,
res = processMasterVersions(bucketName, listParams, list);
}
pushMetric('listBucket', log, { authInfo, bucket: bucketName });
monitoring.getRequest.inc();
return callback(null, res, corsHeaders);
}

View File

@ -4,6 +4,7 @@ const { metadataValidateBucket } = require('../metadata/metadataUtils');
const vault = require('../auth/vault');
const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
// Sample XML response:
/*
@ -166,6 +167,7 @@ function bucketGetACL(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.getRequest.inc();
return callback(null, xml, corsHeaders);
});
});

View File

@ -6,6 +6,7 @@ const { convertToXml } = require('./apiUtils/bucket/bucketCors');
const { isBucketAuthorized } = require('./apiUtils/authorization/aclChecks');
const metadata = require('../metadata/wrapper');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
const requestType = 'bucketOwnerAction';
@ -55,6 +56,7 @@ function bucketGetCors(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.getRequest.inc();
return callback(null, xml, corsHeaders);
});
}

View File

@ -5,6 +5,7 @@ const LifecycleConfiguration =
const { metadataValidateBucket } = require('../metadata/metadataUtils');
const { pushMetric } = require('../utapi/utilities');
const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const monitoring = require('../utilities/monitoringHandler');
/**
* bucketGetLifecycle - Get the bucket lifecycle configuration
@ -45,6 +46,7 @@ function bucketGetLifecycle(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.getRequest.inc();
return callback(null, xml, corsHeaders);
});
}

View File

@ -6,6 +6,7 @@ const metadata = require('../metadata/wrapper');
const { pushMetric } = require('../utapi/utilities');
const escapeForXml = s3middleware.escapeForXml;
const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const monitoring = require('../utilities/monitoringHandler');
const requestType = 'bucketOwnerAction';
@ -58,7 +59,7 @@ function bucketGetLocation(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.getRequest.inc();
return callback(null, xml, corsHeaders);
});
}

View File

@ -5,6 +5,7 @@ const { pushMetric } = require('../utapi/utilities');
const { getReplicationConfigurationXML } =
require('./apiUtils/bucket/getReplicationConfiguration');
const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const monitoring = require('../utilities/monitoringHandler');
/**
* bucketGetReplication - Get the bucket replication configuration
@ -45,6 +46,7 @@ function bucketGetReplication(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.getRequest.inc();
return callback(null, xml, corsHeaders);
});
}

View File

@ -1,6 +1,7 @@
const { metadataValidateBucket } = require('../metadata/metadataUtils');
const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
// Sample XML response:
/*
@ -70,6 +71,7 @@ function bucketGetVersioning(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.getRequest.inc();
return callback(null, xml, corsHeaders);
});
}

View File

@ -6,6 +6,7 @@ const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const { isBucketAuthorized } = require('./apiUtils/authorization/aclChecks');
const metadata = require('../metadata/wrapper');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
const requestType = 'bucketOwnerAction';
@ -56,6 +57,7 @@ function bucketGetWebsite(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.getRequest.inc();
return callback(null, xml, corsHeaders);
});
}

View File

@ -2,6 +2,7 @@ const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const { metadataValidateBucket } = require('../metadata/metadataUtils');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
/**
* Determine if bucket exists and if user has permission to access it
@ -30,6 +31,7 @@ function bucketHead(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.headRequest.inc();
return callback(null, corsHeaders);
});
}

View File

@ -8,7 +8,7 @@ const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const { config } = require('../Config');
const aclUtils = require('../utilities/aclUtils');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
let { restEndpoints, locationConstraints } = config;
config.on('rest-endpoints-update', () => {
restEndpoints = config.restEndpoints;
@ -183,6 +183,9 @@ function bucketPut(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.putRequest.inc();
monitoring.totalBucketNumber.inc();
monitoring.currentBucketNumber.inc();
return next(null, corsHeaders);
}),
], callback);

View File

@ -9,6 +9,7 @@ const constants = require('../../constants');
const { metadataValidateBucket } = require('../metadata/metadataUtils');
const vault = require('../auth/vault');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
/*
Format of xml request:
@ -289,6 +290,7 @@ function bucketPutACL(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.putRequest.inc();
}
return callback(err, corsHeaders);
});

View File

@ -8,6 +8,7 @@ const { isBucketAuthorized } = require('./apiUtils/authorization/aclChecks');
const metadata = require('../metadata/wrapper');
const { parseCorsXml } = require('./apiUtils/bucket/bucketCors');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
const requestType = 'bucketOwnerAction';
@ -88,6 +89,7 @@ function bucketPutCors(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.putRequest.inc();
return callback(err, corsHeaders);
});
}

View File

@ -7,6 +7,7 @@ const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const metadata = require('../metadata/wrapper');
const { metadataValidateBucket } = require('../metadata/metadataUtils');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
/**
* Bucket Put Lifecycle - Create or update bucket lifecycle configuration
@ -64,6 +65,8 @@ function bucketPutLifecycle(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.putRequest.inc();
monitoring.currentLifecycleBucketNumber.inc();
return callback(null, corsHeaders);
});
}

View File

@ -7,6 +7,7 @@ const { pushMetric } = require('../utapi/utilities');
const { getReplicationConfiguration } =
require('./apiUtils/bucket/getReplicationConfiguration');
const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const monitoring = require('../utilities/monitoringHandler');
// The error response when a bucket does not have versioning 'Enabled'.
const versioningNotEnabledError = errors.InvalidRequest.customizeDescription(
@ -64,6 +65,7 @@ function bucketPutReplication(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.putRequest.inc();
return callback(null, corsHeaders);
});
}

View File

@ -9,6 +9,7 @@ const { pushMetric } = require('../utapi/utilities');
const versioningNotImplBackends =
require('../../constants').versioningNotImplBackends;
const { config } = require('../Config');
const monitoring = require('../utilities/monitoringHandler');
const externalVersioningErrorMessage = 'We do not currently support putting ' +
'a versioned object to a location-constraint of type Azure or GCP.';
@ -132,6 +133,7 @@ function bucketPutVersioning(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.putRequest.inc();
}
return callback(err, corsHeaders);
});

View File

@ -7,6 +7,7 @@ const { isBucketAuthorized } = require('./apiUtils/authorization/aclChecks');
const metadata = require('../metadata/wrapper');
const { parseWebsiteConfigXml } = require('./apiUtils/bucket/bucketWebsite');
const { pushMetric } = require('../utapi/utilities');
const monitoring = require('../utilities/monitoringHandler');
const requestType = 'bucketOwnerAction';
@ -72,6 +73,7 @@ function bucketPutWebsite(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.putRequest.inc();
}
return callback(err, corsHeaders);
});

View File

@ -16,6 +16,7 @@ const { preprocessingVersioningDelete }
= require('./apiUtils/object/versioning');
const createAndStoreObject = require('./apiUtils/object/createAndStoreObject');
const { metadataGetObject } = require('../metadata/metadataUtils');
const monitoring = require('../utilities/monitoringHandler');
const versionIdUtils = versioning.VersionID;
@ -490,6 +491,7 @@ function multiObjectDelete(authInfo, request, log, callback) {
byteLength: Number.parseInt(totalContentLengthDeleted, 10),
numberOfObjects: numOfObjectsRemoved,
});
monitoring.currentObjectNumber.dec();
return callback(null, xml, corsHeaders);
});
}

View File

@ -10,6 +10,7 @@ const { pushMetric } = require('../utapi/utilities');
const isLegacyAWSBehavior = require('../utilities/legacyAWSBehavior');
const { config } = require('../Config');
const multipleBackendGateway = require('../data/multipleBackendGateway');
const monitoring = require('../utilities/monitoringHandler');
/**
* multipartDelete - DELETE an open multipart upload from a bucket
@ -148,6 +149,7 @@ function multipartDelete(authInfo, request, log, callback) {
keys: [objectKey],
byteLength: partSizeSum,
});
monitoring.currentObjectNumber.dec();
return next(null, destBucket);
});
},

View File

@ -20,6 +20,7 @@ const { metadataValidateBucketAndObj } = require('../metadata/metadataUtils');
const validateWebsiteHeader = require('./apiUtils/object/websiteServing')
.validateWebsiteHeader;
const { config } = require('../Config');
const monitoring = require('../utilities/monitoringHandler');
const versionIdUtils = versioning.VersionID;
const locationHeader = constants.objectLocationConstraintHeader;
@ -485,6 +486,8 @@ function objectCopy(authInfo, request, sourceBucket,
newByteLength: sourceObjSize,
oldByteLength: isVersioned ? null : destObjPrevSize,
});
monitoring.totalObjectNumber.inc();
monitoring.currentObjectNumber.inc();
// Add expiration header if lifecycle enabled
return callback(null, xml, additionalHeaders);
});

View File

@ -8,6 +8,7 @@ const createAndStoreObject = require('./apiUtils/object/createAndStoreObject');
const { decodeVersionId, preprocessingVersioningDelete }
= require('./apiUtils/object/versioning');
const { metadataValidateBucketAndObj } = require('../metadata/metadataUtils');
const monitoring = require('../utilities/monitoringHandler');
const versionIdUtils = versioning.VersionID;
@ -170,7 +171,10 @@ function objectDelete(authInfo, request, log, cb) {
bucket: bucketName,
keys: [objectKey],
byteLength: Number.parseInt(objectMD['content-length'], 10),
numberOfObjects: 1 });
numberOfObjects: 1,
});
monitoring.deleteRequest.inc();
monitoring.currentObjectNumber.dec();
}
return cb(err, resHeaders);
});

View File

@ -11,6 +11,7 @@ const metadata = require('../metadata/wrapper');
const getReplicationInfo = require('./apiUtils/object/getReplicationInfo');
const { config } = require('../Config');
const multipleBackendGateway = require('../data/multipleBackendGateway');
const monitoring = require('../utilities/monitoringHandler');
const REPLICATION_ACTION = 'DELETE_TAGGING';
/**
@ -102,6 +103,7 @@ function objectDeleteTagging(authInfo, request, log, callback) {
bucket: bucketName,
keys: [objectKey],
});
monitoring.deleteRequest.inc();
const verCfg = bucket.getVersioningConfiguration();
additionalResHeaders['x-amz-version-id'] =
getVersionIdResHeader(verCfg, objectMD);

View File

@ -10,6 +10,7 @@ const { pushMetric } = require('../utapi/utilities');
const { getVersionIdResHeader } = require('./apiUtils/object/versioning');
const setPartRanges = require('./apiUtils/object/setPartRanges');
const { metadataValidateBucketAndObj } = require('../metadata/metadataUtils');
const monitoring = require('../utilities/monitoringHandler');
const validateHeaders = s3middleware.validateConditionalHeaders;
@ -200,6 +201,7 @@ function objectGet(authInfo, request, returnTagCount, log, callback) {
newByteLength:
Number.parseInt(responseMetaHeaders['Content-Length'], 10),
});
monitoring.getRequest.inc();
return callback(null, dataLocator, responseMetaHeaders,
byteRange);
});

View File

@ -9,6 +9,7 @@ const { decodeVersionId, getVersionIdResHeader }
= require('./apiUtils/object/versioning');
const vault = require('../auth/vault');
const { metadataValidateBucketAndObj } = require('../metadata/metadataUtils');
const monitoring = require('../utilities/monitoringHandler');
// Sample XML response:
/*
@ -216,6 +217,7 @@ function objectGetACL(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.getRequest.inc();
resHeaders['x-amz-version-id'] = resVersionId;
return callback(null, xml, resHeaders);
});

View File

@ -8,6 +8,7 @@ const { metadataValidateBucketAndObj } = require('../metadata/metadataUtils');
const { pushMetric } = require('../utapi/utilities');
const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const { convertToXml } = s3middleware.tagging;
const monitoring = require('../utilities/monitoringHandler');
/**
* Object Get Tagging - Return tag for object
@ -84,6 +85,7 @@ function objectGetTagging(authInfo, request, log, callback) {
authInfo,
bucket: bucketName,
});
monitoring.getRequest.inc();
const verCfg = bucket.getVersioningConfiguration();
additionalResHeaders['x-amz-version-id'] =
getVersionIdResHeader(verCfg, objectMD);

View File

@ -6,6 +6,7 @@ const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const collectResponseHeaders = require('../utilities/collectResponseHeaders');
const { pushMetric } = require('../utapi/utilities');
const { getVersionIdResHeader } = require('./apiUtils/object/versioning');
const monitoring = require('../utilities/monitoringHandler');
const { metadataValidateBucketAndObj } = require('../metadata/metadataUtils');
@ -78,6 +79,7 @@ function objectHead(authInfo, request, log, callback) {
const responseHeaders =
collectResponseHeaders(objMD, corsHeaders, verCfg);
pushMetric('headObject', log, { authInfo, bucket: bucketName });
monitoring.headRequest.inc();
return callback(null, responseHeaders);
});
}

View File

@ -9,6 +9,7 @@ const { checkQueryVersionId } = require('./apiUtils/object/versioning');
const { metadataValidateBucketAndObj } = require('../metadata/metadataUtils');
const { pushMetric } = require('../utapi/utilities');
const kms = require('../kms/wrapper');
const monitoring = require('../utilities/monitoringHandler');
const versionIdUtils = versioning.VersionID;
@ -118,6 +119,10 @@ function objectPut(authInfo, request, streamingV4Params, log, callback) {
newByteLength,
oldByteLength: isVersionedObj ? null : oldByteLength,
});
monitoring.putRequest.inc();
monitoring.bytesUploaded.inc(newByteLength);
monitoring.totalObjectNumber.inc();
monitoring.currentObjectNumber.inc();
return callback(null, responseHeaders);
});
});

View File

@ -10,6 +10,7 @@ const vault = require('../auth/vault');
const { decodeVersionId, getVersionIdResHeader }
= require('./apiUtils/object/versioning');
const { metadataValidateBucketAndObj } = require('../metadata/metadataUtils');
const monitoring = require('../utilities/monitoringHandler');
/*
Format of xml request:
@ -301,6 +302,7 @@ function objectPutACL(authInfo, request, log, cb) {
bucket: bucketName,
keys: [objectKey],
});
monitoring.putRequest.inc();
return cb(null, resHeaders);
});
}

View File

@ -10,6 +10,7 @@ const logger = require('../utilities/logger');
const services = require('../services');
const setUpCopyLocator = require('./apiUtils/object/setUpCopyLocator');
const { metadataValidateBucketAndObj } = require('../metadata/metadataUtils');
const monitoring = require('../utilities/monitoringHandler');
const versionIdUtils = versioning.VersionID;
@ -333,6 +334,7 @@ function objectPutCopyPart(authInfo, request, sourceBucket,
}
}
additionalHeaders['x-amz-copy-source-version-id'] = sourceVerId;
monitoring.putRequest.inc();
// TODO push metric for objectPutCopyPart
// pushMetric('putObjectCopyPart', log, {
// bucket: destBucketName,

View File

@ -14,6 +14,7 @@ const { pushMetric } = require('../utapi/utilities');
const logger = require('../utilities/logger');
const { config } = require('../Config');
const multipleBackendGateway = require('../data/multipleBackendGateway');
const monitoring = require('../utilities/monitoringHandler');
const skipError = new Error('skip');
@ -345,6 +346,10 @@ function objectPutPart(authInfo, request, streamingV4Params, log,
newByteLength: size,
oldByteLength: prevObjectSize,
});
monitoring.putRequest.inc();
monitoring.bytesUploaded.inc(size);
monitoring.totalObjectNumber.inc();
monitoring.currentObjectNumber.inc();
return cb(null, hexDigest, corsHeaders);
});
}

View File

@ -11,6 +11,7 @@ const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const metadata = require('../metadata/wrapper');
const { config } = require('../Config');
const multipleBackendGateway = require('../data/multipleBackendGateway');
const monitoring = require('../utilities/monitoringHandler');
const { parseTagXml } = s3middleware.tagging;
const REPLICATION_ACTION = 'PUT_TAGGING';
@ -108,6 +109,7 @@ function objectPutTagging(authInfo, request, log, callback) {
bucket: bucketName,
keys: [objectKey],
});
monitoring.putRequest.inc();
const verCfg = bucket.getVersioningConfiguration();
additionalResHeaders['x-amz-version-id'] =
getVersionIdResHeader(verCfg, objectMD);

View File

@ -2,6 +2,7 @@ const { errors } = require('arsenal');
const constants = require('../../constants');
const services = require('../services');
const monitoring = require('../utilities/monitoringHandler');
/*
* Format of xml response:
@ -75,6 +76,7 @@ function serviceGet(authInfo, request, log, callback) {
if (err) {
return callback(err);
}
monitoring.getRequest.inc();
// TODO push metric for serviceGet
// pushMetric('getService', log, {
// bucket: bucketName,

View File

@ -11,6 +11,7 @@ const { isObjAuthorized } = require('./apiUtils/authorization/aclChecks');
const collectResponseHeaders = require('../utilities/collectResponseHeaders');
const { pushMetric } = require('../utapi/utilities');
const { isBucketAuthorized } = require('./apiUtils/authorization/aclChecks');
const monitoring = require('../utilities/monitoringHandler');
/**
* _errorActions - take a number of actions once have error getting obj
@ -205,6 +206,7 @@ function websiteGet(request, log, callback) {
bucket: bucketName,
newByteLength: responseMetaHeaders['Content-Length'],
});
monitoring.getRequest.inc();
return callback(null, false, dataLocator, responseMetaHeaders);
});
});

View File

@ -11,7 +11,7 @@ const { isObjAuthorized } = require('./apiUtils/authorization/aclChecks');
const collectResponseHeaders = require('../utilities/collectResponseHeaders');
const { pushMetric } = require('../utapi/utilities');
const { isBucketAuthorized } = require('./apiUtils/authorization/aclChecks');
const monitoring = require('../utilities/monitoringHandler');
/**
* _errorActions - take a number of actions once have error getting obj
@ -151,6 +151,7 @@ function websiteHead(request, log, callback) {
pushMetric('headObject', log, {
bucket: bucketName,
});
monitoring.headRequest.inc();
return callback(null, responseMetaHeaders);
});
});

View File

@ -2,6 +2,7 @@ const http = require('http');
const https = require('https');
const cluster = require('cluster');
const arsenal = require('arsenal');
const monitoringClient = require('./utilities/monitoringHandler');
const { RedisClient, StatsClient } = require('arsenal').metrics;
const logger = require('./utilities/logger');
@ -248,6 +249,7 @@ function main() {
const server = new S3Server(cluster.worker);
server.initiateStartup(logger.newRequestLogger());
}
monitoringClient.collectDefaultMetrics({ timeout: 5000 });
}
module.exports = main;

View File

@ -1,6 +1,49 @@
const errors = require('arsenal');
const client = require('prom-client');
const collectDefaultMetrics = client.collectDefaultMetrics;
const totalBucketNumber = new client.Counter({
name: 'cloud_server_bucket_number_total',
help: 'Total number of buckets created by Zenko(post deployment)',
});
const currentBucketNumber = new client.Gauge({
name: 'cloud_server_bucket_number_current',
help: 'Current number of buckets created by Zenko(post deployment)',
});
const currentLifecycleBucketNumber = new client.Gauge({
name: 'cloud_server_bucket_lifecycle_number_current',
help: 'Current number of lifecycle buckets created by Zenko',
});
const totalObjectNumber = new client.Counter({
name: 'cloud_server_object_number_total',
help: 'Total number of objects uploaded by Zenko(post deployment)',
});
const currentObjectNumber = new client.Gauge({
name: 'cloud_server_object_number_current',
help: 'Current number of objects uploaded by Zenko(post deployment)',
});
const getRequest = new client.Counter({
name: 'cloud_server_get_request',
help: 'Number of GET requests made through Zenko(post deployment)',
});
const putRequest = new client.Counter({
name: 'cloud_server_put_request',
help: 'Number of PUT requests made through Zenko(post deployment)',
});
const deleteRequest = new client.Counter({
name: 'cloud_server_delete_request',
help: 'Number of DELETE requests made through Zenko(post deployment)',
});
const headRequest = new client.Counter({
name: 'cloud_server_head_request',
help: 'Number of HEAD requests made through Zenko(post deployment)',
});
const bytesUploaded = new client.Counter({
name: 'cloud_server_bytes_uploaded',
help: 'Number of bytes uploaded made through Zenko(post deployment)',
});
function writeResponse(res, error, log, results, cb) {
let statusCode = 200;
if (error) {
@ -22,7 +65,6 @@ function routeHandler(req, res, log, cb) {
if (req.method !== 'GET') {
return cb(errors.BadRequest, []);
}
client.collectDefaultMetrics();
const promMetrics = client.register.metrics();
const contentLen = Buffer.byteLength(promMetrics, 'utf8');
res.setHeader('content-length', contentLen);
@ -62,4 +104,16 @@ function monitoringHandler(clientIP, req, res, log) {
module.exports = {
monitoringHandler,
client,
collectDefaultMetrics,
totalBucketNumber,
currentBucketNumber,
currentLifecycleBucketNumber,
totalObjectNumber,
currentObjectNumber,
getRequest,
bytesUploaded,
putRequest,
deleteRequest,
headRequest,
};