2024-07-25 17:10:00 +02:00
|
|
|
<!--
|
|
|
|
@component Metric plot wrapper with user scope selection; used in job detail view
|
|
|
|
|
|
|
|
Properties:
|
|
|
|
- `job Object`: The GQL job object
|
|
|
|
- `metricName String`: The metrics name
|
|
|
|
- `metricUnit Object`: The metrics GQL unit object
|
|
|
|
- `nativeScope String`: The metrics native scope
|
|
|
|
- `scopes [String]`: The scopes returned for this metric
|
|
|
|
- `width Number`: Nested plot width
|
|
|
|
- `rawData [Object]`: Metric data for all scopes returned for this metric
|
|
|
|
- `isShared Bool?`: If this job used shared resources; will adapt threshold indicators accordingly in downstream plots [Default: false]
|
|
|
|
-->
|
|
|
|
|
2022-06-22 11:20:57 +02:00
|
|
|
<script>
|
2024-08-16 14:50:31 +02:00
|
|
|
import {
|
|
|
|
queryStore,
|
|
|
|
gql,
|
|
|
|
getContextClient
|
|
|
|
} from "@urql/svelte";
|
|
|
|
// import { createEventDispatcher } from "svelte";
|
2024-03-09 10:30:40 +01:00
|
|
|
import {
|
|
|
|
InputGroup,
|
|
|
|
InputGroupText,
|
|
|
|
Spinner,
|
|
|
|
Card,
|
|
|
|
} from "@sveltestrap/sveltestrap";
|
2024-08-16 16:35:17 +02:00
|
|
|
import { minScope } from "../generic/utils.js";
|
2024-07-26 12:34:18 +02:00
|
|
|
import Timeseries from "../generic/plots/MetricPlot.svelte";
|
2022-06-22 11:20:57 +02:00
|
|
|
|
2024-03-09 10:30:40 +01:00
|
|
|
export let job;
|
|
|
|
export let metricName;
|
2024-07-22 15:41:33 +02:00
|
|
|
export let metricUnit;
|
|
|
|
export let nativeScope;
|
2024-03-09 10:30:40 +01:00
|
|
|
export let scopes;
|
|
|
|
export let width;
|
|
|
|
export let rawData;
|
|
|
|
export let isShared = false;
|
2022-06-22 11:20:57 +02:00
|
|
|
|
2024-03-09 10:30:40 +01:00
|
|
|
let selectedHost = null,
|
|
|
|
plot,
|
|
|
|
error = null;
|
|
|
|
let selectedScope = minScope(scopes);
|
2024-08-16 14:50:31 +02:00
|
|
|
let selectedResolution = 600
|
2024-05-08 16:17:42 +02:00
|
|
|
let statsPattern = /(.*)-stat$/
|
2024-05-02 16:32:01 +02:00
|
|
|
let statsSeries = rawData.map((data) => data?.statisticsSeries ? data.statisticsSeries : null)
|
|
|
|
let selectedScopeIndex
|
|
|
|
|
2024-08-16 14:50:31 +02:00
|
|
|
// const dispatch = createEventDispatcher();
|
|
|
|
const unit = (metricUnit?.prefix ? metricUnit.prefix : "") + (metricUnit?.base ? metricUnit.base : "")
|
|
|
|
const resolutions = [600, 240, 60]
|
|
|
|
const client = getContextClient();
|
|
|
|
const subQuery = gql`
|
|
|
|
query ($dbid: ID!, $selectedMetrics: [String!]!, $selectedScopes: [MetricScope!]!, $selectedResolution: Int) {
|
|
|
|
singleUpdate: jobMetrics(id: $dbid, metrics: $selectedMetrics, scopes: $selectedScopes, resolution: $selectedResolution) {
|
|
|
|
name
|
|
|
|
scope
|
|
|
|
metric {
|
|
|
|
unit {
|
|
|
|
prefix
|
|
|
|
base
|
|
|
|
}
|
|
|
|
timestep
|
|
|
|
statisticsSeries {
|
|
|
|
min
|
|
|
|
median
|
|
|
|
max
|
|
|
|
}
|
|
|
|
series {
|
|
|
|
hostname
|
|
|
|
id
|
|
|
|
data
|
|
|
|
statistics {
|
|
|
|
min
|
|
|
|
avg
|
|
|
|
max
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
let metricData;
|
|
|
|
let selectedScopes = [...scopes]
|
|
|
|
const dbid = job.id;
|
|
|
|
const selectedMetrics = [metricName]
|
|
|
|
|
|
|
|
function loadUpdate() {
|
2024-08-16 16:35:17 +02:00
|
|
|
console.log('S> OLD DATA:', rawData)
|
2024-08-16 14:50:31 +02:00
|
|
|
metricData = queryStore({
|
|
|
|
client: client,
|
|
|
|
query: subQuery,
|
|
|
|
variables: { dbid, selectedMetrics, selectedScopes, selectedResolution },
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
$: if (selectedScope == "load-all") {
|
|
|
|
scopes = [...scopes, "socket", "core"]
|
|
|
|
selectedScope = nativeScope
|
|
|
|
selectedScopes = [...scopes]
|
|
|
|
loadUpdate()
|
|
|
|
};
|
2024-08-08 12:28:36 +02:00
|
|
|
|
2024-05-02 16:32:01 +02:00
|
|
|
$: patternMatches = statsPattern.exec(selectedScope)
|
|
|
|
$: if (!patternMatches) {
|
|
|
|
selectedScopeIndex = scopes.findIndex((s) => s == selectedScope);
|
|
|
|
} else {
|
|
|
|
selectedScopeIndex = scopes.findIndex((s) => s == patternMatches[1]);
|
|
|
|
}
|
2024-03-09 10:30:40 +01:00
|
|
|
$: data = rawData[selectedScopeIndex];
|
|
|
|
$: series = data?.series.filter(
|
|
|
|
(series) => selectedHost == null || series.hostname == selectedHost,
|
|
|
|
);
|
|
|
|
|
2024-08-16 16:35:17 +02:00
|
|
|
$: if ($metricData && !$metricData.fetching) {
|
|
|
|
rawData = $metricData.data.singleUpdate.map((x) => x.metric)
|
|
|
|
console.log('S> NEW DATA:', rawData)
|
|
|
|
}
|
2024-08-16 14:50:31 +02:00
|
|
|
$: console.log('SelectedScope', selectedScope)
|
2022-06-22 11:20:57 +02:00
|
|
|
</script>
|
2024-03-09 10:30:40 +01:00
|
|
|
|
2022-06-22 11:20:57 +02:00
|
|
|
<InputGroup>
|
2024-03-09 10:30:40 +01:00
|
|
|
<InputGroupText style="min-width: 150px;">
|
2024-07-22 15:41:33 +02:00
|
|
|
{metricName} ({unit})
|
2024-03-09 10:30:40 +01:00
|
|
|
</InputGroupText>
|
|
|
|
<select class="form-select" bind:value={selectedScope}>
|
2024-08-16 14:50:31 +02:00
|
|
|
{#each scopes as scope, index}
|
2024-03-09 10:30:40 +01:00
|
|
|
<option value={scope}>{scope}</option>
|
2024-05-02 16:32:01 +02:00
|
|
|
{#if statsSeries[index]}
|
2024-05-08 16:17:42 +02:00
|
|
|
<option value={scope + '-stat'}>stats series ({scope})</option>
|
2024-05-02 16:32:01 +02:00
|
|
|
{/if}
|
2024-03-09 10:30:40 +01:00
|
|
|
{/each}
|
2024-08-16 14:50:31 +02:00
|
|
|
{#if scopes.length == 1 && nativeScope != "node"}
|
2024-07-22 15:41:33 +02:00
|
|
|
<option value={"load-all"}>Load all...</option>
|
2022-06-22 11:20:57 +02:00
|
|
|
{/if}
|
2024-03-09 10:30:40 +01:00
|
|
|
</select>
|
|
|
|
{#if job.resources.length > 1}
|
2024-05-02 16:32:01 +02:00
|
|
|
<select class="form-select" bind:value={selectedHost} disabled={patternMatches}>
|
2024-03-09 10:30:40 +01:00
|
|
|
<option value={null}>All Hosts</option>
|
|
|
|
{#each job.resources as { hostname }}
|
|
|
|
<option value={hostname}>{hostname}</option>
|
|
|
|
{/each}
|
|
|
|
</select>
|
|
|
|
{/if}
|
2024-08-16 14:50:31 +02:00
|
|
|
<select class="form-select" bind:value={selectedResolution} on:change={() => {
|
|
|
|
scopes = ["node"]
|
|
|
|
selectedScope = "node"
|
|
|
|
selectedScopes = [...scopes]
|
2024-08-16 16:35:17 +02:00
|
|
|
loadUpdate()
|
2024-08-16 14:50:31 +02:00
|
|
|
}}>
|
2024-08-08 12:28:36 +02:00
|
|
|
{#each resolutions as res}
|
|
|
|
<option value={res}>Timestep: {res}</option>
|
|
|
|
{/each}
|
|
|
|
</select>
|
2022-06-22 11:20:57 +02:00
|
|
|
</InputGroup>
|
|
|
|
{#key series}
|
2024-08-16 14:50:31 +02:00
|
|
|
{#if $metricData?.fetching == true}
|
2024-03-09 10:30:40 +01:00
|
|
|
<Spinner />
|
|
|
|
{:else if error != null}
|
|
|
|
<Card body color="danger">{error.message}</Card>
|
2024-05-02 16:32:01 +02:00
|
|
|
{:else if series != null && !patternMatches}
|
|
|
|
<Timeseries
|
|
|
|
bind:this={plot}
|
|
|
|
{width}
|
|
|
|
height={300}
|
2024-07-22 15:41:33 +02:00
|
|
|
cluster={job.cluster}
|
|
|
|
subCluster={job.subCluster}
|
2024-05-02 16:32:01 +02:00
|
|
|
timestep={data.timestep}
|
|
|
|
scope={selectedScope}
|
|
|
|
metric={metricName}
|
|
|
|
{series}
|
|
|
|
{isShared}
|
|
|
|
resources={job.resources}
|
|
|
|
/>
|
|
|
|
{:else if statsSeries[selectedScopeIndex] != null && patternMatches}
|
2024-03-09 10:30:40 +01:00
|
|
|
<Timeseries
|
|
|
|
bind:this={plot}
|
|
|
|
{width}
|
|
|
|
height={300}
|
2024-07-22 15:41:33 +02:00
|
|
|
cluster={job.cluster}
|
|
|
|
subCluster={job.subCluster}
|
2024-03-09 10:30:40 +01:00
|
|
|
timestep={data.timestep}
|
|
|
|
scope={selectedScope}
|
|
|
|
metric={metricName}
|
|
|
|
{series}
|
|
|
|
{isShared}
|
|
|
|
resources={job.resources}
|
2024-05-02 16:32:01 +02:00
|
|
|
statisticsSeries={statsSeries[selectedScopeIndex]}
|
|
|
|
useStatsSeries={!!statsSeries[selectedScopeIndex]}
|
2024-03-09 10:30:40 +01:00
|
|
|
/>
|
|
|
|
{/if}
|
2022-06-22 11:20:57 +02:00
|
|
|
{/key}
|