Fixed Console Widgets to match grafana information (#737)

* Fixed Console Widgets to match grafana information

* Fix the Prometheus queries

Signed-off-by: Daniel Valdivia <hola@danielvaldivia.com>

* Add missing steps

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* adjust interval

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Fixed inconsistence with backend names

* Reimplemented step calc to avoid issues on multime times request

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Daniel Valdivia <hola@danielvaldivia.com>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
Alex
2021-05-12 15:35:14 -05:00
committed by GitHub
parent 1daec71271
commit 5c73137d60
10 changed files with 593 additions and 287 deletions

View File

@@ -29,7 +29,7 @@
"codemirror": "^5.52.2", "codemirror": "^5.52.2",
"history": "^4.10.1", "history": "^4.10.1",
"local-storage-fallback": "^4.1.1", "local-storage-fallback": "^4.1.1",
"lodash": "^4.17.19", "lodash": "^4.17.21",
"moment": "^2.29.1", "moment": "^2.29.1",
"react": "17.0.1", "react": "17.0.1",
"react-app-rewire-hot-loader": "^2.0.1", "react-app-rewire-hot-loader": "^2.0.1",

View File

@@ -422,9 +422,19 @@ export const generatePoolName = (pools: IPool[]) => {
}; };
// seconds / minutes /hours / Days / Years calculator // seconds / minutes /hours / Days / Years calculator
export const niceDays = (secondsValue: string) => { export const niceDays = (secondsValue: string, timeVariant: string = "s") => {
let seconds = parseFloat(secondsValue); let seconds = parseFloat(secondsValue);
switch (timeVariant) {
case "ns":
seconds = Math.floor(seconds * 0.000000001);
break;
case "ms":
seconds = Math.floor(seconds * 0.001);
break;
default:
}
const days = Math.floor(seconds / (3600 * 24)); const days = Math.floor(seconds / (3600 * 24));
seconds -= days * 3600 * 24; seconds -= days * 3600 * 24;

View File

@@ -77,7 +77,7 @@ const PrDashboard = ({ classes, displayErrorMessage }: IPrDashboard) => {
const xSpacing = 10; const xSpacing = 10;
const ySpacing = 10; const ySpacing = 10;
const dashboardDistr = getDashboardDistribution(); const dashboardDistr = getDashboardDistribution(panelInformation.length);
const autoSizerStyleProp = { const autoSizerStyleProp = {
width: "100%", width: "100%",
@@ -121,7 +121,7 @@ const PrDashboard = ({ classes, displayErrorMessage }: IPrDashboard) => {
hideYAxis={value.disableYAxis} hideYAxis={value.disableYAxis}
xAxisFormatter={value.xAxisFormatter} xAxisFormatter={value.xAxisFormatter}
yAxisFormatter={value.yAxisFormatter} yAxisFormatter={value.yAxisFormatter}
panelWidth={singlePanelWidth * dashboardDistr[index].w} panelWidth={dashboardDistr[index] ? singlePanelWidth * dashboardDistr[index].w : singlePanelWidth}
/> />
); );
case widgetType.barChart: case widgetType.barChart:
@@ -160,12 +160,12 @@ const PrDashboard = ({ classes, displayErrorMessage }: IPrDashboard) => {
); );
const fetchUsage = useCallback(() => { const fetchUsage = useCallback(() => {
let stepCalc = 15; let stepCalc = 0;
if (timeStart !== null && timeEnd !== null) { if (timeStart !== null && timeEnd !== null) {
const secondsInPeriod = timeEnd.unix() - timeStart.unix(); const secondsInPeriod = timeEnd.unix() - timeStart.unix();
const periods = secondsInPeriod / 60; const periods = Math.floor(secondsInPeriod / 60);
stepCalc = periods < 1 ? 15 : periods; stepCalc = periods < 1 ? 15 : periods;
} }

View File

@@ -32,8 +32,8 @@ export const defaultWidgetsLayout: Layout[] = [
h: 2, h: 2,
x: 0, x: 0,
y: 0, y: 0,
minW: 1,
i: "panel-0", i: "panel-0",
minW: 1,
moved: false, moved: false,
static: false, static: false,
}, },
@@ -41,9 +41,9 @@ export const defaultWidgetsLayout: Layout[] = [
w: 1, w: 1,
h: 1, h: 1,
x: 1, x: 1,
y: 0, y: 2,
minW: 1,
i: "panel-1", i: "panel-1",
minW: 1,
moved: false, moved: false,
static: false, static: false,
}, },
@@ -51,9 +51,9 @@ export const defaultWidgetsLayout: Layout[] = [
w: 1, w: 1,
h: 1, h: 1,
x: 1, x: 1,
y: 1, y: 3,
minW: 1,
i: "panel-2", i: "panel-2",
minW: 1,
moved: false, moved: false,
static: false, static: false,
}, },
@@ -62,8 +62,8 @@ export const defaultWidgetsLayout: Layout[] = [
h: 2, h: 2,
x: 2, x: 2,
y: 0, y: 0,
minW: 1,
i: "panel-3", i: "panel-3",
minW: 1,
moved: false, moved: false,
static: false, static: false,
}, },
@@ -72,18 +72,18 @@ export const defaultWidgetsLayout: Layout[] = [
h: 2, h: 2,
x: 3, x: 3,
y: 0, y: 0,
minW: 2,
i: "panel-4", i: "panel-4",
minW: 2,
moved: false, moved: false,
static: false, static: false,
}, },
{ {
w: 3, w: 2,
h: 2, h: 2,
x: 5, x: 5,
y: 0, y: 0,
minW: 2,
i: "panel-5", i: "panel-5",
minW: 2,
moved: false, moved: false,
static: false, static: false,
}, },
@@ -92,8 +92,8 @@ export const defaultWidgetsLayout: Layout[] = [
h: 1, h: 1,
x: 0, x: 0,
y: 2, y: 2,
minW: 1,
i: "panel-6", i: "panel-6",
minW: 1,
moved: false, moved: false,
static: false, static: false,
}, },
@@ -102,58 +102,108 @@ export const defaultWidgetsLayout: Layout[] = [
h: 1, h: 1,
x: 0, x: 0,
y: 3, y: 3,
minW: 1,
i: "panel-7", i: "panel-7",
minW: 1,
moved: false, moved: false,
static: false, static: false,
}, },
{ {
w: 1, w: 1,
h: 1, h: 1,
x: 1, x: 2,
y: 2, y: 2,
minW: 1,
i: "panel-8", i: "panel-8",
minW: 1,
moved: false, moved: false,
static: false, static: false,
}, },
{ {
w: 1, w: 1,
h: 1, h: 1,
x: 1, x: 2,
y: 3, y: 3,
minW: 1,
i: "panel-9", i: "panel-9",
moved: false,
static: false,
},
{
w: 1,
h: 1,
x: 2,
y: 2,
minW: 1, minW: 1,
i: "panel-10",
moved: false, moved: false,
static: false, static: false,
}, },
{ {
w: 1, w: 2,
h: 1,
x: 2,
y: 3,
minW: 1,
i: "panel-11",
moved: false,
static: false,
},
{
w: 4,
h: 2, h: 2,
x: 3, x: 3,
y: 2, y: 2,
i: "panel-10",
minW: 2, minW: 2,
moved: false,
static: false,
},
{
w: 1,
h: 1,
x: 7,
y: 0,
i: "panel-11",
minW: 1,
moved: false,
static: false,
},
{
w: 1,
h: 1,
x: 7,
y: 1,
i: "panel-12", i: "panel-12",
minW: 1,
moved: false,
static: false,
},
{
w: 4,
h: 3,
x: 0,
y: 10,
i: "panel-13",
minW: 2,
moved: false,
static: false,
},
{
w: 4,
h: 3,
x: 0,
y: 4,
i: "panel-14",
minW: 2,
moved: false,
static: false,
},
{
w: 2,
h: 2,
x: 5,
y: 2,
i: "panel-15",
minW: 2,
moved: false,
static: false,
},
{
w: 8,
h: 3,
x: 0,
y: 7,
i: "panel-16",
minW: 2,
moved: false,
static: false,
},
{
w: 8,
h: 3,
x: 0,
y: 19,
i: "panel-19",
minW: 2,
moved: false, moved: false,
static: false, static: false,
}, },
@@ -162,8 +212,8 @@ export const defaultWidgetsLayout: Layout[] = [
h: 1, h: 1,
x: 7, x: 7,
y: 2, y: 2,
i: "panel-20",
minW: 1, minW: 1,
i: "panel-13",
moved: false, moved: false,
static: false, static: false,
}, },
@@ -172,68 +222,88 @@ export const defaultWidgetsLayout: Layout[] = [
h: 1, h: 1,
x: 7, x: 7,
y: 3, y: 3,
i: "panel-21",
minW: 1, minW: 1,
i: "panel-14",
moved: false, moved: false,
static: false, static: false,
}, },
{ {
w: 8, w: 4,
h: 2, h: 3,
x: 0, x: 4,
y: 4, y: 4,
i: "panel-22",
minW: 2, minW: 2,
i: "panel-15",
moved: false, moved: false,
static: false, static: false,
}, },
{ {
w: 4, w: 4,
h: 2, h: 3,
x: 4,
y: 10,
i: "panel-23",
minW: 2,
moved: false,
static: false,
},
{
w: 4,
h: 3,
x: 0, x: 0,
y: 5, y: 13,
i: "panel-24",
minW: 2, minW: 2,
i: "panel-16",
moved: false, moved: false,
static: false, static: false,
}, },
{ {
w: 4, w: 4,
h: 2, h: 3,
x: 5, x: 4,
y: 5, y: 13,
i: "panel-25",
minW: 2, minW: 2,
i: "panel-17",
moved: false, moved: false,
static: false, static: false,
}, },
{ {
w: 8, w: 4,
h: 2, h: 3,
x: 0, x: 0,
y: 7, y: 16,
i: "panel-26",
minW: 2, minW: 2,
i: "panel-18",
moved: false, moved: false,
static: false, static: false,
}, },
{ {
w: 4, w: 4,
h: 2, h: 3,
x: 0, x: 4,
y: 9, y: 16,
i: "panel-27",
minW: 2, minW: 2,
i: "panel-19",
moved: false, moved: false,
static: false, static: false,
}, },
{ {
w: 4, w: 1,
h: 2, h: 1,
x: 5, x: 1,
y: 9, y: 0,
minW: 2, i: "panel-28",
i: "panel-20", minW: 1,
moved: false,
static: false,
},
{
w: 1,
h: 1,
x: 1,
y: 1,
i: "panel-29",
minW: 1,
moved: false, moved: false,
static: false, static: false,
}, },
@@ -251,6 +321,10 @@ const colorsMain = [
"#ADD5E0", "#ADD5E0",
]; ];
const niceDaysFromNS = (seconds: string) => {
return niceDays(seconds, 'ns');
}
export const panelsConfiguration: IDashboardPanel[] = [ export const panelsConfiguration: IDashboardPanel[] = [
{ {
title: "Uptime", title: "Uptime",
@@ -260,19 +334,19 @@ export const panelsConfiguration: IDashboardPanel[] = [
labelDisplayFunction: niceDays, labelDisplayFunction: niceDays,
}, },
{ {
title: "Total Online disks", title: "Total Online Disks",
data: "N/A", data: "N/A",
type: widgetType.singleValue, type: widgetType.singleValue,
layoutIdentifier: "panel-1", layoutIdentifier: "panel-1",
}, },
{ {
title: "Total Offline disks", title: "Total Offline Disks",
data: "N/A", data: "N/A",
type: widgetType.singleValue, type: widgetType.singleValue,
layoutIdentifier: "panel-2", layoutIdentifier: "panel-2",
}, },
{ {
title: "Total Data", title: "Current Usable Capacity",
data: [], data: [],
dataOuter: [{ name: "outer", value: 100 }], dataOuter: [{ name: "outer", value: 100 }],
widgetConfiguration: { widgetConfiguration: {
@@ -297,7 +371,7 @@ export const panelsConfiguration: IDashboardPanel[] = [
labelDisplayFunction: niceBytes, labelDisplayFunction: niceBytes,
}, },
{ {
title: "Data Growth", title: "Data Usage Growth",
data: [], data: [],
widgetConfiguration: [ widgetConfiguration: [
{ {
@@ -366,26 +440,6 @@ export const panelsConfiguration: IDashboardPanel[] = [
type: widgetType.singleValue, type: widgetType.singleValue,
layoutIdentifier: "panel-7", layoutIdentifier: "panel-7",
}, },
{
title: "Total S3 Traffic Inbound",
data: [],
innerLabel: "N/A",
type: widgetType.singleRep,
layoutIdentifier: "panel-8",
color: "#22B573",
fillColor: "#A6E8C4",
labelDisplayFunction: niceBytes,
},
{
title: "Total S3 Traffic Outbound",
data: [],
innerLabel: "N/A",
type: widgetType.singleRep,
layoutIdentifier: "panel-9",
color: "#22B573",
fillColor: "#A6E8C4",
labelDisplayFunction: niceBytes,
},
{ {
title: "Number of Buckets", title: "Number of Buckets",
data: [], data: [],
@@ -393,7 +447,7 @@ export const panelsConfiguration: IDashboardPanel[] = [
type: widgetType.singleRep, type: widgetType.singleRep,
color: "#0071BC", color: "#0071BC",
fillColor: "#ADD5E0", fillColor: "#ADD5E0",
layoutIdentifier: "panel-10", layoutIdentifier: "panel-8",
}, },
{ {
title: "Number of Objects", title: "Number of Objects",
@@ -402,10 +456,10 @@ export const panelsConfiguration: IDashboardPanel[] = [
type: widgetType.singleRep, type: widgetType.singleRep,
color: "#0071BC", color: "#0071BC",
fillColor: "#ADD5E0", fillColor: "#ADD5E0",
layoutIdentifier: "panel-11", layoutIdentifier: "panel-9",
}, },
{ {
title: "S3 API Request & Error Rate", title: "S3 API Data Received Rate",
data: [], data: [],
widgetConfiguration: [ widgetConfiguration: [
{ {
@@ -416,7 +470,7 @@ export const panelsConfiguration: IDashboardPanel[] = [
}, },
], ],
type: widgetType.linearGraph, type: widgetType.linearGraph,
layoutIdentifier: "panel-12", layoutIdentifier: "panel-10",
disableYAxis: true, disableYAxis: true,
xAxisFormatter: getTimeFromTimestamp, xAxisFormatter: getTimeFromTimestamp,
}, },
@@ -425,21 +479,53 @@ export const panelsConfiguration: IDashboardPanel[] = [
data: [], data: [],
innerLabel: "N/A", innerLabel: "N/A",
type: widgetType.singleRep, type: widgetType.singleRep,
layoutIdentifier: "panel-13", layoutIdentifier: "panel-11",
color: "#F7655E", color: "#22B573",
fillColor: "#F4CECE", fillColor: "#A6E8C4",
}, },
{ {
title: "Total Goroutines", title: "Total Goroutines",
data: [], data: [],
innerLabel: "N/A", innerLabel: "N/A",
type: widgetType.singleRep, type: widgetType.singleRep,
layoutIdentifier: "panel-14", layoutIdentifier: "panel-12",
color: "#F7655E", color: "#F7655E",
fillColor: "#F4CECE", fillColor: "#F4CECE",
}, },
{ {
title: "S3 API Data Transfer", title: "Node CPU Usage",
data: [],
widgetConfiguration: [
{
dataKey: "",
keyLabel: "",
lineColor: "#000",
fillColor: "#000",
},
],
type: widgetType.linearGraph,
layoutIdentifier: "panel-13",
disableYAxis: true,
xAxisFormatter: getTimeFromTimestamp,
},
{
title: "S3 API Request Rate",
data: [],
widgetConfiguration: [
{
dataKey: "",
keyLabel: "",
lineColor: "#000",
fillColor: "#000",
},
],
type: widgetType.linearGraph,
layoutIdentifier: "panel-14",
yAxisFormatter: niceBytes,
xAxisFormatter: getTimeFromTimestamp,
},
{
title: "S3 API Data Sent Rate",
data: [], data: [],
widgetConfiguration: [ widgetConfiguration: [
{ {
@@ -451,11 +537,10 @@ export const panelsConfiguration: IDashboardPanel[] = [
], ],
type: widgetType.linearGraph, type: widgetType.linearGraph,
layoutIdentifier: "panel-15", layoutIdentifier: "panel-15",
disableYAxis: true,
xAxisFormatter: getTimeFromTimestamp, xAxisFormatter: getTimeFromTimestamp,
}, },
{ {
title: "Total S3 API Data Transfer", title: "Internode Data Transfer",
data: [], data: [],
widgetConfiguration: [ widgetConfiguration: [
{ {
@@ -471,38 +556,7 @@ export const panelsConfiguration: IDashboardPanel[] = [
xAxisFormatter: getTimeFromTimestamp, xAxisFormatter: getTimeFromTimestamp,
}, },
{ {
title: "Active S3 Requests", title: "Node IO",
data: [],
widgetConfiguration: [
{
dataKey: "",
keyLabel: "",
lineColor: "#000",
fillColor: "#000",
},
],
type: widgetType.linearGraph,
layoutIdentifier: "panel-17",
xAxisFormatter: getTimeFromTimestamp,
},
{
title: "Internode Data Transfer",
data: [],
widgetConfiguration: [
{
dataKey: "",
keyLabel: "",
lineColor: "#000",
fillColor: "#000",
},
],
type: widgetType.linearGraph,
layoutIdentifier: "panel-18",
yAxisFormatter: niceBytes,
xAxisFormatter: getTimeFromTimestamp,
},
{
title: "Online Disks",
data: [], data: [],
widgetConfiguration: [ widgetConfiguration: [
{ {
@@ -514,11 +568,25 @@ export const panelsConfiguration: IDashboardPanel[] = [
], ],
type: widgetType.linearGraph, type: widgetType.linearGraph,
layoutIdentifier: "panel-19", layoutIdentifier: "panel-19",
disableYAxis: true, yAxisFormatter: niceBytes,
xAxisFormatter: getTimeFromTimestamp, xAxisFormatter: getTimeFromTimestamp,
}, },
{ {
title: "Disk Usage", title: "Time Since Last Heal Activity",
data: "N/A",
type: widgetType.singleValue,
layoutIdentifier: "panel-20",
labelDisplayFunction: niceDaysFromNS,
},
{
title: "Time Since Last Scan Activity",
data: "N/A",
type: widgetType.singleValue,
layoutIdentifier: "panel-21",
labelDisplayFunction: niceDaysFromNS,
},
{
title: "S3 API Request Error Rate",
data: [], data: [],
widgetConfiguration: [ widgetConfiguration: [
{ {
@@ -529,10 +597,106 @@ export const panelsConfiguration: IDashboardPanel[] = [
}, },
], ],
type: widgetType.linearGraph, type: widgetType.linearGraph,
layoutIdentifier: "panel-20", layoutIdentifier: "panel-22",
yAxisFormatter: niceBytes, disableYAxis: true,
xAxisFormatter: getTimeFromTimestamp, xAxisFormatter: getTimeFromTimestamp,
}, },
{
title: "Node Memory Usage",
data: [],
widgetConfiguration: [
{
dataKey: "",
keyLabel: "",
lineColor: "#000",
fillColor: "#000",
},
],
type: widgetType.linearGraph,
layoutIdentifier: "panel-23",
disableYAxis: true,
xAxisFormatter: getTimeFromTimestamp,
yAxisFormatter: niceBytes,
},
{
title: "Drive Used Capacity",
data: [],
widgetConfiguration: [
{
dataKey: "",
keyLabel: "",
lineColor: "#000",
fillColor: "#000",
},
],
type: widgetType.linearGraph,
layoutIdentifier: "panel-24",
disableYAxis: true,
xAxisFormatter: getTimeFromTimestamp,
yAxisFormatter: niceBytes,
},
{
title: "Drives Free Inodes",
data: [],
widgetConfiguration: [
{
dataKey: "",
keyLabel: "",
lineColor: "#000",
fillColor: "#000",
},
],
type: widgetType.linearGraph,
layoutIdentifier: "panel-25",
disableYAxis: true,
xAxisFormatter: getTimeFromTimestamp,
},
{
title: "Node Syscalls",
data: [],
widgetConfiguration: [
{
dataKey: "",
keyLabel: "",
lineColor: "#000",
fillColor: "#000",
},
],
type: widgetType.linearGraph,
layoutIdentifier: "panel-26",
disableYAxis: true,
xAxisFormatter: getTimeFromTimestamp,
},
{
title: "Node File Descriptors",
data: [],
widgetConfiguration: [
{
dataKey: "",
keyLabel: "",
lineColor: "#000",
fillColor: "#000",
},
],
type: widgetType.linearGraph,
layoutIdentifier: "panel-27",
disableYAxis: true,
xAxisFormatter: getTimeFromTimestamp,
},
{
title: "Total S3 Traffic Inbound",
data: "N/A",
type: widgetType.singleValue,
layoutIdentifier: "panel-28",
labelDisplayFunction: niceBytes,
},
{
title: "Total S3 Traffic Outbound",
data: "N/A",
type: widgetType.singleValue,
layoutIdentifier: "panel-29",
labelDisplayFunction: niceBytes,
},
]; ];
const calculateMainValue = (elements: any[], metricCalc: string) => { const calculateMainValue = (elements: any[], metricCalc: string) => {
@@ -574,7 +738,7 @@ const constructLabelNames = (metrics: any, legendFormat: string) => {
export const getWidgetsWithValue = (payload: any[]) => { export const getWidgetsWithValue = (payload: any[]) => {
return panelsConfiguration.map((panelItem) => { return panelsConfiguration.map((panelItem) => {
const payloadData = payload.find( const payloadData = payload.find(
(panelT) => panelT.title === panelItem.title (panelT) => panelT.title.toLowerCase().trim() === panelItem.title.toLowerCase().trim()
); );
if (!payloadData) { if (!payloadData) {
@@ -853,7 +1017,7 @@ export const saveDashboardDistribution = (configuration: Layout[]) => {
localStorage.setItem(dLocalStorageV, btoa(JSON.stringify(configuration))); localStorage.setItem(dLocalStorageV, btoa(JSON.stringify(configuration)));
}; };
export const getDashboardDistribution = () => { export const getDashboardDistribution = (currentItems: number) => {
const storedConfiguration = localStorage.getItem(dLocalStorageV); const storedConfiguration = localStorage.getItem(dLocalStorageV);
if (!storedConfiguration) { if (!storedConfiguration) {
@@ -869,5 +1033,10 @@ export const getDashboardDistribution = () => {
return defaultWidgetsLayout; return defaultWidgetsLayout;
} }
// Stored Widgets length is not the same as the currentItems, then we return the new configuration
if (currentItems !== 0 && parsedConfig.length !== currentItems) {
return defaultWidgetsLayout;
}
return parsedConfig; return parsedConfig;
}; };

View File

@@ -7464,6 +7464,11 @@ lodash.uniq@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
loglevel@^1.6.8: loglevel@^1.6.8:
version "1.7.1" version "1.7.1"
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.7.1.tgz#005fde2f5e6e47068f935ff28573e125ef72f197" resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.7.1.tgz#005fde2f5e6e47068f935ff28573e125ef72f197"

View File

@@ -93,11 +93,20 @@ type MetricOptions struct {
} }
type Metric struct { type Metric struct {
ID int32 ID int32
Title string Title string
Type string Type string
Options MetricOptions Options MetricOptions
Targets []Target Targets []Target
GridPos GridPos
MaxDataPoints int32
}
type GridPos struct {
H int32
W int32
X int32
Y int32
} }
type WidgetLabel struct { type WidgetLabel struct {
@@ -111,10 +120,16 @@ var labels = []WidgetLabel{
var widgets = []Metric{ var widgets = []Metric{
{ {
ID: 1, ID: 1,
Title: "Uptime", Title: "Uptime",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 6,
W: 3,
X: 0,
Y: 0,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -122,9 +137,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "time() - max(minio_node_process_starttime_seconds)", Expr: "time() - max(minio_node_process_starttime_seconds)",
LegendFormat: "{{instance}}", LegendFormat: "{{instance}}",
@@ -133,10 +146,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 65, ID: 65,
Title: "Total S3 Traffic Inbound", Title: "Total S3 Traffic Inbound",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 3,
W: 3,
X: 3,
Y: 0,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -144,9 +163,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "sum by (instance) (minio_s3_traffic_received_bytes{job=\"minio-job\"})", Expr: "sum by (instance) (minio_s3_traffic_received_bytes{job=\"minio-job\"})",
LegendFormat: "{{instance}}", LegendFormat: "{{instance}}",
@@ -155,10 +172,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 50, ID: 50,
Title: "Current Usable Capacity", Title: "Current Usable Capacity",
Type: "gauge", Type: "gauge",
MaxDataPoints: 100,
GridPos: GridPos{
H: 6,
W: 3,
X: 6,
Y: 0,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -166,9 +189,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "topk(1, sum(minio_cluster_capacity_usable_free_bytes) by (instance))", Expr: "topk(1, sum(minio_cluster_capacity_usable_free_bytes) by (instance))",
LegendFormat: "", LegendFormat: "",
@@ -180,9 +201,13 @@ var widgets = []Metric{
ID: 68, ID: 68,
Title: "Data Usage Growth", Title: "Data Usage Growth",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 6,
W: 7,
X: 9,
Y: 0,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "sum(minio_bucket_usage_total_bytes) by (instance)", Expr: "sum(minio_bucket_usage_total_bytes) by (instance)",
LegendFormat: "Used Capacity", LegendFormat: "Used Capacity",
@@ -193,7 +218,12 @@ var widgets = []Metric{
ID: 52, ID: 52,
Title: "Object size distribution", Title: "Object size distribution",
Type: "bargauge", Type: "bargauge",
GridPos: GridPos{
H: 6,
W: 5,
X: 16,
Y: 0,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -201,9 +231,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "max by (range) (minio_bucket_objects_size_distribution)", Expr: "max by (range) (minio_bucket_objects_size_distribution)",
LegendFormat: "{{range}}", LegendFormat: "{{range}}",
@@ -212,10 +240,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 61, ID: 61,
Title: "Total Open FDs", Title: "Total Open FDs",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 3,
W: 3,
X: 21,
Y: 0,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -223,9 +257,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "sum (minio_node_file_descriptor_open_total)", Expr: "sum (minio_node_file_descriptor_open_total)",
LegendFormat: "", LegendFormat: "",
@@ -234,10 +266,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 64, ID: 64,
Title: "Total S3 Traffic Outbound", Title: "Total S3 Traffic Outbound",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 3,
W: 3,
X: 3,
Y: 3,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -245,9 +283,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "sum by (instance) (minio_s3_traffic_sent_bytes{job=\"minio-job\"})", Expr: "sum by (instance) (minio_s3_traffic_sent_bytes{job=\"minio-job\"})",
LegendFormat: "", LegendFormat: "",
@@ -256,10 +292,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 62, ID: 62,
Title: "Total Goroutines", Title: "Total Goroutines",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 3,
W: 3,
X: 21,
Y: 3,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -267,9 +309,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "sum without (server,instance) (minio_node_go_routine_total)", Expr: "sum without (server,instance) (minio_node_go_routine_total)",
LegendFormat: "", LegendFormat: "",
@@ -278,10 +318,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 53, ID: 53,
Title: "Total Online Servers", Title: "Total Online Servers",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 2,
W: 3,
X: 0,
Y: 6,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -289,9 +335,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "minio_cluster_nodes_online_total", Expr: "minio_cluster_nodes_online_total",
LegendFormat: "", LegendFormat: "",
@@ -300,10 +344,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 9, ID: 9,
Title: "Total Online Disks", Title: "Total Online Disks",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 2,
W: 3,
X: 3,
Y: 6,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -311,9 +361,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "minio_cluster_disk_online_total", Expr: "minio_cluster_disk_online_total",
LegendFormat: "Total online disks in MinIO Cluster", LegendFormat: "Total online disks in MinIO Cluster",
@@ -322,10 +370,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 66, ID: 66,
Title: "Number of Buckets", Title: "Number of Buckets",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 3,
W: 3,
X: 6,
Y: 6,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -333,9 +387,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "count(count by (bucket) (minio_bucket_usage_total_bytes))", Expr: "count(count by (bucket) (minio_bucket_usage_total_bytes))",
LegendFormat: "", LegendFormat: "",
@@ -346,9 +398,13 @@ var widgets = []Metric{
ID: 63, ID: 63,
Title: "S3 API Data Received Rate ", Title: "S3 API Data Received Rate ",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 6,
W: 7,
X: 9,
Y: 6,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "sum by (server) (rate(minio_s3_traffic_received_bytes[$__interval]))", Expr: "sum by (server) (rate(minio_s3_traffic_received_bytes[$__interval]))",
LegendFormat: "Data Received [{{server}}]", LegendFormat: "Data Received [{{server}}]",
@@ -359,9 +415,13 @@ var widgets = []Metric{
ID: 70, ID: 70,
Title: "S3 API Data Sent Rate ", Title: "S3 API Data Sent Rate ",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 6,
W: 8,
X: 16,
Y: 6,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "sum by (server) (rate(minio_s3_traffic_sent_bytes[$__interval]))", Expr: "sum by (server) (rate(minio_s3_traffic_sent_bytes[$__interval]))",
LegendFormat: "Data Sent [{{server}}]", LegendFormat: "Data Sent [{{server}}]",
@@ -369,10 +429,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 69, ID: 69,
Title: "Total Offline Servers", Title: "Total Offline Servers",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 2,
W: 3,
X: 0,
Y: 8,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -380,9 +446,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "minio_cluster_nodes_offline_total", Expr: "minio_cluster_nodes_offline_total",
LegendFormat: "", LegendFormat: "",
@@ -391,10 +455,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 78, ID: 78,
Title: "Total Offline Disks", Title: "Total Offline Disks",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 2,
W: 3,
X: 3,
Y: 8,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -402,9 +472,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "minio_cluster_disk_offline_total", Expr: "minio_cluster_disk_offline_total",
LegendFormat: "", LegendFormat: "",
@@ -413,10 +481,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 44, ID: 44,
Title: "Number of Objects", Title: "Number of Objects",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 3,
W: 3,
X: 6,
Y: 9,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -424,9 +498,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "topk(1, sum(minio_bucket_usage_object_total) by (instance))", Expr: "topk(1, sum(minio_bucket_usage_object_total) by (instance))",
LegendFormat: "", LegendFormat: "",
@@ -434,10 +506,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 80, ID: 80,
Title: "Time Since Last Heal Activity", Title: "Time Since Last Heal Activity",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 2,
W: 3,
X: 0,
Y: 10,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -445,9 +523,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "minio_heal_time_last_activity_nano_seconds", Expr: "minio_heal_time_last_activity_nano_seconds",
LegendFormat: "{{server}}", LegendFormat: "{{server}}",
@@ -456,10 +532,16 @@ var widgets = []Metric{
}, },
}, },
{ {
ID: 81, ID: 81,
Title: "Time Since Last Scan Activity", Title: "Time Since Last Scan Activity",
Type: "stat", Type: "stat",
MaxDataPoints: 100,
GridPos: GridPos{
H: 2,
W: 3,
X: 3,
Y: 10,
},
Options: MetricOptions{ Options: MetricOptions{
ReduceOptions: ReduceOptions{ ReduceOptions: ReduceOptions{
Calcs: []string{ Calcs: []string{
@@ -467,9 +549,7 @@ var widgets = []Metric{
}, },
}, },
}, },
Targets: []Target{ Targets: []Target{
{ {
Expr: "minio_usage_last_activity_nano_seconds", Expr: "minio_usage_last_activity_nano_seconds",
LegendFormat: "{{server}}", LegendFormat: "{{server}}",
@@ -481,9 +561,13 @@ var widgets = []Metric{
ID: 60, ID: 60,
Title: "S3 API Request Rate", Title: "S3 API Request Rate",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 10,
W: 12,
X: 0,
Y: 12,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "sum by (server,api) (rate(minio_s3_requests_total[$__interval]))", Expr: "sum by (server,api) (rate(minio_s3_requests_total[$__interval]))",
LegendFormat: "{{server,api}}", LegendFormat: "{{server,api}}",
@@ -494,9 +578,13 @@ var widgets = []Metric{
ID: 71, ID: 71,
Title: "S3 API Request Error Rate", Title: "S3 API Request Error Rate",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 10,
W: 12,
X: 12,
Y: 12,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "rate(minio_s3_requests_errors_total[$__interval])", Expr: "rate(minio_s3_requests_errors_total[$__interval])",
LegendFormat: "{{server,api}}", LegendFormat: "{{server,api}}",
@@ -507,9 +595,13 @@ var widgets = []Metric{
ID: 17, ID: 17,
Title: "Internode Data Transfer", Title: "Internode Data Transfer",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 8,
W: 24,
X: 0,
Y: 22,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "rate(minio_inter_node_traffic_sent_bytes{job=\"minio-job\"}[$__interval])", Expr: "rate(minio_inter_node_traffic_sent_bytes{job=\"minio-job\"}[$__interval])",
LegendFormat: "Internode Bytes Received [{{server}}]", LegendFormat: "Internode Bytes Received [{{server}}]",
@@ -519,7 +611,6 @@ var widgets = []Metric{
{ {
Expr: "rate(minio_inter_node_traffic_sent_bytes{job=\"minio-job\"}[$__interval])", Expr: "rate(minio_inter_node_traffic_sent_bytes{job=\"minio-job\"}[$__interval])",
LegendFormat: "Internode Bytes Received [{{server}}]", LegendFormat: "Internode Bytes Received [{{server}}]",
Step: 4,
}, },
}, },
}, },
@@ -527,9 +618,13 @@ var widgets = []Metric{
ID: 77, ID: 77,
Title: "Node CPU Usage", Title: "Node CPU Usage",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 9,
W: 12,
X: 0,
Y: 30,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "rate(minio_node_process_cpu_total_seconds[$__interval])", Expr: "rate(minio_node_process_cpu_total_seconds[$__interval])",
LegendFormat: "CPU Usage Rate [{{server}}]", LegendFormat: "CPU Usage Rate [{{server}}]",
@@ -540,9 +635,13 @@ var widgets = []Metric{
ID: 76, ID: 76,
Title: "Node Memory Usage", Title: "Node Memory Usage",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 9,
W: 12,
X: 12,
Y: 30,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "minio_node_process_resident_memory_bytes", Expr: "minio_node_process_resident_memory_bytes",
LegendFormat: "Memory Used [{{server}}]", LegendFormat: "Memory Used [{{server}}]",
@@ -553,9 +652,13 @@ var widgets = []Metric{
ID: 74, ID: 74,
Title: "Drive Used Capacity", Title: "Drive Used Capacity",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 8,
W: 12,
X: 0,
Y: 39,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "minio_node_disk_used_bytes", Expr: "minio_node_disk_used_bytes",
LegendFormat: "Used Capacity [{{server}}:{{disk}}]", LegendFormat: "Used Capacity [{{server}}:{{disk}}]",
@@ -566,9 +669,13 @@ var widgets = []Metric{
ID: 82, ID: 82,
Title: "Drives Free Inodes", Title: "Drives Free Inodes",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 8,
W: 12,
X: 12,
Y: 39,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "minio_cluster_disk_free_inodes", Expr: "minio_cluster_disk_free_inodes",
LegendFormat: "Free Inodes [{{server}}:{{disk}}]", LegendFormat: "Free Inodes [{{server}}:{{disk}}]",
@@ -579,9 +686,13 @@ var widgets = []Metric{
ID: 11, ID: 11,
Title: "Node Syscalls", Title: "Node Syscalls",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 9,
W: 12,
X: 0,
Y: 47,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "rate(minio_node_syscall_read_total[$__interval])", Expr: "rate(minio_node_syscall_read_total[$__interval])",
LegendFormat: "Read Syscalls [{{server}}]", LegendFormat: "Read Syscalls [{{server}}]",
@@ -591,7 +702,6 @@ var widgets = []Metric{
{ {
Expr: "rate(minio_node_syscall_read_total[$__interval])", Expr: "rate(minio_node_syscall_read_total[$__interval])",
LegendFormat: "Read Syscalls [{{server}}]", LegendFormat: "Read Syscalls [{{server}}]",
Step: 60,
}, },
}, },
}, },
@@ -599,9 +709,13 @@ var widgets = []Metric{
ID: 8, ID: 8,
Title: "Node File Descriptors", Title: "Node File Descriptors",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 9,
W: 12,
X: 12,
Y: 47,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "minio_node_file_descriptor_open_total", Expr: "minio_node_file_descriptor_open_total",
LegendFormat: "Open FDs [{{server}}]", LegendFormat: "Open FDs [{{server}}]",
@@ -612,9 +726,13 @@ var widgets = []Metric{
ID: 73, ID: 73,
Title: "Node IO", Title: "Node IO",
Type: "graph", Type: "graph",
GridPos: GridPos{
H: 8,
W: 24,
X: 0,
Y: 56,
},
Targets: []Target{ Targets: []Target{
{ {
Expr: "rate(minio_node_io_rchar_bytes[$__interval])", Expr: "rate(minio_node_io_rchar_bytes[$__interval])",
LegendFormat: "Node RChar [{{server}}]", LegendFormat: "Node RChar [{{server}}]",
@@ -656,6 +774,8 @@ type LabelResults struct {
Response LabelResponse Response LabelResponse
} }
var jobRegex = regexp.MustCompile(`(?m)\{[a-z]+\=\".*?\"\}`)
// getAdminInfoResponse returns the response containing total buckets, objects and usage. // getAdminInfoResponse returns the response containing total buckets, objects and usage.
func getAdminInfoResponse(session *models.Principal, params admin_api.AdminInfoParams) (*models.AdminInfoResponse, *models.Error) { func getAdminInfoResponse(session *models.Principal, params admin_api.AdminInfoParams) (*models.AdminInfoResponse, *models.Error) {
prometheusURL := getPrometheusURL() prometheusURL := getPrometheusURL()
@@ -755,10 +875,15 @@ LabelsWaitLoop:
extraParamters := fmt.Sprintf("&start=%d&end=%d", now.Add(-15*time.Minute).Unix(), now.Unix()) extraParamters := fmt.Sprintf("&start=%d&end=%d", now.Add(-15*time.Minute).Unix(), now.Unix())
var step int32 = 60
if target.Step > 0 { if target.Step > 0 {
extraParamters = fmt.Sprintf("%s&step=%d", extraParamters, target.Step) step = target.Step
} else { }
extraParamters = fmt.Sprintf("%s&step=%d", extraParamters, *params.Step) if params.Step != nil && *params.Step > 0 {
step = *params.Step
}
if step > 0 {
extraParamters = fmt.Sprintf("%s&step=%d", extraParamters, step)
} }
if params.Start != nil && params.End != nil { if params.Start != nil && params.End != nil {
@@ -766,7 +891,7 @@ LabelsWaitLoop:
} }
// replace the `$__interval` global for step with unit (s for seconds) // replace the `$__interval` global for step with unit (s for seconds)
queryExpr := strings.ReplaceAll(target.Expr, "$__interval", fmt.Sprintf("%ds", *params.Step)) queryExpr := strings.ReplaceAll(target.Expr, "$__interval", fmt.Sprintf("%ds", 120))
if strings.Contains(queryExpr, "$") { if strings.Contains(queryExpr, "$") {
var re = regexp.MustCompile(`\$([a-z]+)`) var re = regexp.MustCompile(`\$([a-z]+)`)
@@ -777,7 +902,14 @@ LabelsWaitLoop:
} }
} }
// replace the weird {job="asd"} in the exp
if strings.Contains(queryExpr, "job=") {
queryExpr = jobRegex.ReplaceAllString(queryExpr, "")
}
endpoint := fmt.Sprintf("%s/api/v1/%s?query=%s%s", getPrometheusURL(), apiType, url.QueryEscape(queryExpr), extraParamters) endpoint := fmt.Sprintf("%s/api/v1/%s?query=%s%s", getPrometheusURL(), apiType, url.QueryEscape(queryExpr), extraParamters)
log.Printf("%s \t - %d [%d] - %s\n\n", m.Title, target.Step, params.Step, endpoint)
resp, err := http.Get(endpoint) resp, err := http.Get(endpoint)
if err != nil { if err != nil {
log.Println(err) log.Println(err)

View File

@@ -128,7 +128,7 @@ func init() {
}, },
{ {
"type": "integer", "type": "integer",
"default": 15, "format": "int32",
"name": "step", "name": "step",
"in": "query" "in": "query"
} }
@@ -7002,7 +7002,7 @@ func init() {
}, },
{ {
"type": "integer", "type": "integer",
"default": 15, "format": "int32",
"name": "step", "name": "step",
"in": "query" "in": "query"
} }

View File

@@ -33,18 +33,10 @@ import (
) )
// NewAdminInfoParams creates a new AdminInfoParams object // NewAdminInfoParams creates a new AdminInfoParams object
// with the default values initialized. // no default values defined in spec.
func NewAdminInfoParams() AdminInfoParams { func NewAdminInfoParams() AdminInfoParams {
var ( return AdminInfoParams{}
// initialize parameters with default values
stepDefault = int64(15)
)
return AdminInfoParams{
Step: &stepDefault,
}
} }
// AdminInfoParams contains all the bound params for the admin info operation // AdminInfoParams contains all the bound params for the admin info operation
@@ -66,9 +58,8 @@ type AdminInfoParams struct {
Start *int64 Start *int64
/* /*
In: query In: query
Default: 15
*/ */
Step *int64 Step *int32
} }
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
@@ -157,13 +148,12 @@ func (o *AdminInfoParams) bindStep(rawData []string, hasKey bool, formats strfmt
// Required: false // Required: false
// AllowEmptyValue: false // AllowEmptyValue: false
if raw == "" { // empty values pass all other validations if raw == "" { // empty values pass all other validations
// Default values have been previously initialized by NewAdminInfoParams()
return nil return nil
} }
value, err := swag.ConvertInt64(raw) value, err := swag.ConvertInt32(raw)
if err != nil { if err != nil {
return errors.InvalidType("step", "query", "int64", raw) return errors.InvalidType("step", "query", "int32", raw)
} }
o.Step = &value o.Step = &value

View File

@@ -34,7 +34,7 @@ import (
type AdminInfoURL struct { type AdminInfoURL struct {
End *int64 End *int64
Start *int64 Start *int64
Step *int64 Step *int32
_basePath string _basePath string
// avoid unkeyed usage // avoid unkeyed usage
@@ -88,7 +88,7 @@ func (o *AdminInfoURL) Build() (*url.URL, error) {
var stepQ string var stepQ string
if o.Step != nil { if o.Step != nil {
stepQ = swag.FormatInt64(*o.Step) stepQ = swag.FormatInt32(*o.Step)
} }
if stepQ != "" { if stepQ != "" {
qs.Set("step", stepQ) qs.Set("step", stepQ)

View File

@@ -1758,9 +1758,9 @@ paths:
in: query in: query
type: integer type: integer
- name: step - name: step
default: 15
in: query in: query
type: integer type: integer
format: int32
responses: responses:
200: 200:
description: A successful response. description: A successful response.