Add web auth, infinite-scroll, agent admission and review fixes across agent/server/web
This commit is contained in:
@@ -13,24 +13,29 @@ import (
|
||||
type Metrics struct {
|
||||
Registry *prometheus.Registry
|
||||
|
||||
CheckRuns *prometheus.CounterVec
|
||||
CheckSkipped *prometheus.CounterVec
|
||||
CheckDuration *prometheus.HistogramVec
|
||||
CheckStatus *prometheus.GaugeVec
|
||||
CheckExitCode *prometheus.GaugeVec
|
||||
CheckLastRun *prometheus.GaugeVec
|
||||
CheckLastSuccess *prometheus.GaugeVec
|
||||
CheckInterval *prometheus.GaugeVec
|
||||
ChecksConfigured prometheus.Gauge
|
||||
SpoolDepth prometheus.Gauge
|
||||
SpoolBytes prometheus.Gauge
|
||||
SendAttempts *prometheus.CounterVec
|
||||
SendFailures *prometheus.CounterVec
|
||||
EventsAccepted prometheus.Counter
|
||||
EventsDedup prometheus.Counter
|
||||
EventsDropped *prometheus.CounterVec
|
||||
LastHeartbeat prometheus.Gauge
|
||||
BuildInfo *prometheus.GaugeVec
|
||||
CheckRuns *prometheus.CounterVec
|
||||
CheckSkipped *prometheus.CounterVec
|
||||
CheckDuration *prometheus.HistogramVec
|
||||
CheckStatus *prometheus.GaugeVec
|
||||
CheckExitCode *prometheus.GaugeVec
|
||||
CheckLastRun *prometheus.GaugeVec
|
||||
CheckLastSuccess *prometheus.GaugeVec
|
||||
CheckInterval *prometheus.GaugeVec
|
||||
ChecksConfigured prometheus.Gauge
|
||||
ConfigLoadSuccess prometheus.Gauge
|
||||
ConfigReloadTotal *prometheus.CounterVec
|
||||
ConfigLastReloadSuccess prometheus.Gauge
|
||||
ResourceLimitApplyFailures *prometheus.CounterVec
|
||||
EventsChannelFull prometheus.Counter
|
||||
SpoolDepth prometheus.Gauge
|
||||
SpoolBytes prometheus.Gauge
|
||||
SendAttempts *prometheus.CounterVec
|
||||
SendFailures *prometheus.CounterVec
|
||||
EventsAccepted prometheus.Counter
|
||||
EventsDedup prometheus.Counter
|
||||
EventsDropped *prometheus.CounterVec
|
||||
LastHeartbeat prometheus.Gauge
|
||||
BuildInfo *prometheus.GaugeVec
|
||||
}
|
||||
|
||||
// StatusCode maps a CheckResultEvent status string to a numeric gauge value.
|
||||
@@ -115,6 +120,26 @@ func New() *Metrics {
|
||||
Name: "monlet_agent_checks_configured",
|
||||
Help: "Number of checks configured.",
|
||||
})
|
||||
m.ConfigLoadSuccess = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "monlet_agent_config_load_success",
|
||||
Help: "Whether the last agent config load or reload succeeded.",
|
||||
})
|
||||
m.ConfigReloadTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: "monlet_agent_config_reload_total",
|
||||
Help: "Number of config reload attempts by result.",
|
||||
}, []string{"result"})
|
||||
m.ConfigLastReloadSuccess = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "monlet_agent_config_last_reload_success_timestamp_seconds",
|
||||
Help: "Unix timestamp of the last successful config reload.",
|
||||
})
|
||||
m.ResourceLimitApplyFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: "monlet_agent_resource_limit_apply_failures_total",
|
||||
Help: "Number of failed resource limit applications by check and resource.",
|
||||
}, []string{"check_id", "resource"})
|
||||
m.EventsChannelFull = prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Name: "monlet_agent_events_channel_full_total",
|
||||
Help: "Number of times scheduler event delivery would block because the agent event channel was full.",
|
||||
})
|
||||
m.LastHeartbeat = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "monlet_agent_last_heartbeat_timestamp_seconds",
|
||||
Help: "Unix timestamp of the last successful heartbeat ack.",
|
||||
@@ -126,6 +151,9 @@ func New() *Metrics {
|
||||
reg.MustRegister(m.CheckRuns, m.CheckSkipped, m.CheckDuration,
|
||||
m.CheckStatus, m.CheckExitCode, m.CheckLastRun, m.CheckLastSuccess,
|
||||
m.CheckInterval, m.ChecksConfigured,
|
||||
m.ConfigLoadSuccess, m.ConfigReloadTotal, m.ConfigLastReloadSuccess,
|
||||
m.ResourceLimitApplyFailures,
|
||||
m.EventsChannelFull,
|
||||
m.SpoolDepth, m.SpoolBytes,
|
||||
m.SendAttempts, m.SendFailures,
|
||||
m.EventsAccepted, m.EventsDedup, m.EventsDropped,
|
||||
@@ -133,6 +161,19 @@ func New() *Metrics {
|
||||
return m
|
||||
}
|
||||
|
||||
// DeleteCheck removes metric series for a check that no longer exists.
|
||||
func (m *Metrics) DeleteCheck(checkID string) {
|
||||
m.CheckRuns.DeletePartialMatch(prometheus.Labels{"check_id": checkID})
|
||||
m.CheckSkipped.DeleteLabelValues(checkID)
|
||||
m.CheckDuration.DeleteLabelValues(checkID)
|
||||
m.CheckStatus.DeleteLabelValues(checkID)
|
||||
m.CheckExitCode.DeleteLabelValues(checkID)
|
||||
m.CheckLastRun.DeleteLabelValues(checkID)
|
||||
m.CheckLastSuccess.DeleteLabelValues(checkID)
|
||||
m.CheckInterval.DeleteLabelValues(checkID)
|
||||
m.ResourceLimitApplyFailures.DeletePartialMatch(prometheus.Labels{"check_id": checkID})
|
||||
}
|
||||
|
||||
// Serve blocks until ctx is done; the listener is closed on shutdown.
|
||||
func (m *Metrics) Serve(ctx context.Context, addr string) error {
|
||||
mux := http.NewServeMux()
|
||||
|
||||
@@ -14,6 +14,7 @@ func TestMetricsExposeRegistered(t *testing.T) {
|
||||
m := New()
|
||||
m.CheckRuns.WithLabelValues("c1", "ok").Inc()
|
||||
m.SpoolDepth.Set(7)
|
||||
m.EventsChannelFull.Inc()
|
||||
srv := httptest.NewServer(promhttp.HandlerFor(m.Registry, promhttp.HandlerOpts{}))
|
||||
defer srv.Close()
|
||||
resp, err := http.Get(srv.URL)
|
||||
@@ -26,6 +27,7 @@ func TestMetricsExposeRegistered(t *testing.T) {
|
||||
for _, want := range []string{
|
||||
`monlet_agent_check_runs_total{check_id="c1",status="ok"} 1`,
|
||||
`monlet_agent_spool_events 7`,
|
||||
`monlet_agent_events_channel_full_total 1`,
|
||||
} {
|
||||
if !strings.Contains(s, want) {
|
||||
t.Errorf("missing %q in output", want)
|
||||
|
||||
Reference in New Issue
Block a user