Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Structured logs for Stackdriver Logging #47

Closed
9 of 10 tasks
ymotongpoo opened this issue Sep 24, 2018 · 1 comment
Closed
9 of 10 tasks

JSON Structured logs for Stackdriver Logging #47

ymotongpoo opened this issue Sep 24, 2018 · 1 comment

Comments

@ymotongpoo
Copy link
Member

ymotongpoo commented Sep 24, 2018

Currently services in this demo, at least those written in Go, are emitting logs to stderr as of now, which makes the appearance of logs confusing because some info level logs are treated as error level ones, due to Stackdriver Logging's default setting. Changing the log destination to stdout solves this.

Also, all log messages are in text payload. Though this is the demonstration of GKE, it would be great if it can demonstrate the features of Stackdriver Logging as well. For that, using JSON (structured log format) can show how Stackdriver Logging can handle the log more efficiently such as handy filters.

Progress tracker

(added by ahmetb, cc: @ymotongpoo )

@ahmetb ahmetb changed the title Better log expression for Stackdriver Logging Structured logs for Stackdriver Logging Sep 24, 2018
sebright added a commit to sebright/microservices-demo that referenced this issue Sep 27, 2018
This commit enables OpenCensus log correlation using
opencensus-contrib-log-correlation-log4j2
(https://github.com/census-instrumentation/opencensus-java/tree/master/contrib/log_correlation/log4j2).
The library inserts the trace ID, span ID, and sampling decision into every
Log4j log event.  This commit includes other changes to make the tracing data
available in the logs, in a format that can be interpreted by the StackDriver
Logging agent:

- Convert all adservice log statements from java.util.logging to Log4j.

- Specify a JSON format for Log4j output.  This is related to issue GoogleCloudPlatform#47.

- Add the trace ID, span ID, and sampling decision to the JSON format.  Trace
  ID and span ID use special keys that the Stackdriver Logging agent uses to
  populate the tracing data fields in the LogEntry uploaded to Stackdriver
  (https://cloud.google.com/logging/docs/agent/configuration#special_fields_in_structured_payloads).
  However, Stackdriver won't be able to link the traces and log entries until
  fluent-plugin-google-cloud can automatically format the trace ID with the
  format expected by Stackdriver
  (GoogleCloudPlatform/fluent-plugin-google-cloud#239,
  GoogleCloudPlatform/fluent-plugin-google-cloud#260).

This commit also upgrades OpenCensus to 0.16.1 in order to use
opencensus-contrib-log-correlation-log4j2.
sebright added a commit to sebright/microservices-demo that referenced this issue Sep 28, 2018
This commit enables OpenCensus log correlation using
opencensus-contrib-log-correlation-log4j2
(https://github.com/census-instrumentation/opencensus-java/tree/master/contrib/log_correlation/log4j2).
The library inserts the trace ID, span ID, and sampling decision into every
Log4j log event.  This commit includes other changes to make the tracing data
available in the logs, in a format that can be interpreted by the Stackdriver
Logging agent:

- Convert all adservice log statements from java.util.logging to Log4j.

- Specify a JSON format for Log4j output.  This is related to issue GoogleCloudPlatform#47.

- Add the trace ID, span ID, and sampling decision to the JSON format.  Trace
  ID and span ID use special keys that the Stackdriver Logging agent uses to
  populate the tracing data fields in the LogEntry uploaded to Stackdriver
  (https://cloud.google.com/logging/docs/agent/configuration#special_fields_in_structured_payloads).
  However, Stackdriver won't be able to link the traces and log entries until
  fluent-plugin-google-cloud can automatically format the trace ID with the
  format expected by Stackdriver
  (GoogleCloudPlatform/fluent-plugin-google-cloud#239,
  GoogleCloudPlatform/fluent-plugin-google-cloud#260).

This commit also upgrades OpenCensus to 0.16.1 in order to use
opencensus-contrib-log-correlation-log4j2.
ahmetb pushed a commit that referenced this issue Oct 2, 2018
)

This commit enables OpenCensus log correlation using
opencensus-contrib-log-correlation-log4j2
(https://github.com/census-instrumentation/opencensus-java/tree/master/contrib/log_correlation/log4j2).
The library inserts the trace ID, span ID, and sampling decision into every
Log4j log event.  This commit includes other changes to make the tracing data
available in the logs, in a format that can be interpreted by the Stackdriver
Logging agent:

- Convert all adservice log statements from java.util.logging to Log4j.

- Specify a JSON format for Log4j output.  This is related to issue #47.

- Add the trace ID, span ID, and sampling decision to the JSON format.  Trace
  ID and span ID use special keys that the Stackdriver Logging agent uses to
  populate the tracing data fields in the LogEntry uploaded to Stackdriver
  (https://cloud.google.com/logging/docs/agent/configuration#special_fields_in_structured_payloads).
  However, Stackdriver won't be able to link the traces and log entries until
  fluent-plugin-google-cloud can automatically format the trace ID with the
  format expected by Stackdriver
  (GoogleCloudPlatform/fluent-plugin-google-cloud#239,
  GoogleCloudPlatform/fluent-plugin-google-cloud#260).

This commit also upgrades OpenCensus to 0.16.1 in order to use
opencensus-contrib-log-correlation-log4j2.
ymotongpoo added a commit to ymotongpoo/microservices-demo that referenced this issue Oct 2, 2018
…oogleCloudPlatform#47)

change the log format in Python and Node.js services.

Effected services are currencyservice, emailservice, paymentservice,
and recommendationservice. Loadgenerator is left as is because of
the diffculty to change the log format and log target in locust.
ahmetb pushed a commit that referenced this issue Oct 5, 2018
…66)

change the log format in Python and Node.js services.

Effected services are currencyservice, emailservice, paymentservice,
and recommendationservice. Loadgenerator is left as is because of
the diffculty to change the log format and log target in locust.

ref. #47
@ahmetb ahmetb changed the title Structured logs for Stackdriver Logging JSON Structured logs for Stackdriver Logging Oct 5, 2018
@askmeegs
Copy link
Contributor

cartservice is the only service remaining to complete this -- closing in favor of #154

D-Mwanth pushed a commit to D-Mwanth/microservices-demo that referenced this issue Mar 6, 2024
…oogleCloudPlatform#59)

This commit enables OpenCensus log correlation using
opencensus-contrib-log-correlation-log4j2
(https://github.com/census-instrumentation/opencensus-java/tree/master/contrib/log_correlation/log4j2).
The library inserts the trace ID, span ID, and sampling decision into every
Log4j log event.  This commit includes other changes to make the tracing data
available in the logs, in a format that can be interpreted by the Stackdriver
Logging agent:

- Convert all adservice log statements from java.util.logging to Log4j.

- Specify a JSON format for Log4j output.  This is related to issue GoogleCloudPlatform#47.

- Add the trace ID, span ID, and sampling decision to the JSON format.  Trace
  ID and span ID use special keys that the Stackdriver Logging agent uses to
  populate the tracing data fields in the LogEntry uploaded to Stackdriver
  (https://cloud.google.com/logging/docs/agent/configuration#special_fields_in_structured_payloads).
  However, Stackdriver won't be able to link the traces and log entries until
  fluent-plugin-google-cloud can automatically format the trace ID with the
  format expected by Stackdriver
  (GoogleCloudPlatform/fluent-plugin-google-cloud#239,
  GoogleCloudPlatform/fluent-plugin-google-cloud#260).

This commit also upgrades OpenCensus to 0.16.1 in order to use
opencensus-contrib-log-correlation-log4j2.
D-Mwanth pushed a commit to D-Mwanth/microservices-demo that referenced this issue Mar 6, 2024
…oogleCloudPlatform#66)

change the log format in Python and Node.js services.

Effected services are currencyservice, emailservice, paymentservice,
and recommendationservice. Loadgenerator is left as is because of
the diffculty to change the log format and log target in locust.

ref. GoogleCloudPlatform#47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants