feat: 1.3.0 thirteen new pages, charts, tooltips and error analysis
Release / Plan (reuse the published image?) (push) Successful in 3s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 28s
CI / Dependency audit (push) Successful in 20s
CI / Tests (Linux, race detector) (push) Successful in 1m10s
Release / ci (push) Successful in 1m10s
Release / Build image (arm64) (push) Successful in 55s
Release / Build image (amd64) (push) Successful in 1m16s
Release / Publish tags (push) Successful in 14s
Release / Gitea release (push) Skipped
Release / Plan (reuse the published image?) (push) Successful in 3s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 28s
CI / Dependency audit (push) Successful in 20s
CI / Tests (Linux, race detector) (push) Successful in 1m10s
Release / ci (push) Successful in 1m10s
Release / Build image (arm64) (push) Successful in 55s
Release / Build image (amd64) (push) Successful in 1m16s
Release / Publish tags (push) Successful in 14s
Release / Gitea release (push) Skipped
New pages grouped in the rail (Monitor, Investigate, Analyze, Operate, Reports): Services (SLO, Apdex, latency app vs proxy), Sessions (stage funnel), Campaigns, Event search, MITRE ATT&CK matrix, Evolution, Concentration (Pareto, Gini), Survival (Kaplan-Meier per attack episode, recidivists), Where errors come from (application vs failed attack vs proxy vs client), Protocols and TLS, Defense (fail2ban, SSH, blocklist), Integrity, and a printable executive report. Chart library (donut, radar, stacked area, bars, heatmap, gauge), glossary with accessible "?" tooltips, self-explanatory category names (nonexistent page 404), page loader through pages.json. Unique visitors fixed: real browsers opening a page, one per IP per day, deduplicated across domains, with non-human clients counted apart. Anonymous legitimate visits on the Live page (?visits=1, no IP). Traefik origin, service, protocol and TLS fields parsed. Paths and Referer paths drop e-mail and token segments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b7462c14fa
commit
2ebda1e4d7
79 files changed
+9091
-171
No files matched your search
@@ -0,0 +1,132 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"git.lucasrguerra.dev.br/ciberfauna/urutau/internal/store"
|
||||
)
|
||||
|
||||
type integritySource struct {
|
||||
Name string `json:"name"`
|
||||
State string `json:"state"`
|
||||
Lines uint64 `json:"lines"`
|
||||
Malformed uint64 `json:"malformed"`
|
||||
Last int64 `json:"last"`
|
||||
}
|
||||
|
||||
type integrityHost struct {
|
||||
Name string `json:"name"`
|
||||
Online bool `json:"online"`
|
||||
LastEvent int64 `json:"last_event"`
|
||||
LagS int64 `json:"lag_s"`
|
||||
Hourly []uint32 `json:"hourly"`
|
||||
Gaps []store.Gap `json:"gaps"`
|
||||
Sources []integritySource `json:"sources"`
|
||||
ParseErrorRate float64 `json:"parse_error_rate"`
|
||||
}
|
||||
|
||||
type integrityPeer struct {
|
||||
Name string `json:"name"`
|
||||
Online bool `json:"online"`
|
||||
Live bool `json:"live"`
|
||||
LastSync int64 `json:"last_sync"`
|
||||
}
|
||||
|
||||
type integrityGeo struct {
|
||||
CityBuild int64 `json:"city_build"`
|
||||
ASNBuild int64 `json:"asn_build"`
|
||||
State string `json:"state"`
|
||||
LastUpdate int64 `json:"last_update"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type integrityOut struct {
|
||||
Range store.RangeInfo `json:"range"`
|
||||
FromHour int64 `json:"from_hour"`
|
||||
Hosts []integrityHost `json:"hosts"`
|
||||
Peers []integrityPeer `json:"peers"`
|
||||
EventLog store.LogStats `json:"eventlog"`
|
||||
Geo integrityGeo `json:"geo"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
registerUserRoute("GET /api/v1/integrity", func(s *Server) http.HandlerFunc { return s.integrity })
|
||||
}
|
||||
|
||||
// integrity answers "is the data complete?": events ingested per hour and
|
||||
// host, silences, source and peer states, parse errors, event log and geo base.
|
||||
func (s *Server) integrity(w http.ResponseWriter, r *http.Request) {
|
||||
rg, ok := s.rangeOf(w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
host := r.URL.Query().Get("host")
|
||||
if host == "" {
|
||||
host = "all"
|
||||
}
|
||||
if !s.knownHost(w, host) {
|
||||
return
|
||||
}
|
||||
now := s.opt.Now().Unix()
|
||||
info := rg.Info(now)
|
||||
parts, all := s.parts(r.Context(), rg, host)
|
||||
fromH, toH := info.From/3600, info.To/3600
|
||||
if toH-fromH > 24*31-1 {
|
||||
fromH = toH - (24*31 - 1)
|
||||
}
|
||||
out := integrityOut{Range: info, FromHour: fromH, Hosts: []integrityHost{}, Peers: []integrityPeer{}}
|
||||
seen := map[string]bool{}
|
||||
for _, p := range parts {
|
||||
name := p.Host
|
||||
if name == "" && len(p.Hosts) > 0 {
|
||||
name = p.Hosts[0].Name
|
||||
}
|
||||
seen[name] = true
|
||||
hh := integrityHost{Name: name, Online: true, Sources: []integritySource{}}
|
||||
hh.Hourly = store.HourlyFromTimeline(p.Timeline, fromH, toH)
|
||||
hh.Gaps = store.FindGaps(hh.Hourly, fromH)
|
||||
var lines, bad uint64
|
||||
for _, src := range p.Sources {
|
||||
if src.Name == "geo" {
|
||||
if name == s.opt.Store.Name() {
|
||||
out.Geo = integrityGeo{State: src.State, LastUpdate: src.LastEvent, Error: src.Error}
|
||||
if store.GeoBuilds != nil {
|
||||
out.Geo.CityBuild, out.Geo.ASNBuild = store.GeoBuilds()
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
hh.Sources = append(hh.Sources, integritySource{Name: src.Name, State: src.State, Lines: src.Lines, Malformed: src.Malformed, Last: src.LastEvent})
|
||||
lines += src.Lines
|
||||
bad += src.Malformed
|
||||
if src.LastEvent > hh.LastEvent {
|
||||
hh.LastEvent = src.LastEvent
|
||||
}
|
||||
}
|
||||
if lines+bad > 0 {
|
||||
hh.ParseErrorRate = float64(bad) / float64(lines+bad)
|
||||
}
|
||||
if hh.LastEvent > 0 {
|
||||
hh.LagS = now - hh.LastEvent
|
||||
if hh.LagS < 0 {
|
||||
hh.LagS = 0
|
||||
}
|
||||
}
|
||||
out.Hosts = append(out.Hosts, hh)
|
||||
}
|
||||
for _, hi := range all {
|
||||
if hi.Self {
|
||||
continue
|
||||
}
|
||||
out.Peers = append(out.Peers, integrityPeer{Name: hi.Name, Online: hi.Online, Live: hi.Live, LastSync: hi.LastSeen})
|
||||
if !seen[hi.Name] && (host == "all" || host == hi.Name) {
|
||||
out.Hosts = append(out.Hosts, integrityHost{Name: hi.Name, Online: hi.Online, LastEvent: hi.LastSeen,
|
||||
Hourly: make([]uint32, toH-fromH+1), Gaps: []store.Gap{}, Sources: []integritySource{}})
|
||||
}
|
||||
}
|
||||
sort.SliceStable(out.Hosts, func(i, j int) bool { return out.Hosts[i].Name < out.Hosts[j].Name })
|
||||
sort.SliceStable(out.Peers, func(i, j int) bool { return out.Peers[i].Name < out.Peers[j].Name })
|
||||
out.EventLog = s.opt.Store.LogStats()
|
||||
writeJSON(w, 200, out)
|
||||
}
|
||||
Reference in new issue
Block a user