feature/added the lastEndpoint info on metric page - added the to_date to get_metric_last_endpoint

This commit is contained in:
Hongwei 2023-12-06 12:15:37 +01:00
parent e31d48dbe7
commit 5e3b073cde
3 changed files with 5 additions and 6 deletions

View File

@ -6,12 +6,10 @@ function getMetricLastEndpoint(){
$.ajax({url: "/metrics/api/last-endpoint", success: function(result){
var content = ""
+result['implemented_by_partial_function']+" took "
+result['duration']+"ms at "
+result['duration']+" ms at "
+result['date']+" "
+result['verb']+" "
+ result['url']
+" ms.";
+ result['url'];
$("#last_endpoint").text(content);
setTimeout(function(){getMetricLastEndpoint();}, 5000); // will call function to update time every 5 seconds
}});

View File

@ -14,7 +14,7 @@
{{ form.media }} {# Form required JS and CSS #}
{% endblock %}
<h1>{% trans "API Metrics" %}</h1>
<h5 id ="last_endpoint">getBanks took 43ms at 2023-12-06T11:00:49Z GET /obp/v4.0.0/banks ms. </h5>
<p id ="last_endpoint">getBanks took 43ms at 2023-12-06T11:00:49Z GET /obp/v4.0.0/banks ms. </p>
<div id="metrics-filter">
<h2>{% trans "Filter" %}</h2>
<form action="" method="get">

View File

@ -203,7 +203,8 @@ class APIMetricsView(MetricsView):
return context
def get_metric_last_endpoint(request):
urlpath = "/management/metrics?limit=1"
to_date = datetime.datetime.now().strftime(settings.API_DATE_FORMAT_WITH_MILLISECONDS)
urlpath = "/management/metrics?limit=1&to_date="+to_date
api = API(request.session.get('obp'))
last_endpoint_metric={}
try: