Skip to content

Commit

Permalink
Addition of metrics for OCS links
Browse files Browse the repository at this point in the history
  • Loading branch information
jeniawhite authored and nimrod-becker committed Jul 24, 2019
1 parent 1975c03 commit 1c3dbb3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
15 changes: 14 additions & 1 deletion src/api/stats_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,24 @@ module.exports = {
type: 'array',
items: {
type: 'object',
required: ['name', 'capacity', 'reduction_ratio', 'savings', 'total_usage', 'buckets_stats', 'usage_by_project', 'usage_by_bucket_class'],
required: [
'name',
'address',
'capacity',
'reduction_ratio',
'savings',
'total_usage',
'buckets_stats',
'usage_by_project',
'usage_by_bucket_class',
],
properties: {
name: {
type: 'string'
},
address: {
type: 'string'
},
capacity: {
type: 'number'
},
Expand Down
4 changes: 2 additions & 2 deletions src/server/analytic_services/prometheus_reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const METRIC_RECORDS = Object.freeze([{
configuration: {
name: get_metric_name('system_info'),
help: 'System info',
labelNames: ['system_name']
labelNames: ['system_name', 'system_address']
}
}, {
metric_type: 'Gauge',
Expand Down Expand Up @@ -342,7 +342,7 @@ class PrometheusReporting {

set_system_info(info) {
if (!this.enabled()) return;
this._metrics.system_info.set({ system_name: info.name }, 0);
this._metrics.system_info.set({ system_name: info.name, system_address: info.address }, 0);
}

update_providers_bandwidth(type, write_size, read_size) {
Expand Down
13 changes: 12 additions & 1 deletion src/server/system_services/stats_aggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const prom_report = require('../analytic_services/prometheus_reporting').Prometh
const HistoryDataStore = require('../analytic_services/history_data_store').HistoryDataStore;
const { google } = require('googleapis');
const google_storage = google.storage('v1');
const addr_utils = require('../../util/addr_utils');


const ops_aggregation = {};
Expand Down Expand Up @@ -146,6 +147,7 @@ const PARTIAL_SINGLE_ACCOUNT_DEFAULTS = {

const PARTIAL_SINGLE_SYS_DEFAULTS = {
name: '',
address: '',
capacity: 0,
reduction_ratio: 0,
savings: {
Expand Down Expand Up @@ -370,8 +372,16 @@ async function get_partial_systems_stats(req) {
const total_usage = size_utils.bigint_to_bytes(storage.used);
const capacity = 100 - Math.floor(((free_bytes / total_bytes) || 1) * 100);

const { system_address } = system;
const https_port = process.env.SSL_PORT || 5443;
const address = DEV_MODE ? `https://localhost:${https_port}` : addr_utils.get_base_address(system_address, {
hint: 'EXTERNAL',
protocol: 'https'
}).toString();

return _.defaults({
name: system.name,
address,
capacity,
reduction_ratio,
savings,
Expand Down Expand Up @@ -832,6 +842,7 @@ function partial_cycle_parse_prometheus_metrics(payload) {
reduction_ratio,
savings,
name,
address,
usage_by_bucket_class,
usage_by_project,
total_usage,
Expand All @@ -851,7 +862,7 @@ function partial_cycle_parse_prometheus_metrics(payload) {
prom_report.instance().set_num_unhealthy_pools(unhealthy_pool_count);
prom_report.instance().set_num_pools(pool_count);
prom_report.instance().set_unhealthy_cloud_types(cloud_pool_stats);
prom_report.instance().set_system_info({ name });
prom_report.instance().set_system_info({ name, address });
prom_report.instance().set_num_buckets(buckets);
prom_report.instance().set_num_objects(objects_in_buckets);
prom_report.instance().set_num_unhealthy_buckets(unhealthy_buckets);
Expand Down

0 comments on commit 1c3dbb3

Please sign in to comment.