Metrics display tune
This commit is contained in:
@@ -531,25 +531,17 @@ def reports_ajax(env, node_name):
|
||||
reports_events = []
|
||||
total = 0
|
||||
|
||||
report_event_counts = {}
|
||||
# Create a map from the metrics data to what the templates
|
||||
# use to express the data.
|
||||
events_metrics = ['success', 'failure', 'noop']
|
||||
resources_metrics = ['total', 'skipped']
|
||||
# Convert metrics to relational dict
|
||||
metrics = {}
|
||||
for report in reports_events:
|
||||
if total is None:
|
||||
total = puppetdb.total
|
||||
|
||||
report_counts = {}
|
||||
for metric in report.metrics:
|
||||
if ('category' in metric and metric['category'] == 'events' and
|
||||
'name' in metric and metric['name'] in events_metrics):
|
||||
report_counts[metric['name']] = metric['value']
|
||||
if ('category' in metric and metric['category'] == 'resources' and
|
||||
'name' in metric and metric['name'] in resources_metrics):
|
||||
report_counts[metric['name']] = metric['value']
|
||||
|
||||
report_event_counts[report.hash_] = report_counts
|
||||
metrics[report.hash_] = {'resources': {}, 'events': {}}
|
||||
for m in report.metrics:
|
||||
if m['category'] not in metrics[report.hash_]:
|
||||
metrics[report.hash_][m['category']] = {}
|
||||
metrics[report.hash_][m['category']][m['name']] = m['value']
|
||||
|
||||
if total is None:
|
||||
total = 0
|
||||
@@ -560,7 +552,7 @@ def reports_ajax(env, node_name):
|
||||
total=total,
|
||||
total_filtered=total,
|
||||
reports=reports,
|
||||
report_event_counts=report_event_counts,
|
||||
metrics=metrics,
|
||||
envs=envs,
|
||||
current_env=env,
|
||||
columns=REPORTS_COLUMNS[:max_col])
|
||||
|
||||
@@ -57,16 +57,16 @@
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro report_status(caller, status, node_name, events, current_env, unreported_time=False, report_hash=False) -%}
|
||||
{% macro report_status(caller, status, node_name, metrics, current_env, unreported_time=False, report_hash=False) -%}
|
||||
<a class="ui {{status}} label status" href="{{url_for('report', env=current_env, node_name=node_name, report_id=report_hash)}}">{{ status|upper }}</a>
|
||||
{% if status == 'unreported' %}
|
||||
<span class="ui label status"> {{ unreported_time|upper }} </span>
|
||||
{% else %}
|
||||
<span title="Total resources" class="ui small count label{% if events['total'] %} total">{{events['total']}}{% else %}">0{% endif%}</span>
|
||||
<span title="Failure events" class="ui small count label{% if events['failure'] %} failed">{{events['failure']}}{% else %}">0{% endif%}</span>
|
||||
<span title="Success events" class="ui small count label{% if events['success'] %} changed">{{events['success']}}{% else %}">0{% endif%}</span>
|
||||
<span title="Skip events" class="ui small count label{% if events['skipped'] %} skipped">{{events['skipped']}}{% else %}">0{% endif%}</span>
|
||||
<span title="Noop resources" class="ui small count label{% if events['noop'] %} noop">{{events['noop']}}{% else %}">0{% endif%}</span>
|
||||
<span title="Total resources" class="ui small count label{% if metrics.resources.total %} total">{{ metrics.resources.total }}{% else %}">0{% endif%}</span>
|
||||
<span title="Failure events" class="ui small count label{% if metrics.events.failure %} failed">{{ metrics.events.failure }}{% else %}">0{% endif%}</span>
|
||||
<span title="Success events" class="ui small count label{% if metrics.events.success %} changed">{{ metrics.events.success }}{% else %}">0{% endif%}</span>
|
||||
<span title="Skipped resources" class="ui small count label{% if metrics.resources.skipped %} skipped">{{ metrics.resources.skipped }}{% else %}">0{% endif%}</span>
|
||||
<span title="Noop events" class="ui small count label{% if metrics.events.noop %} noop">{{ metrics.events.noop }}{% else %}">0{% endif%}</span>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"<span rel=\"utctimestamp\">{{ report[column.attr] }}</span>"
|
||||
{%- elif column.type == 'status' -%}
|
||||
{% filter jsonprint -%}
|
||||
{{ macros.report_status(status=report.status, node_name=report.node, events=report_event_counts[report.hash_], report_hash=report.hash_, current_env=current_env) }}
|
||||
{{ macros.report_status(status=report.status, node_name=report.node, metrics=metrics[report.hash_], report_hash=report.hash_, current_env=current_env) }}
|
||||
{%- endfilter %}
|
||||
{%- elif column.type == 'node' -%}
|
||||
{% filter jsonprint %}<a href="{{url_for('node', env=current_env, node_name=report.node)}}">{{ report.node }}</a>{% endfilter %}
|
||||
|
||||
Reference in New Issue
Block a user