Open ebekebe opened 1 year ago
@ebekebe - thanks for submitting the feature request here. From the use case you outlined above, I agree this would be a helpful feature for users. Did you want to attempt adding this functionality in Skaffold?
Also, as a potential short term workaround, skaffold has an Events API: https://skaffold.dev/docs/design/api/
You could look at the events here (namely /v2/applicationLogs) which have the raw logs and metadata (which container made the log, etc.) and write a script to parse the events and use the metadata there to make the desired log output. Lmk if that would be helpful here and I can talk more about eventing or how do this if our docs aren't enough here
@aaron-prindle
Did you want to attempt adding this functionality in Skaffold?
No, maybe at a later point. We are currently evaluating skaffold for local dev as well as CI use. Since we can work around this issue ok for now, I will focus on big road blocks first (e.g. see my PR for daemonless buildkit CI).
You could look at the events here (namely /v2/applicationLogs) which have the raw logs and metadata (which container made the log, etc.) and write a script to parse the events and use the metadata there to make the desired log output. Lmk if that would be helpful here and I can talk more about eventing or how do this if our docs aren't enough here
That is interesting. I will certainly have a look at this one. Thanks for the pointer.
Comment for triage party.
Some of our services do structural logging in JSON. For development, we pipe stdout/stderr to a CLI tool like bunyan or pino-pretty, which parses the JSON and prints human readable log lines instead.
I would like to do the same when using
skaffold dev
, but as skaffold prefixes lines and outputs the logs of multiple services, this is not straight forward.Expected behavior
Skaffold yaml:
Semantics:
bunyan
. Capture the output of bunyan and treat it as if it was the original output of that service. In particular, prefix it as configured.bunyan
. Analogously to above, treat the output as if it was the original stderr output of SERVICE1.pino -i v
and handle output like described above.Actual behavior
There is no way of specifying a formatter.
A work-around is setting the log prefix to the empty string and pass it to pino. pino is smart enough to detect if a line is JSON and outputs non JSON lines verbatim. For bunyan, there is no such simple solution.
With the work-around, I see these drawbacks:
Information
Steps to reproduce the behavior
npm install -g pino-pretty
skaffold dev | pino-pretty