Commit 1d65c683 authored by Daniele Venzano's avatar Daniele Venzano

Add a link to plots in grafana (Eurecom specific)

parent f4e74272
# Copyright (c) 2015, Daniele Venzano
# Copyright (c) 2017, Daniele Venzano
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......@@ -15,7 +15,11 @@
"""Web pages and functions related to executions."""
import datetime
import json
import time
from zoe_lib.config import get_conf
import zoe_api.exceptions
from zoe_api.web.utils import get_auth, catch_exceptions
......@@ -138,6 +142,16 @@ class ExecutionInspectWeb(ZoeRequestHandler):
"services_info": services_info,
"endpoints": endpoints,
}
if get_conf().enable_plots:
grafana_url_template = 'http://bigfoot-m2.eurecom.fr/grafana/dashboard/db/zoe-executions?orgId=1&from={}&to={}&var-execution_id={}&refresh=1y'
if e.time_end is None:
e_time_end = int(time.time() * 1000)
else:
e_time_end = int((e.time_end - datetime.datetime(1970, 1, 1)) / datetime.timedelta(seconds=1) * 1000)
e_time_start = int((e.time_start - datetime.datetime(1970, 1, 1)) / datetime.timedelta(seconds=1) * 1000)
template_vars['grafana_url'] = grafana_url_template.format(e_time_start, e_time_end, execution_id)
self.render('execution_inspect.html', **template_vars)
......
......@@ -45,6 +45,11 @@
<a href="/executions/restart/{{ e.id }}">Restart</a>
</li>
{% endif %}
{% if grafana_url is defined %}
<li>
<a href="{{ grafana_url }}">Resource usage plots</a>
</li>
{% endif %}
</ul>
{% if e.status == 'error' %}
<p>Error message: <code>{{ e.error_message }}</code></p>
......
......@@ -124,6 +124,7 @@ def load_configuration(test_conf=None):
argparser.add_argument('--max-memory-limit', help='Maximum amount of memory services can use (in GiB)', type=int, default=64)
argparser.add_argument('--no-user-edit-limits-web', action='store_true', help='Disable editing ZApp resource limits from the web interface (only admins will able to)')
argparser.add_argument('--additional-volumes', help='Additional volumes to mount in services filesystems. (ex: /mnt/data:data,/mnt/data_n:data_n)', default='')
argparser.add_argument('--enable-plots', action='store_true', help='Enable generation of URLs to Grafana')
opts = argparser.parse_args()
if opts.debug:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment