Skip to content

Commit

Permalink
Jobstats: Handle missing exe from metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
guilbaults committed Jul 17, 2024
1 parent eef8fba commit 888cf02
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions jobstats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,15 @@ def job(request, username, job_id):
stats_exe = prom.query_prometheus_multiple(query_exe, job.time_start_dt(), job.time_end_dt())
context['applications'] = []
for exe in stats_exe:
name = exe['metric']['exe']
value = statistics.mean(exe['y'])
if settings.DEMO:
if not name.startswith('/cvmfs'):
# skip non-cvmfs applications in demo mode
name = '[redacted]'
context['applications'].append({'name': name, 'value': value})
# sometimes the exe is not present, skip those
if 'exe' in exe['metric']:
name = exe['metric']['exe']
value = statistics.mean(exe['y'])
if settings.DEMO:
if not name.startswith('/cvmfs'):
# skip non-cvmfs applications in demo mode
name = '[redacted]'
context['applications'].append({'name': name, 'value': value})
except ValueError:
pass

Expand Down Expand Up @@ -836,14 +838,16 @@ def graph_thread(request, username, job_id):
for line in stats_exe:
x = list(map(lambda x: x.strftime('%Y-%m-%d %H:%M:%S'), line['x']))
y = line['y']
name = os.path.basename(line['metric']['exe'])
data.append({
'x': x,
'y': y,
'type': 'scatter',
'name': name,
'hovertemplate': '%{y:.1f}',
})
# sometimes the exe is not present, skip those
if 'exe' in line['metric']:
name = os.path.basename(line['metric']['exe'])
data.append({
'x': x,
'y': y,
'type': 'scatter',
'name': name,
'hovertemplate': '%{y:.1f}',
})

layout = {
'yaxis': {
Expand Down

0 comments on commit 888cf02

Please sign in to comment.