Skip to content

Should journald keys be sanitized to strip/replace invalid characters? #668

@jqueuniet

Description

@jqueuniet

Some logging middlewares like https://github.com/grpc-ecosystem/go-grpc-middleware/blob/main/interceptors/logging/logging.go like to use dots to namespace field keys. This is not an issue using the console or JSON output formats, but sending those messages to the journald writer triggers errors on the dot character.

Apr 15 07:53:33 hostname process[521208]: 07:53:33 INF started call grpc.component=server grpc.method=Check grpc.method_type=unary grpc.service=grpc.health.v1.Health grpc.start_time=2024-04-15T07:53:33Z grpc.time_ms=0.019 peer.address=1.2.3.4:49140 protocol=grpc request_id=4a4a70b0-1c92-47d9-a50c-b10f9f636bd7
Apr 15 07:53:33 hostname process[521208]: variable name GRPC.SERVICE contains invalid character, ignoring
Apr 15 07:53:33 hostname process[521208]: variable name GRPC.METHOD contains invalid character, ignoring
Apr 15 07:53:33 hostname process[521208]: variable name GRPC.START_TIME contains invalid character, ignoring
Apr 15 07:53:33 hostname process[521208]: variable name GRPC.TIME_MS contains invalid character, ignoring
Apr 15 07:53:33 hostname process[521208]: variable name PEER.ADDRESS contains invalid character, ignoring
Apr 15 07:53:33 hostname process[521208]: variable name GRPC.METHOD_TYPE contains invalid character, ignoring
Apr 15 07:53:33 hostname process[521208]: variable name GRPC.COMPONENT contains invalid character, ignoring

Do you consider the journald writer could make some attempt at sanitising those keys, ie by replacing invalid characters by _ or something else, or do you feel like it is the responsibility of the zerolog user to ensure only valid keys are used?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions