cmd: fix outpost metrics not being set in embedded mode

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-09-16 12:09:12 +02:00
parent 65c75f085a
commit f771383c4b
4 changed files with 10 additions and 8 deletions

View file

@ -133,6 +133,7 @@ jobs:
python-version: '3.9'
- name: checkout stable
run: |
git fetch
# Copy current, latest config to local
cp authentik/lib/default.yml local.env.yml
git checkout $(git describe --abbrev=0 --match 'version/*')

View file

@ -106,6 +106,7 @@ func attemptProxyStart(ws *web.WebServer, u *url.URL) {
log.WithField("logger", "authentik").Debug("attempting to start outpost")
err := ac.StartBackgorundTasks()
if err != nil {
log.WithField("logger", "authentik").WithError(err).Warning("outpost failed to start")
attempt += 1
time.Sleep(15 * time.Second)
if attempt > maxTries {

View file

@ -94,13 +94,6 @@ func NewAPIController(akURL url.URL, token string) *APIController {
// Start Starts all handlers, non-blocking
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()
if err != nil {
return err
@ -131,6 +124,13 @@ func (a *APIController) OnRefresh() error {
}
func (a *APIController) StartBackgorundTasks() 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.OnRefresh()
if err != nil {
return errors.Wrap(err, "failed to run initial refresh")

View file

@ -22,7 +22,7 @@ var (
func RunMetricsServer() {
m := mux.NewRouter()
m.Path("/metrics").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
defer promhttp.InstrumentMetricHandler(
promhttp.InstrumentMetricHandler(
prometheus.DefaultRegisterer, promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{
DisableCompression: true,
}),