mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-02-04 15:25:17 +01:00
initial prototyping
This commit is contained in:
parent
42e8e37bd4
commit
817076bdbf
@ -450,12 +450,15 @@ func (r *JobRepository) AddHistograms(
|
|||||||
) (*model.JobsStatistics, error) {
|
) (*model.JobsStatistics, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
binSeconds := 900
|
||||||
|
binMinutes := binSeconds / 60
|
||||||
castType := r.getCastType()
|
castType := r.getCastType()
|
||||||
var err error
|
var err error
|
||||||
value := fmt.Sprintf(`CAST(ROUND((CASE WHEN job.job_state = "running" THEN %d - job.start_time ELSE job.duration END) / 3600) as %s) as value`, time.Now().Unix(), castType)
|
// Bin by job duration in sizes of binSeconds, add +1, gives Integers from 1-XX+1, re-multiply by binMinutes to get final bar x-values (logic: Jobs less than duration X in bin)
|
||||||
|
value := fmt.Sprintf(`CAST((ROUND(((CASE WHEN job.job_state = "running" THEN %d - job.start_time ELSE job.duration END) / %d) + 1) * %d) as %s) as value`, time.Now().Unix(), binSeconds, binMinutes, castType)
|
||||||
stat.HistDuration, err = r.jobsStatisticsHistogram(ctx, value, filter)
|
stat.HistDuration, err = r.jobsStatisticsHistogram(ctx, value, filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("Error while loading job statistics histogram: running jobs")
|
log.Warn("Error while loading job statistics histogram: job duration")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,9 +213,10 @@
|
|||||||
<Col class="px-1">
|
<Col class="px-1">
|
||||||
{#key $stats.data.jobsStatistics[0].histDuration}
|
{#key $stats.data.jobsStatistics[0].histDuration}
|
||||||
<Histogram
|
<Histogram
|
||||||
data={convert2uplot($stats.data.jobsStatistics[0].histDuration)}
|
data={convert2uplot($stats.data.jobsStatistics[0].histDuration, true)}
|
||||||
title="Duration Distribution"
|
title="Duration Distribution"
|
||||||
xlabel="Current Runtimes"
|
xlabel="Current Runtimes (Hours)"
|
||||||
|
xtime={true}
|
||||||
xunit="Hours"
|
xunit="Hours"
|
||||||
ylabel="Number of Jobs"
|
ylabel="Number of Jobs"
|
||||||
yunit="Jobs"
|
yunit="Jobs"
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
export let height = 250;
|
export let height = 250;
|
||||||
export let title = "";
|
export let title = "";
|
||||||
export let xlabel = "";
|
export let xlabel = "";
|
||||||
|
export let xtime = false;
|
||||||
export let xunit = "";
|
export let xunit = "";
|
||||||
export let ylabel = "";
|
export let ylabel = "";
|
||||||
export let yunit = "";
|
export let yunit = "";
|
||||||
@ -139,7 +140,7 @@
|
|||||||
label: xlabel,
|
label: xlabel,
|
||||||
labelGap: 10,
|
labelGap: 10,
|
||||||
size: 25,
|
size: 25,
|
||||||
incrs: [1, 2, 5, 6, 10, 12, 50, 100, 500, 1000, 5000, 10000],
|
incrs: xtime ? [0.25, 0.5, 1, 2, 4, 8, 15, 30, 60, 90, 120, 180, 240] : [1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 5000, 10000],
|
||||||
border: {
|
border: {
|
||||||
show: true,
|
show: true,
|
||||||
stroke: "#000000",
|
stroke: "#000000",
|
||||||
@ -149,7 +150,10 @@
|
|||||||
size: 5 / devicePixelRatio,
|
size: 5 / devicePixelRatio,
|
||||||
stroke: "#000000",
|
stroke: "#000000",
|
||||||
},
|
},
|
||||||
values: (_, t) => t.map((v) => formatNumber(v)),
|
values: (_, t) => t.map((v) => {
|
||||||
|
if (!usesBins) console.log("X Scale Val", xlabel, v)
|
||||||
|
return formatNumber(v)
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stroke: "#000000",
|
stroke: "#000000",
|
||||||
@ -166,7 +170,10 @@
|
|||||||
size: 5 / devicePixelRatio,
|
size: 5 / devicePixelRatio,
|
||||||
stroke: "#000000",
|
stroke: "#000000",
|
||||||
},
|
},
|
||||||
values: (_, t) => t.map((v) => formatNumber(v)),
|
values: (_, t) => t.map((v) => {
|
||||||
|
if (!usesBins) console.log("Y Scale Val", ylabel, v)
|
||||||
|
return formatNumber(v)
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
series: [
|
series: [
|
||||||
|
@ -405,7 +405,7 @@ function getMetricConfigDeep(metric, cluster, subCluster) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function convert2uplot(canvasData) {
|
export function convert2uplot(canvasData, minutesToHours = false) {
|
||||||
// Prep: Uplot Data Structure
|
// Prep: Uplot Data Structure
|
||||||
let uplotData = [[],[]] // [X, Y1, Y2, ...]
|
let uplotData = [[],[]] // [X, Y1, Y2, ...]
|
||||||
// Iterate if exists
|
// Iterate if exists
|
||||||
@ -415,9 +415,15 @@ export function convert2uplot(canvasData) {
|
|||||||
uplotData[0].push(cd?.max ? cd.max : 0)
|
uplotData[0].push(cd?.max ? cd.max : 0)
|
||||||
uplotData[1].push(cd.count)
|
uplotData[1].push(cd.count)
|
||||||
} else { // Default
|
} else { // Default
|
||||||
uplotData[0].push(cd.value)
|
if (minutesToHours) {
|
||||||
|
let hours = cd.value / 60
|
||||||
|
console.log("x minutes to y hours", cd.value, hours)
|
||||||
|
uplotData[0].push(hours)
|
||||||
|
} else {
|
||||||
|
uplotData[0].push(cd.value)
|
||||||
|
}
|
||||||
uplotData[1].push(cd.count)
|
uplotData[1].push(cd.count)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return uplotData
|
return uplotData
|
||||||
|
Loading…
Reference in New Issue
Block a user