1
0
mirror of https://github.com/TwiN/gatus.git synced 2026-02-07 08:55:37 +00:00

feat: add support for 1h response chart

This commit is contained in:
Tore Stendal Lønøy
2025-02-05 13:46:00 +01:00
parent ebda6c2c08
commit 4e3241f78c
3 changed files with 9 additions and 2 deletions

View File

@@ -42,8 +42,10 @@ func ResponseTimeChart(c *fiber.Ctx) error {
from = time.Now().Truncate(time.Hour).Add(-7 * 24 * time.Hour)
case "24h":
from = time.Now().Truncate(time.Hour).Add(-24 * time.Hour)
case "1h":
from = time.Now().Add(-2 * time.Hour) // Because response time metrics are stored by hour, we have to cheat a little
default:
return c.Status(400).SendString("Durations supported: 30d, 7d, 24h")
return c.Status(400).SendString("Durations supported: 30d, 7d, 24h, 1h")
}
hourlyAverageResponseTime, err := store.Get().GetHourlyAverageResponseTimeByKey(c.Params("key"), from, time.Now())
if err != nil {

View File

@@ -39,6 +39,11 @@ func TestResponseTimeChart(t *testing.T) {
Gzip bool
}
scenarios := []Scenario{
{
Name: "chart-response-time-1h",
Path: "/api/v1/endpoints/core_backend/response-times/1h/chart.svg",
ExpectedCode: http.StatusOK,
},
{
Name: "chart-response-time-24h",
Path: "/api/v1/endpoints/core_backend/response-times/24h/chart.svg",

View File

@@ -41,7 +41,7 @@
<div v-if="endpointStatus && endpointStatus.key && showResponseTimeChartAndBadges" class="mt-12">
<div class="flex items-center justify-between">
<h1 class="text-xl xl:text-3xl font-mono text-gray-400">RESPONSE TIME</h1>
<select v-model="selectedChartDuration" class="text-sm bg-gray-400 text-white border border-gray-600 rounded-md px-3 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="1h">1 hour</option>
<option value="24h">24 hours</option>
<option value="7d">7 days</option>
<option value="30d">30 days</option>