diff --git a/ansible/roles/forgejo_metrics/templates/forgejo-metrics.sh.j2 b/ansible/roles/forgejo_metrics/templates/forgejo-metrics.sh.j2 index 0afb488..365b62b 100644 --- a/ansible/roles/forgejo_metrics/templates/forgejo-metrics.sh.j2 +++ b/ansible/roles/forgejo_metrics/templates/forgejo-metrics.sh.j2 @@ -18,7 +18,8 @@ api() { } # jq helper: convert ISO 8601 timestamp (with any tz offset) to epoch seconds -JQ_EPOCH='def epoch: sub("[.][0-9]+"; "") | sub("[+-][0-9][0-9]:[0-9][0-9]$"; "Z") | sub("ZZ$"; "Z") | fromdate;' +# jq's fromdate only handles Z, so we parse the offset and apply it manually +JQ_EPOCH='def epoch: sub("[.][0-9]+"; "") | if test("[+-][0-9]{2}:[0-9]{2}$") then capture("^(?
.*)(?[+-])(?[0-9]{2}):(?[0-9]{2})$") | (.dt + "Z" | fromdate) as $base | ((.h | tonumber) * 3600 + (.m | tonumber) * 60) as $off | if .sign == "-" then $base + $off else $base - $off end else sub("Z$"; "") + "Z" | fromdate end;' forgejo_up=0 if curl -sf "${FORGEJO_URL}/api/v1/version" >/dev/null 2>&1; then