Skip to content

Commit

Permalink
feat(vps): move metrics to mimir
Browse files Browse the repository at this point in the history
Signed-off-by: cyril.biencourt <[email protected]>
  • Loading branch information
lizardK committed Nov 20, 2024
1 parent ca43a88 commit dea61dc
Show file tree
Hide file tree
Showing 15 changed files with 307 additions and 285 deletions.
2 changes: 1 addition & 1 deletion packages/components/ng-ovh-chart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"angular": "~1.6",
"chart.js": "^4.4.2",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-plugin-datasource-prometheus": "^2.1.3",
"chartjs-plugin-datasource-prometheus": "^2.3.0",
"chartjs-plugin-zoom": "^2.0.1",
"date-fns": "^2.24.0"
}
Expand Down
13 changes: 13 additions & 0 deletions packages/manager/apps/dedicated/client/app/app.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import './css/source.scss';
import get from 'lodash/get';
import has from 'lodash/has';
import set from 'lodash/set';
import * as dateFnsLocales from 'date-fns/locale';
import isString from 'lodash/isString';
import trustedNic from '@ovh-ux/manager-trusted-nic';
import '@ovh-ux/ng-at-internet';
Expand Down Expand Up @@ -131,6 +132,17 @@ const getLocale = (shellClient) => {
return shellClient.i18n.getLocale();
};

const getDateFnsLocale = (language) => {
if (language === 'en_GB') {
return 'enGB';
}
if (language === 'fr_CA') {
return 'frCA';
}
const [locale] = language.split('_');
return locale;
};

