diff --git a/authentik/outposts/models.py b/authentik/outposts/models.py index 0303ec3d4..e2a0c60ea 100644 --- a/authentik/outposts/models.py +++ b/authentik/outposts/models.py @@ -67,8 +67,6 @@ class OutpostConfig: authentik_host_browser: str = "" log_level: str = CONFIG.y("log_level") - error_reporting_enabled: bool = CONFIG.y_bool("error_reporting.enabled") - error_reporting_environment: str = CONFIG.y("error_reporting.environment", "customer") object_naming_template: str = field(default="ak-outpost-%(name)s") docker_network: Optional[str] = field(default=None) diff --git a/internal/outpost/ak/api.go b/internal/outpost/ak/api.go index 198d14946..42fee6598 100644 --- a/internal/outpost/ak/api.go +++ b/internal/outpost/ak/api.go @@ -22,8 +22,6 @@ import ( ) const ConfigLogLevel = "log_level" -const ConfigErrorReportingEnabled = "error_reporting_enabled" -const ConfigErrorReportingEnvironment = "error_reporting_environment" // APIController main controller which connects to the authentik api via http and ws type APIController struct { @@ -68,7 +66,6 @@ func NewAPIController(akURL url.URL, token string) *APIController { return nil } outpost := outposts.Results[0] - doGlobalSetup(outpost.Config) log.WithField("name", outpost.Name).Debug("Fetched outpost configuration") @@ -79,6 +76,8 @@ func NewAPIController(akURL url.URL, token string) *APIController { } log.Debug("Fetched global configuration") + doGlobalSetup(outpost, akConfig) + ac := &APIController{ Client: apiClient, GlobalConfig: akConfig, diff --git a/internal/outpost/ak/global.go b/internal/outpost/ak/global.go index 2ebecfd37..28dc7d951 100644 --- a/internal/outpost/ak/global.go +++ b/internal/outpost/ak/global.go @@ -1,6 +1,7 @@ package ak import ( + "fmt" "net/http" "os" "strings" @@ -8,17 +9,18 @@ import ( "github.com/getsentry/sentry-go" httptransport "github.com/go-openapi/runtime/client" log "github.com/sirupsen/logrus" + "goauthentik.io/api" "goauthentik.io/internal/constants" ) -func doGlobalSetup(config map[string]interface{}) { +func doGlobalSetup(outpost api.Outpost, globalConfig api.Config) { log.SetFormatter(&log.JSONFormatter{ FieldMap: log.FieldMap{ log.FieldKeyMsg: "event", log.FieldKeyTime: "timestamp", }, }) - switch config[ConfigLogLevel].(string) { + switch outpost.Config[ConfigLogLevel].(string) { case "trace": log.SetLevel(log.TraceLevel) case "debug": @@ -34,29 +36,17 @@ func doGlobalSetup(config map[string]interface{}) { } log.WithField("logger", "authentik.outpost").WithField("hash", constants.BUILD()).WithField("version", constants.VERSION).Info("Starting authentik outpost") - sentryEnv := "customer-outpost" - sentryEnable := true - if cSentryEnv, ok := config[ConfigErrorReportingEnvironment]; ok { - if ccSentryEnv, ok := cSentryEnv.(string); ok { - sentryEnv = ccSentryEnv - } - } - var dsn string - if cSentryEnable, ok := config[ConfigErrorReportingEnabled]; ok { - if ccSentryEnable, ok := cSentryEnable.(bool); ok { - sentryEnable = ccSentryEnable - } - } - if sentryEnable { - dsn = "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8" + if globalConfig.ErrorReporting.Enabled { + sentryEnv := fmt.Sprintf("%s-outpost-%s", globalConfig.ErrorReporting.Environment, outpost.Type) + dsn := "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8" log.WithField("env", sentryEnv).Debug("Error reporting enabled") err := sentry.Init(sentry.ClientOptions{ Dsn: dsn, Environment: sentryEnv, - TracesSampleRate: 1, + TracesSampleRate: float64(globalConfig.ErrorReporting.TracesSampleRate), }) if err != nil { - log.Fatalf("sentry.Init: %s", err) + log.WithField("env", sentryEnv).WithError(err).Warning("Failed to initialise sentry") } } } diff --git a/website/docs/outposts/outposts.md b/website/docs/outposts/outposts.md index 96d31f23e..811ccda77 100644 --- a/website/docs/outposts/outposts.md +++ b/website/docs/outposts/outposts.md @@ -27,9 +27,6 @@ Outposts fetch their configuration from authentik. Below are all the options you ```yaml # Log level that the outpost will set log_level: debug -# Enable/disable error reporting for the outpost, based on the authentik settings -error_reporting_enabled: true -error_reporting_environment: beryjuorg-prod ######################################## # The settings below are only relevant when using a managed outpost ########################################