Skip to content

Commit 1548373

Browse files
Merge pull request #5585 from nimrod-becker/nimrod_backport_4_0
Backport Prometheus Metrics phase2 into 4.0
2 parents 1a48828 + d584090 commit 1548373

File tree

6 files changed

+288
-59
lines changed

6 files changed

+288
-59
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "noobaa-core",
3-
"version": "4.0.1",
3+
"version": "4.0.2",
44
"private": true,
55
"license": "SEE LICENSE IN LICENSE",
66
"description": "",

src/api/stats_api.js

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ module.exports = {
3333
}
3434
},
3535

36+
get_partial_accounts_stats: {
37+
method: 'GET',
38+
reply: {
39+
$ref: '#/definitions/partial_accounts_stats'
40+
},
41+
auth: {
42+
system: 'admin'
43+
}
44+
},
45+
3646
get_nodes_stats: {
3747
method: 'GET',
3848
reply: {
@@ -483,14 +493,17 @@ module.exports = {
483493

484494
partial_stats: {
485495
type: 'object',
486-
required: ['systems_stats', 'cloud_pool_stats'],
496+
required: ['systems_stats', 'cloud_pool_stats', 'accounts_stats'],
487497
properties: {
488498
systems_stats: {
489499
$ref: '#/definitions/partial_systems_stats'
490500
},
491501
cloud_pool_stats: {
492502
$ref: '#/definitions/cloud_pool_stats'
493503
},
504+
accounts_stats: {
505+
$ref: '#/definitions/partial_accounts_stats'
506+
},
494507
}
495508
},
496509

@@ -502,20 +515,61 @@ module.exports = {
502515
type: 'array',
503516
items: {
504517
type: 'object',
505-
required: ['name', 'free_space', 'total_space', 'buckets_stats'],
518+
required: ['name', 'capacity', 'reduction_ratio', 'savings', 'buckets_stats', 'usage_by_project', 'usage_by_bucket_class'],
506519
properties: {
507520
name: {
508521
type: 'string'
509522
},
510-
free_space: {
511-
$ref: 'common_api#/definitions/bigint'
523+
capacity: {
524+
type: 'number'
512525
},
513-
total_space: {
514-
$ref: 'common_api#/definitions/bigint'
526+
savings: {
527+
type: 'number'
528+
},
529+
reduction_ratio: {
530+
type: 'number'
515531
},
516532
buckets_stats: {
517533
$ref: '#/definitions/partial_buckets_stats'
518534
},
535+
usage_by_project: {
536+
type: 'object',
537+
additionalProperties: true,
538+
properties: {},
539+
},
540+
usage_by_bucket_class: {
541+
type: 'object',
542+
additionalProperties: true,
543+
properties: {},
544+
},
545+
}
546+
}
547+
}
548+
}
549+
},
550+
551+
partial_accounts_stats: {
552+
type: 'object',
553+
required: ['accounts'],
554+
properties: {
555+
accounts: {
556+
type: 'array',
557+
items: {
558+
type: 'object',
559+
required: ['account', 'read_count', 'write_count', 'read_write_bytes'],
560+
properties: {
561+
account: {
562+
type: 'string'
563+
},
564+
read_count: {
565+
type: 'number'
566+
},
567+
write_count: {
568+
type: 'number'
569+
},
570+
read_write_bytes: {
571+
type: 'number'
572+
},
519573
}
520574
}
521575
}

src/deploy/NVA_build/noobaa_core.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ spec:
126126
tcpSocket:
127127
port: 6001
128128
timeoutSeconds: 5
129-
image: noobaa/noobaa-core:4.0.1
129+
image: noobaa/noobaa-core:4.0.2
130130
imagePullPolicy: IfNotPresent
131131
resources:
132132
# https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/

src/server/analytic_services/prometheus_reporting.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,30 @@ const METRIC_RECORDS = Object.freeze([{
1717
help: 'Cloud Resource Types in the System',
1818
labelNames: ['type', 'count']
1919
}
20+
}, {
21+
metric_type: 'Gauge',
22+
metric_variable: 'projects_capacity_usage',
23+
configuration: {
24+
name: get_metric_name('projects_capacity_usage'),
25+
help: 'Projects Capacity Usage',
26+
labelNames: ['project', 'count']
27+
}
28+
}, {
29+
metric_type: 'Gauge',
30+
metric_variable: 'accounts_io_usage',
31+
configuration: {
32+
name: get_metric_name('accounts_io_usage'),
33+
help: 'Accounts I/O Usage',
34+
labelNames: ['account', 'read_count', 'write_count']
35+
}
36+
}, {
37+
metric_type: 'Gauge',
38+
metric_variable: 'bucket_class_capacity_usage',
39+
configuration: {
40+
name: get_metric_name('bucket_class_capacity_usage'),
41+
help: 'Bucket Class Capacity Usage',
42+
labelNames: ['bucket_class', 'count']
43+
}
2044
}, {
2145
metric_type: 'Gauge',
2246
metric_variable: 'unhealthy_cloud_types',
@@ -105,6 +129,22 @@ const METRIC_RECORDS = Object.freeze([{
105129
help: 'Objects On Object Bucket Claims',
106130
},
107131
generate_default_set: true,
132+
}, {
133+
metric_type: 'Gauge',
134+
metric_variable: 'reduction_ratio',
135+
configuration: {
136+
name: get_metric_name('reduction_ratio'),
137+
help: 'Object Efficiency Ratio',
138+
},
139+
generate_default_set: true,
140+
}, {
141+
metric_type: 'Gauge',
142+
metric_variable: 'object_savings',
143+
configuration: {
144+
name: get_metric_name('object_savings'),
145+
help: 'Object Savings',
146+
},
147+
generate_default_set: true,
108148
}]);
109149

110150

@@ -173,6 +213,31 @@ class PrometheusReporting {
173213
this._metrics.unhealthy_cloud_types.set({ type: 'S3_Compatible' }, types.unhealthy_cloud_pool_target.s3_comp_unhealthy);
174214
}
175215

216+
set_bucket_class_capacity_usage(usage_info) {
217+
if (!this.enabled()) return;
218+
this._metrics.bucket_class_capacity_usage.reset();
219+
for (let [key, value] of Object.entries(usage_info)) {
220+
this._metrics.bucket_class_capacity_usage.set({ bucket_class: key }, value);
221+
}
222+
}
223+
224+
set_projects_capacity_usage(usage_info) {
225+
if (!this.enabled()) return;
226+
this._metrics.projects_capacity_usage.reset();
227+
for (let [key, value] of Object.entries(usage_info)) {
228+
this._metrics.projects_capacity_usage.set({ project: key }, value);
229+
}
230+
}
231+
232+
set_accounts_io_usage(accounts_info) {
233+
if (!this.enabled()) return;
234+
this._metrics.accounts_io_usage.reset();
235+
accounts_info.accounts.forEach(account_info => {
236+
const { account, read_count, write_count, read_write_bytes } = account_info;
237+
this._metrics.accounts_io_usage.set({ account, read_count, write_count }, read_write_bytes);
238+
});
239+
}
240+
176241
set_object_sizes(sizes) {
177242
if (!this.enabled()) return;
178243
for (const bin of sizes) {

src/server/system_services/account_server.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -706,31 +706,26 @@ function check_external_connection(req) {
706706
return P.resolve()
707707
.then(() => {
708708
switch (endpoint_type) {
709-
case 'AZURE':
710-
{
711-
return check_azure_connection(params);
712-
}
709+
case 'AZURE': {
710+
return check_azure_connection(params);
711+
}
713712

714713
case 'AWS':
715714
case 'S3_COMPATIBLE':
716-
case 'FLASHBLADE':
717-
{
718-
return check_aws_connection(params);
719-
}
715+
case 'FLASHBLADE': {
716+
return check_aws_connection(params);
717+
}
720718

721-
case 'NET_STORAGE':
722-
{
723-
return check_net_storage_connection(params);
724-
}
725-
case 'GOOGLE':
726-
{
727-
return check_google_connection(params);
728-
}
719+
case 'NET_STORAGE': {
720+
return check_net_storage_connection(params);
721+
}
722+
case 'GOOGLE': {
723+
return check_google_connection(params);
724+
}
729725

730-
default:
731-
{
732-
throw new Error('Unknown endpoint type');
733-
}
726+
default: {
727+
throw new Error('Unknown endpoint type');
728+
}
734729
}
735730
});
736731
}

0 commit comments

Comments
 (0)