ops: glance borg-widget fix - alter via promql berechnen statt now.Unix im template

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 19:05:48 +02:00
parent ca81b959cc
commit 3474d53ce5
+3 -4
View File
@@ -459,20 +459,19 @@
title: Borg Backup title: Borg Backup
title-url: https://borg.kaleschke.info title-url: https://borg.kaleschke.info
cache: 15m cache: 15m
url: http://monitoring-prometheus:9090/api/v1/query?query=homelab_borg_last_completed_timestamp_seconds url: http://monitoring-prometheus:9090/api/v1/query?query=(time()-homelab_borg_last_completed_timestamp_seconds)/3600
subrequests: subrequests:
success: success:
url: http://monitoring-prometheus:9090/api/v1/query?query=homelab_borg_last_success url: http://monitoring-prometheus:9090/api/v1/query?query=homelab_borg_last_success
template: | template: |
{{ $ts := .JSON.Float "data.result.0.value.1" }} {{ $ageHours := .JSON.Float "data.result.0.value.1" }}
{{ $archive := .JSON.String "data.result.0.metric.archive" }} {{ $archive := .JSON.String "data.result.0.metric.archive" }}
{{ $succ := .Subrequest "success" }} {{ $succ := .Subrequest "success" }}
{{ $ok := $succ.JSON.Float "data.result.0.value.1" }} {{ $ok := $succ.JSON.Float "data.result.0.value.1" }}
{{ $status := $succ.JSON.String "data.result.0.metric.status" }} {{ $status := $succ.JSON.String "data.result.0.metric.status" }}
{{ if eq $ts 0.0 }} {{ if eq (len (.JSON.Array "data.result")) 0 }}
<div class="text-center color-subdue">Keine Backup-Metrik gefunden</div> <div class="text-center color-subdue">Keine Backup-Metrik gefunden</div>
{{ else }} {{ else }}
{{ $ageHours := div (sub (toFloat now.Unix) $ts) 3600.0 }}
<div class="text-center"> <div class="text-center">
<div class="size-h2 {{ if gt $ageHours 30.0 }}color-negative{{ else }}color-positive{{ end }}">vor {{ printf "%.0f" $ageHours }} h</div> <div class="size-h2 {{ if gt $ageHours 30.0 }}color-negative{{ else }}color-positive{{ end }}">vor {{ printf "%.0f" $ageHours }} h</div>
<div class="size-h6 color-subdue" style="margin-top: 4px;">letztes abgeschlossenes Backup</div> <div class="size-h6 color-subdue" style="margin-top: 4px;">letztes abgeschlossenes Backup</div>