outposts: add consistent name and type to metrics
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
a6a6b3bd06
commit
471f7d9c62
|
@ -87,20 +87,20 @@ func NewAPIController(akURL url.URL, token string) *APIController {
|
||||||
instanceUUID: uuid.New(),
|
instanceUUID: uuid.New(),
|
||||||
Outpost: outpost,
|
Outpost: outpost,
|
||||||
}
|
}
|
||||||
ac.logger.Debugf("HA Reload offset: %s", ac.reloadOffset)
|
ac.logger.WithField("offset", ac.reloadOffset).Debug("HA Reload offset")
|
||||||
ac.initWS(akURL, strfmt.UUID(outpost.Pk))
|
ac.initWS(akURL, strfmt.UUID(outpost.Pk))
|
||||||
|
|
||||||
OutpostInfo.With(prometheus.Labels{
|
|
||||||
"uuid": ac.instanceUUID.String(),
|
|
||||||
"name": outpost.Name,
|
|
||||||
"version": constants.VERSION,
|
|
||||||
"build": constants.BUILD(),
|
|
||||||
}).Set(1)
|
|
||||||
return ac
|
return ac
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start Starts all handlers, non-blocking
|
// Start Starts all handlers, non-blocking
|
||||||
func (a *APIController) Start() error {
|
func (a *APIController) Start() error {
|
||||||
|
OutpostInfo.With(prometheus.Labels{
|
||||||
|
"outpost_name": a.Outpost.Name,
|
||||||
|
"outpost_type": a.Server.Type(),
|
||||||
|
"uuid": a.instanceUUID.String(),
|
||||||
|
"version": constants.VERSION,
|
||||||
|
"build": constants.BUILD(),
|
||||||
|
}).Set(1)
|
||||||
err := a.StartBackgorundTasks()
|
err := a.StartBackgorundTasks()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -136,10 +136,11 @@ func (a *APIController) StartBackgorundTasks() error {
|
||||||
return errors.Wrap(err, "failed to run initial refresh")
|
return errors.Wrap(err, "failed to run initial refresh")
|
||||||
} else {
|
} else {
|
||||||
LastUpdate.With(prometheus.Labels{
|
LastUpdate.With(prometheus.Labels{
|
||||||
"uuid": a.instanceUUID.String(),
|
"uuid": a.instanceUUID.String(),
|
||||||
"name": a.Outpost.Name,
|
"outpost_name": a.Outpost.Name,
|
||||||
"version": constants.VERSION,
|
"outpost_type": a.Server.Type(),
|
||||||
"build": constants.BUILD(),
|
"version": constants.VERSION,
|
||||||
|
"build": constants.BUILD(),
|
||||||
}).SetToCurrentTime()
|
}).SetToCurrentTime()
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
@ -76,8 +76,9 @@ func (ac *APIController) startWSHandler() {
|
||||||
err := ac.wsConn.ReadJSON(&wsMsg)
|
err := ac.wsConn.ReadJSON(&wsMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ConnectionStatus.With(prometheus.Labels{
|
ConnectionStatus.With(prometheus.Labels{
|
||||||
"uuid": ac.instanceUUID.String(),
|
"outpost_name": ac.Outpost.Name,
|
||||||
"name": ac.Outpost.Name,
|
"outpost_type": ac.Server.Type(),
|
||||||
|
"uuid": ac.instanceUUID.String(),
|
||||||
}).Set(0)
|
}).Set(0)
|
||||||
logger.WithError(err).Warning("ws write error, reconnecting")
|
logger.WithError(err).Warning("ws write error, reconnecting")
|
||||||
ac.wsConn.CloseAndReconnect()
|
ac.wsConn.CloseAndReconnect()
|
||||||
|
@ -85,8 +86,9 @@ func (ac *APIController) startWSHandler() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ConnectionStatus.With(prometheus.Labels{
|
ConnectionStatus.With(prometheus.Labels{
|
||||||
"uuid": ac.instanceUUID.String(),
|
"outpost_name": ac.Outpost.Name,
|
||||||
"name": ac.Outpost.Name,
|
"outpost_type": ac.Server.Type(),
|
||||||
|
"uuid": ac.instanceUUID.String(),
|
||||||
}).Set(1)
|
}).Set(1)
|
||||||
if wsMsg.Instruction == WebsocketInstructionTriggerUpdate {
|
if wsMsg.Instruction == WebsocketInstructionTriggerUpdate {
|
||||||
time.Sleep(ac.reloadOffset)
|
time.Sleep(ac.reloadOffset)
|
||||||
|
@ -96,10 +98,11 @@ func (ac *APIController) startWSHandler() {
|
||||||
logger.WithError(err).Debug("Failed to update")
|
logger.WithError(err).Debug("Failed to update")
|
||||||
} else {
|
} else {
|
||||||
LastUpdate.With(prometheus.Labels{
|
LastUpdate.With(prometheus.Labels{
|
||||||
"uuid": ac.instanceUUID.String(),
|
"outpost_name": ac.Outpost.Name,
|
||||||
"name": ac.Outpost.Name,
|
"outpost_type": ac.Server.Type(),
|
||||||
"version": constants.VERSION,
|
"uuid": ac.instanceUUID.String(),
|
||||||
"build": constants.BUILD(),
|
"version": constants.VERSION,
|
||||||
|
"build": constants.BUILD(),
|
||||||
}).SetToCurrentTime()
|
}).SetToCurrentTime()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,8 +131,9 @@ func (ac *APIController) startWSHealth() {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
ConnectionStatus.With(prometheus.Labels{
|
ConnectionStatus.With(prometheus.Labels{
|
||||||
"uuid": ac.instanceUUID.String(),
|
"outpost_name": ac.Outpost.Name,
|
||||||
"name": ac.Outpost.Name,
|
"outpost_type": ac.Server.Type(),
|
||||||
|
"uuid": ac.instanceUUID.String(),
|
||||||
}).Set(1)
|
}).Set(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,10 +148,11 @@ func (ac *APIController) startIntervalUpdater() {
|
||||||
logger.WithError(err).Debug("Failed to update")
|
logger.WithError(err).Debug("Failed to update")
|
||||||
} else {
|
} else {
|
||||||
LastUpdate.With(prometheus.Labels{
|
LastUpdate.With(prometheus.Labels{
|
||||||
"uuid": ac.instanceUUID.String(),
|
"outpost_name": ac.Outpost.Name,
|
||||||
"name": ac.Outpost.Name,
|
"outpost_type": ac.Server.Type(),
|
||||||
"version": constants.VERSION,
|
"uuid": ac.instanceUUID.String(),
|
||||||
"build": constants.BUILD(),
|
"version": constants.VERSION,
|
||||||
|
"build": constants.BUILD(),
|
||||||
}).SetToCurrentTime()
|
}).SetToCurrentTime()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,13 @@ var (
|
||||||
OutpostInfo = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
OutpostInfo = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
Name: "authentik_outpost_info",
|
Name: "authentik_outpost_info",
|
||||||
Help: "Outpost info",
|
Help: "Outpost info",
|
||||||
}, []string{"uuid", "name", "version", "build"})
|
}, []string{"outpost_name", "outpost_type", "uuid", "version", "build"})
|
||||||
LastUpdate = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
LastUpdate = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
Name: "authentik_outpost_last_update",
|
Name: "authentik_outpost_last_update",
|
||||||
Help: "Time of last update",
|
Help: "Time of last update",
|
||||||
}, []string{"uuid", "name", "version", "build"})
|
}, []string{"outpost_name", "outpost_type", "uuid", "version", "build"})
|
||||||
ConnectionStatus = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
ConnectionStatus = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
Name: "authentik_outpost_connection",
|
Name: "authentik_outpost_connection",
|
||||||
Help: "Connection status",
|
Help: "Connection status",
|
||||||
}, []string{"uuid", "name"})
|
}, []string{"outpost_name", "outpost_type", "uuid"})
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,4 +4,5 @@ type Outpost interface {
|
||||||
Start() error
|
Start() error
|
||||||
Refresh() error
|
Refresh() error
|
||||||
TimerFlowCacheExpiry()
|
TimerFlowCacheExpiry()
|
||||||
|
Type() string
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,3 +86,7 @@ func NewServer(ac *ak.APIController) *LDAPServer {
|
||||||
s.CloseFunc("", ls)
|
s.CloseFunc("", ls)
|
||||||
return ls
|
return ls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ls *LDAPServer) Type() string {
|
||||||
|
return "ldap"
|
||||||
|
}
|
||||||
|
|
|
@ -79,6 +79,10 @@ func (ps *ProxyServer) HandleHost(host string, rw http.ResponseWriter, r *http.R
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ps *ProxyServer) Type() string {
|
||||||
|
return "proxy"
|
||||||
|
}
|
||||||
|
|
||||||
func (ps *ProxyServer) TimerFlowCacheExpiry() {}
|
func (ps *ProxyServer) TimerFlowCacheExpiry() {}
|
||||||
|
|
||||||
func (ps *ProxyServer) getCertificates(info *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
func (ps *ProxyServer) getCertificates(info *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
||||||
|
|
Reference in a new issue