export default async (containerEl, shellClient) => {
const moduleName = 'App';

Expand Down Expand Up @@ -233,6 +245,7 @@ export default async (containerEl, shellClient) => {
].filter(isString),
)
.service('Polling', pollingService)
.constant('DATEFNS_LOCALE', dateFnsLocales[getDateFnsLocale(locale)])
.constant('shellClient', shellClient)
.constant('constants', {
prodMode: config.prodMode,
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/apps/dedicated/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"bootstrap4": "twbs/bootstrap#v4.6.2",
"chart.js": "^4.4.2",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-plugin-datasource-prometheus": "^2.1.3",
"chartjs-plugin-datasource-prometheus": "^2.3.0",
"chartjs-plugin-zoom": "^2.0.1",
"clipboard": "^2.0.4",
"components-jqueryui": "^1.12.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/apps/iplb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"bootstrap": "~3.3.7",
"chart.js": "^4.4.2",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-plugin-datasource-prometheus": "^2.1.3",
"chartjs-plugin-datasource-prometheus": "^2.3.0",
"chartjs-plugin-zoom": "^2.0.1",
"clipboard": "^2.0.4",
"core-js": "^3.6.5",
Expand Down
1 change: 1 addition & 0 deletions packages/manager/apps/vps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"bootstrap": "~3.3.0",
"chart.js": "^4.4.2",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-plugin-datasource-prometheus": "^2.3.0",
"chartjs-plugin-zoom": "^2.0.1",
"clipboard": "^2.0.4",
"core-js": "^3.6.5",
Expand Down
16 changes: 16 additions & 0 deletions packages/manager/apps/vps/src/app.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { isString, get } from 'lodash-es';

import angular from 'angular';
import cloudUniverseComponents from '@ovh-ux/ng-ovh-cloud-universe-components';
import * as dateFnsLocales from 'date-fns/locale';
import ngAtInternet from '@ovh-ux/ng-at-internet';
import ngOvhChart from '@ovh-ux/ng-ovh-chart';
import ngOvhFeatureFlipping from '@ovh-ux/ng-ovh-feature-flipping';
Expand All @@ -20,6 +21,17 @@ import ngOvhPaymentMethod from '@ovh-ux/ng-ovh-payment-method';
import '@ovh-ux/ui-kit/dist/css/oui.css';
import 'ovh-ui-kit-bs/dist/css/oui-bs3.css';

const getDateFnsLocale = (language) => {
if (language === 'en_GB') {
return 'enGB';
}
if (language === 'fr_CA') {
return 'frCA';
}
const [locale] = language.split('_');
return locale;
};

export default (containerEl, environment) => {
const moduleName = 'vpsApp';
angular
Expand Down Expand Up @@ -57,6 +69,10 @@ export default (containerEl, environment) => {
$urlRouterProvider.otherwise('/vps');
},
)
.constant(
'DATEFNS_LOCALE',
dateFnsLocales[getDateFnsLocale(environment.userLocale)],
)
.run(
/* @ngInject */ ($translate) => {
let lang = $translate.use();
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"bootstrap4": "twbs/bootstrap#v4.6.2",
"chart.js": "^4.4.2",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-plugin-datasource-prometheus": "^2.1.3",
"chartjs-plugin-datasource-prometheus": "^2.3.0",
"chartjs-plugin-zoom": "^2.0.1",
"clipboard": "^2.0.4",
"core-js": "^3.6.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/modules/iplb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"bootstrap": "~3.3.0",
"chart.js": "^4.4.2",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-plugin-datasource-prometheus": "^2.1.3",
"chartjs-plugin-datasource-prometheus": "^2.3.0",
"chartjs-plugin-zoom": "^2.0.1",
"date-fns": "^2.24.0",
"moment": "^2.24.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/manager/modules/vps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"bootstrap": "~3.3.0",
"chart.js": "^4.4.2",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-plugin-datasource-prometheus": "^2.3.0",
"chartjs-plugin-zoom": "^2.0.1",
"date-fns": "^2.24.0",
"jsurl": "0.1.5",
"moment": "^2.24.0",
"oclazyload": "^1.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"vps_monitoring": "Monitoring"
"vps_monitoring": "Monitoring",
"vps_monitoring_loading_data": "Chargement des données ...",
"vps_monitoring_data_none": "Il n'y a aucune statistique à afficher."
}
Original file line number Diff line number Diff line change
@@ -1,49 +1,50 @@
export const VPS_MONITORING_BPS_OPTIONS = {
data: {
datasets: [],
},
options: {
scales: {
x: {
grid: {
display: false,
},
},
y: {
id: 'y-axis-1',
type: 'linear',
display: true,
position: 'left',
min: 0,
beginAtZero: true,
title: {
display: true,
text: 'BPS',
},
},
export const VPS_MONITORING_CHARTS = [
{
title: 'vps_configuration_monitoring_usage_proc',
min: 0,
max: 100,
queries: (serviceName) => [
`sum(rec_libvirtd_domain_cpu_usage{service_name="${serviceName}"})`,
],
yTitle: '%',
bgColor: '#59d2ef',
borderColor: '#00a2bf',
legend: {
display: false,
labels: [],
},
elements: {
line: {
fill: true,
borderColor: '#00a2bf',
borderWidth: 4,
tension: 0.5,
},
point: {
radius: 0,
},
},
{
title: 'vps_configuration_monitoring_usage_ram',
min: 0,
max: 100,
queries: (serviceName) => [
`sum((rec_libvirtd_domain_balloon_rss{service_name="${serviceName}"} / rec_libvirtd_domain_balloon_current{service_name="${serviceName}"}) * 100)`,
],
yTitle: '%',
bgColor: '#59d2ef',
borderColor: '#00a2bf',
legend: {
display: false,
labels: [],
},
plugins: {
legend: {
display: true,
},
tooltip: {
mode: 'index',
intersect: false,
},
},
{
title: 'vps_configuration_monitoring_usage_trafic',
min: 0,
queries: (serviceName) => [
`sum(rate(rec_libvirtd_domain_net_rx_bytes{service_name="${serviceName}"}[5m]) * 8)`,
`sum(rate(rec_libvirtd_domain_net_tx_bytes{service_name="${serviceName}"}[5m]) * 8)`,
],
yTitle: 'BPS',
bgColor: ['rgba(241,196,15, .5)', 'rgba(52,152,219, .5)'],
borderColor: ['#F1C40F', '#00a2bf'],
legend: {
display: true,
labels: ['vps_monitoring_network_netRx', 'vps_monitoring_network_netTx'],
},
},
};
];

export const VPS_MONITORING_COLORS = [
'#F1C40F',
Expand All @@ -52,55 +53,41 @@ export const VPS_MONITORING_COLORS = [
'#72C02C',
];

export const VPS_MONITORING_PERCENT_OPTIONS = {
data: {
datasets: [],
export const VPS_MONITORING_PERIODS = [
{
label: 'TODAY',
value: '1d',
step: '1m',
timeRange: -(new Date() - new Date().setHours(0, 0, 0, 0)),
},
options: {
scales: {
x: {
grid: {
display: false,
},
},

y: {
id: 'y-axe',
type: 'linear',
min: 0,
max: 100,
beginAtZero: true,
title: {
display: true,
text: '%',
},
},
},
elements: {
line: {
fill: true,
backgroundColor: '#59d2ef',
borderColor: '#00a2bf',
borderWidth: 4,
},
point: {
radius: 0,
},
},
plugins: {
legend: {
display: false,
},
tooltip: {
mode: 'index',
intersect: false,
},
},
{
label: 'LASTDAY',
value: '1d',
step: '1m',
timeRange: -24 * 60 * 60 * 1000,
},
};

{
label: 'LASTWEEK',
value: '7d',
step: '1m',
timeRange: -7 * 24 * 60 * 60 * 1000,
isDefault: true,
},
{
label: 'LASTMONTH',
value: '30d',
step: '5m',
timeRange: -1 * 30 * 24 * 60 * 60 * 1000,
},
{
label: 'LASTYEAR',
value: '365d',
step: '60m',
timeRange: -365 * 24 * 60 * 60 * 1000,
},
];
export default {
VPS_MONITORING_BPS_OPTIONS,
VPS_MONITORING_CHARTS,
VPS_MONITORING_COLORS,
VPS_MONITORING_PERCENT_OPTIONS,
VPS_MONITORING_PERIODS,
};
Loading

0 comments on commit dea61dc

Please sign in to comment.