feat: Prometheus monitors in console and API

Closes #25

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 11:49:07 +01:00
1 parent 5e7db9c054
commit 94b519b421
8 files changed
+919 -580

No files matched your search

+8
View File
@@ -7,6 +7,7 @@ import (
"fmt"
"net/http"
"slices"
"strconv"
"strings"
"time"
@@ -476,6 +477,7 @@ func (s *Server) monitorEditor(c *gin.Context, p *principal, page web.Page, me w
Type: "http", IntervalSeconds: 60, TimeoutMS: 10000, Confirmations: 2, Enabled: true,
MinInterval: s.minInterval(), Method: "GET", ExpectStatus: "2xx, 3xx", GraceSeconds: check.DefaultHeartbeatGrace,
JSONExpect: "2xx", JSONVerify: true, Assertions: assertionRows(nil),
PromOp: ">=", PromThreshold: "1", PromMode: "all", PromVerify: true,
FollowRedirects: true, VerifyTLS: true, DNSRecord: "A", TLSMinDays: 14,
}
var (
@@ -543,6 +545,7 @@ func fillForm(f *web.MonitorForm, m store.Monitor) {
}
// Defaults for the other types, in case the type is switched.
f.JSONExpect, f.JSONVerify, f.Assertions, f.GraceSeconds = "2xx", true, assertionRows(nil), check.DefaultHeartbeatGrace
f.PromOp, f.PromThreshold, f.PromMode, f.PromVerify = ">=", "1", "all", true
switch check.Type(m.Type) {
case check.HTTP:
var c check.HTTPConfig
@@ -564,6 +567,11 @@ func fillForm(f *web.MonitorForm, m store.Monitor) {
var c check.TLSConfig
_ = json.Unmarshal(m.Config, &c)
f.TLSMinDays, f.TLSServerName = c.MinDaysValid, c.ServerName
case check.Prometheus:
var c check.PrometheusConfig
_ = json.Unmarshal(m.Config, &c)
f.PromQuery, f.PromOp, f.PromThreshold, f.PromMode = c.Query, c.Op, strconv.FormatFloat(c.Threshold, 'g', -1, 64), c.Mode
f.PromEmptyOK, f.PromVerify, f.Headers = c.EmptyOK, c.VerifyTLS, headerLines(c.Headers)
case check.Heartbeat:
var c check.HeartbeatConfig
_ = json.Unmarshal(m.Config, &c)