mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-01 21:21:04 +00:00
cmd/tailscaled: count all health messages
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
0f0d54b5cc
commit
3e9eaa293a
@ -63,6 +63,7 @@ import (
|
|||||||
"tailscale.com/util/clientmetric"
|
"tailscale.com/util/clientmetric"
|
||||||
"tailscale.com/util/multierr"
|
"tailscale.com/util/multierr"
|
||||||
"tailscale.com/util/osshare"
|
"tailscale.com/util/osshare"
|
||||||
|
"tailscale.com/util/usermetric"
|
||||||
"tailscale.com/version"
|
"tailscale.com/version"
|
||||||
"tailscale.com/version/distro"
|
"tailscale.com/version/distro"
|
||||||
"tailscale.com/wgengine"
|
"tailscale.com/wgengine"
|
||||||
@ -340,6 +341,13 @@ func run() (err error) {
|
|||||||
|
|
||||||
sys := new(tsd.System)
|
sys := new(tsd.System)
|
||||||
|
|
||||||
|
health := sys.HealthTracker()
|
||||||
|
metricHealthMessages.Set(healthMessageLabel{
|
||||||
|
Severity: "warning",
|
||||||
|
}, expvar.Func(func() any {
|
||||||
|
return health.OverallErrorCount()
|
||||||
|
}))
|
||||||
|
|
||||||
// Parse config, if specified, to fail early if it's invalid.
|
// Parse config, if specified, to fail early if it's invalid.
|
||||||
var conf *conffile.Config
|
var conf *conffile.Config
|
||||||
if args.confFile != "" {
|
if args.confFile != "" {
|
||||||
@ -919,3 +927,13 @@ func applyIntegrationTestEnvKnob() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type healthMessageLabel struct {
|
||||||
|
Severity string
|
||||||
|
}
|
||||||
|
|
||||||
|
var metricHealthMessages = usermetric.NewMultiLabelMap[healthMessageLabel](
|
||||||
|
"tailscaled_health_messages",
|
||||||
|
"gauge",
|
||||||
|
"A gauge of health messages from control, by severity",
|
||||||
|
)
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"cmp"
|
"cmp"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"expvar"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"maps"
|
"maps"
|
||||||
"net"
|
"net"
|
||||||
@ -33,7 +32,6 @@ import (
|
|||||||
"tailscale.com/util/clientmetric"
|
"tailscale.com/util/clientmetric"
|
||||||
"tailscale.com/util/mak"
|
"tailscale.com/util/mak"
|
||||||
"tailscale.com/util/set"
|
"tailscale.com/util/set"
|
||||||
"tailscale.com/util/usermetric"
|
|
||||||
"tailscale.com/wgengine/filter"
|
"tailscale.com/wgengine/filter"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -346,9 +344,6 @@ func (ms *mapSession) updateStateFromResponse(resp *tailcfg.MapResponse) {
|
|||||||
}
|
}
|
||||||
if resp.Health != nil {
|
if resp.Health != nil {
|
||||||
ms.lastHealth = resp.Health
|
ms.lastHealth = resp.Health
|
||||||
warnings := expvar.Int{}
|
|
||||||
warnings.Set(int64(len(resp.Health)))
|
|
||||||
metricHealthMessages.Set(healthMessageLabel{Severity: "warning"}, &warnings)
|
|
||||||
}
|
}
|
||||||
if resp.TKAInfo != nil {
|
if resp.TKAInfo != nil {
|
||||||
ms.lastTKAInfo = resp.TKAInfo
|
ms.lastTKAInfo = resp.TKAInfo
|
||||||
@ -358,16 +353,6 @@ func (ms *mapSession) updateStateFromResponse(resp *tailcfg.MapResponse) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type healthMessageLabel struct {
|
|
||||||
Severity string
|
|
||||||
}
|
|
||||||
|
|
||||||
var metricHealthMessages = usermetric.NewMultiLabelMap[healthMessageLabel](
|
|
||||||
"tailscaled_health_messages",
|
|
||||||
"gauge",
|
|
||||||
"A gauge of health messages from control, by severity",
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
patchDERPRegion = clientmetric.NewCounter("controlclient_patch_derp")
|
patchDERPRegion = clientmetric.NewCounter("controlclient_patch_derp")
|
||||||
patchEndpoints = clientmetric.NewCounter("controlclient_patch_endpoints")
|
patchEndpoints = clientmetric.NewCounter("controlclient_patch_endpoints")
|
||||||
|
@ -897,6 +897,18 @@ func (t *Tracker) OverallError() error {
|
|||||||
return t.multiErrLocked()
|
return t.multiErrLocked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OverallErrorCount returns the number of errors currently known to the
|
||||||
|
// Tracker.
|
||||||
|
func (t *Tracker) OverallErrorCount() int64 {
|
||||||
|
if t.nil() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
t.mu.Lock()
|
||||||
|
defer t.mu.Unlock()
|
||||||
|
t.updateBuiltinWarnablesLocked()
|
||||||
|
return int64(len(t.stringsLocked()))
|
||||||
|
}
|
||||||
|
|
||||||
// Strings() returns a string array containing the Text of all Warnings
|
// Strings() returns a string array containing the Text of all Warnings
|
||||||
// currently known to the Tracker. These strings can be presented to the
|
// currently known to the Tracker. These strings can be presented to the
|
||||||
// user, although ideally you would use the Code property on each Warning
|
// user, although ideally you would use the Code property on each Warning
|
||||||
|
Loading…
x
Reference in New Issue
Block a user