thanos-io/thanos · error

journald log format requested but systemd journal is not…

Error message

journald log format requested but systemd journal is not available

What it means

NewLogger supports a journald log format, but it requires the process to run on a system with systemd journal available (journal.Enabled() from go-systemd). Requesting LogFormatJournald on a host without systemd journal (macOS, containers without journald socket, non-Linux) returns this error instead of silently degrading.

Solutions

  1. Switch --log.format to logfmt or JSON on hosts without systemd.
  2. Run the process on the host (or a container with journald socket mounted) where journal.Enabled() is true.
  3. Gate the journald format behind an environment check in your launcher script.

Example fix

// before
--log.format=journald   # in a plain Docker container
// after
--log.format=logfmt
Defensive patterns

Strategy: fallback

Validate before calling

if format == "journald" && !journal.Enabled() {
  fmt.Fprintln(os.Stderr, "journald unavailable, falling back to logfmt")
  format = "logfmt"
}

Try / catch

logger, err := logging.NewLogger(opts)
if err != nil { return nil, fmt.Errorf("logger init failed (check --log.format vs platform): %w", err) }

Prevention

When it happens

Trigger: Starting Thanos (main via flags) with --log.format=journald on a machine where journal.Enabled() is false — e.g. Docker containers without journald, macOS dev machines, or systemd-less distros.

Common situations: Copying a bare-metal journald config into a containerized deployment; running Thanos on macOS for local development with production flags; minimal images lacking libsystemd/journald socket.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/a11490292e5a2725. Report an issue: GitHub.

Appendix: source

Thrown at pkg/logging/logger.go:60

	case "info":
		lvl = level.AllowInfo()
	case "debug":
		lvl = level.AllowDebug()
	default:
		// This enum is already checked and enforced by flag validations, so
		// this should never happen.
		panic("unexpected log level")
	}

	logger = log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr))
	switch logFormat {
	case LogFormatJSON:
		logger = log.NewJSONLogger(log.NewSyncWriter(os.Stderr))
	case LogFormatJournald:
		if journal.Enabled() {
			logger = newJournaldLogger()
		} else {
			return nil, errors.New("journald log format requested but systemd journal is not available")
		}
	}

	// Sort the logger chain to avoid expensive log.Valuer evaluation for disallowed level.
	// Ref: https://github.com/go-kit/log/issues/14#issuecomment-945038252
	logger = log.With(logger, "ts", log.DefaultTimestampUTC, "caller", log.Caller(5))
	logger = level.NewFilter(logger, lvl)

	if debugName != "" {
		logger = log.With(logger, "name", debugName)
	}

	return LevelLogger{
		Logger:   logger,
		LogLevel: logLevel,
	}, nil
}

View on GitHub (pinned to 35b8b99117)