mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-12-05 14:39:23 -05:00
The audit service reads the JetStream stream `audit` and writes every record as one line of JSON to stdout and, if configured, to an OTLP endpoint, with the emitting service in the resource. A record is acknowledged only when all outputs have it, so an output outage keeps the records in the stream, in order and without duplicates. The old audit log stays available with AUDIT_LEGACY_ENABLED. Adds the OpenTelemetry log packages for the OTLP output.
58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
package defaults
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/opencloud-eu/opencloud/services/audit/pkg/config"
|
|
)
|
|
|
|
// FullDefaultConfig returns a fully initialized default configuration
|
|
func FullDefaultConfig() *config.Config {
|
|
cfg := DefaultConfig()
|
|
EnsureDefaults(cfg)
|
|
Sanitize(cfg)
|
|
return cfg
|
|
}
|
|
|
|
// DefaultConfig returns a basic default configuration
|
|
func DefaultConfig() *config.Config {
|
|
return &config.Config{
|
|
Debug: config.Debug{
|
|
Addr: "127.0.0.1:9229",
|
|
Zpages: false,
|
|
Pprof: false,
|
|
},
|
|
Service: config.Service{
|
|
Name: "audit",
|
|
},
|
|
Events: config.Events{
|
|
Endpoint: "127.0.0.1:9233",
|
|
Cluster: "opencloud-cluster",
|
|
EnableTLS: false,
|
|
},
|
|
Stream: config.Stream{
|
|
Replicas: 1,
|
|
MaxAge: 7 * 24 * time.Hour,
|
|
},
|
|
Output: config.Output{
|
|
Stdout: true,
|
|
},
|
|
Auditlog: config.Auditlog{
|
|
LogToConsole: true,
|
|
Format: "json",
|
|
},
|
|
}
|
|
}
|
|
|
|
// EnsureDefaults adds default values to the configuration if they are not set yet
|
|
func EnsureDefaults(cfg *config.Config) {
|
|
if cfg.LogLevel == "" {
|
|
cfg.LogLevel = "error"
|
|
}
|
|
}
|
|
|
|
// Sanitize sanitized the configuration
|
|
func Sanitize(cfg *config.Config) {
|
|
// sanitize config
|
|
}
|