Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new metric on CPU usage to detect burst usage #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion jobstats/templates/jobstats/job.html
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,15 @@ <h2>{% translate "Resources" %}</h2>
<td></td>
</tr>
<tr>
<td>{% translate "CPU cores" %}</td>
<td>{% translate "CPU cores (mean)" %}</td>
<td>{{tres_req.total_cores}}</td>
<td>{{cpu_used | floatformat:-2}}</td>
</tr>
<tr>
<td>{% translate "CPU cores (90th percentile)" %}</td>
<td>{{tres_req.total_cores}}</td>
<td>{{cpu_used_p90 | floatformat:-2}}</td>
</tr>
<tr>
<td>{% translate "CPU cores by node" %}</td>
<td>
Expand Down
8 changes: 7 additions & 1 deletion jobstats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ def user(request, username):
query_cpu = 'sum(rate(slurm_job_core_usage_total{{user="{}", {}}}[{}s]) / 1000000000)'.format(username, prom.get_filter(), prom.rate('slurm-job-exporter'))
stats_cpu = prom.query_prometheus(query_cpu, now - delta, now)
context['cpu_used'] = statistics.mean(stats_cpu[1])
context["cpu_used_p90"] = statistics.quantiles(stats_cpu[1], n=10, method="inclusive")[-1]
except ValueError:
context['cpu_used'] = 'N/A'
context["cpu_used_p90"] = 'N/A'

try:
query_mem = 'sum(slurm_job_memory_max{{user="{}", {}}})'.format(username, prom.get_filter())
Expand Down Expand Up @@ -359,8 +361,10 @@ def job(request, username, job_id):
query_cpu = 'sum(rate(slurm_job_core_usage_total{{slurmjobid="{}", {}}}[{}s]) / 1000000000)'.format(job_id, prom.get_filter(), prom.rate('slurm-job-exporter'))
stats_cpu = prom.query_prometheus(query_cpu, job.time_start_dt(), job.time_end_dt())
context['cpu_used'] = statistics.mean(stats_cpu[1])
context['cpu_used_p90'] = statistics.quantiles(stats_cpu[1], n=10, method="inclusive")[-1]
except ValueError:
context['cpu_used'] = None
context['cpu_used_p90'] = None

try:
query_cpu_bynode = 'count(slurm_job_core_usage_total{{slurmjobid="{}", {}}}) by ({})'.format(job_id, prom.get_filter(), settings.PROM_NODE_HOSTNAME_LABEL)
Expand Down Expand Up @@ -424,7 +428,9 @@ def job(request, username, job_id):
'https://docs.alliancecan.ca/wiki/Running_jobs#Serial_job',
graph_ids=['cpu'])]

if (context['tres_req']['total_cores'] / 2) > context['cpu_used']:
if (context['tres_req']['total_cores'] / 2) > context['cpu_used'] and (
context["tres_req"]["total_cores"] * 0.75 > context["cpu_used_p90"]
):
comments += [Comment(
_('Less than half the CPU compute cycle were used').format(context['tres_req']['total_cores']),
'critical',
Expand Down