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

util/log: implement a json log entry parser #66684

Closed
cameronnunez opened this issue Jun 21, 2021 · 5 comments · Fixed by #79356
Closed

util/log: implement a json log entry parser #66684

cameronnunez opened this issue Jun 21, 2021 · 5 comments · Fixed by #79356
Assignees
Labels
A-logging In and around the logging infrastructure. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) X-anchored-telemetry The issue number is anchored by telemetry references.

Comments

@cameronnunez
Copy link
Contributor

cameronnunez commented Jun 21, 2021

The json log format currently does not have a parser. Because of this, tech support tools like debug zip and debug merge-logs fail during the construction of a parser for a log that is json formatted. Customers have expressed a desire to switch from crdb log formats to json formatting to be compatible with third-party tools.

We want to create a json log entry parser to remedy this, one that exists alongside the other parsers.

Jira issue: CRDB-8178

@cameronnunez cameronnunez added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-logging In and around the logging infrastructure. T-server-and-security DB Server & Security labels Jun 21, 2021
@knz knz added the X-anchored-telemetry The issue number is anchored by telemetry references. label Jul 6, 2021
@dhartunian
Copy link
Collaborator

I started filing a bug but discovered this one in the process so attaching my details as well. The one thing to note here is that this appears to be more severe than just affecting merge-logs but also prevents the logs from being exported at all.

Describe the problem

Use the following log config in logconfig.yaml (note the use of the json-fluent type!)

file-defaults:
  max-file-size: 10MiB
  max-group-size: 100MiB
  buffered-writes: true
  filter: INFO
  format: json-fluent
  redact: false
  redactable: true
  exit-on-error: true
  auditable: false
sinks:
  file-groups:
    sql-slow:
      channels: [SQL_PERF]
      format: crdb-v2
      redact: false
      redactable: true
    default:
      channels: [DEV, OPS, HEALTH]
      format: json-fluent
      redact: false
      redactable: true

Start a server:

./cockroach-short start-single-node --insecure --log-config-file=./logconfig.yaml

Generate a debug.zip

./cockroach-short debug zip /tmp/jsondebug.zip --insecure

Inspect zip file for default log:

cd /tmp
tar -xzf jsondebug.zip
cd debug/nodes/1/logs
cat cockroachshort.David-Hartunian-MacBook-Pro.david.2021-11-23T18_37_10Z.006761.log.err.txt

returns

rpc error: code = Unknown desc = decoding format: failed to extract log file format from the log

Expected behavior

The log file in the cockroach-data directory should be in the debug.zip file

This is what the local log looks like:

13:41:43 ❯ tail cockroach-data/logs/cockroachshort.David-Hartunian-MacBook-Pro.david.2021-11-23T18_37_10Z.006761.log
{"tag":"cockroachshort.dev","channel_numeric":0,"channel":"DEV","timestamp":"1637692645.753415000","cluster_id":"e3dc94b7-6f13-4c9f-bad8-da197ecc956c","node_id":1,"version":"v22.1.0-alpha.00000000-1480-g8bc5cb51a7","severity_numeric":2,"severity":"WARNING","goroutine":1433,"file":"jobs/registry.go","line":1458,"entry_counter":168,"redactable":1,"tags":{"n":"1"},"message":"failed to record error for job 713104539858632705: non-cancelable: marking migration complete for 21.1-1114: ‹migration-job-mark-job-succeeded›: cannot acquire lease when draining: non-cancelable: marking migration complete for 21.1-1114: ‹migration-job-mark-job-succeeded›: cannot acquire lease when draining"}
{"tag":"cockroachshort.ops","channel_numeric":1,"channel":"OPS","timestamp":"1637692645.792529000","cluster_id":"e3dc94b7-6f13-4c9f-bad8-da197ecc956c","node_id":1,"version":"v22.1.0-alpha.00000000-1480-g8bc5cb51a7","severity_numeric":1,"severity":"INFO","goroutine":1492,"file":"server/drain.go","line":161,"entry_counter":169,"redactable":1,"tags":{"server drain process":""},"message":"drain remaining: 6"}
{"tag":"cockroachshort.ops","channel_numeric":1,"channel":"OPS","timestamp":"1637692645.811880000","cluster_id":"e3dc94b7-6f13-4c9f-bad8-da197ecc956c","node_id":1,"version":"v22.1.0-alpha.00000000-1480-g8bc5cb51a7","severity_numeric":1,"severity":"INFO","goroutine":1492,"file":"server/drain.go","line":163,"entry_counter":170,"redactable":1,"tags":{"server drain process":""},"message":"drain details: descriptor leases: 5, liveness record: 1"}
{"tag":"cockroachshort.ops","channel_numeric":1,"channel":"OPS","timestamp":"1637692646.093153000","cluster_id":"e3dc94b7-6f13-4c9f-bad8-da197ecc956c","node_id":1,"version":"v22.1.0-alpha.00000000-1480-g8bc5cb51a7","severity_numeric":1,"severity":"INFO","goroutine":1492,"file":"server/drain.go","line":161,"entry_counter":171,"redactable":1,"tags":{"server drain process":""},"message":"drain remaining: 0"}
{"tag":"cockroachshort.dev","channel_numeric":0,"channel":"DEV","timestamp":"1637692646.093328000","cluster_id":"e3dc94b7-6f13-4c9f-bad8-da197ecc956c","node_id":1,"version":"v22.1.0-alpha.00000000-1480-g8bc5cb51a7","severity_numeric":2,"severity":"WARNING","goroutine":434,"file":"jobs/registry.go","line":851,"entry_counter":172,"redactable":1,"tags":{"n":"1"},"message":"canceling all adopted jobs due to stopper quiescing"}
{"tag":"cockroachshort.health","channel_numeric":2,"channel":"HEALTH","timestamp":"1637692646.093363000","cluster_id":"e3dc94b7-6f13-4c9f-bad8-da197ecc956c","node_id":1,"version":"v22.1.0-alpha.00000000-1480-g8bc5cb51a7","severity_numeric":1,"severity":"INFO","goroutine":528,"file":"rpc/context.go","line":688,"entry_counter":173,"redactable":1,"tags":{"n":"1"},"message":"closing [{n1: ‹David-Hartunian-MacBook-Pro:26257› (default)} {n0: ‹David-Hartunian-MacBook-Pro:26257› (default)}]"}
{"tag":"cockroachshort.dev","channel_numeric":0,"channel":"DEV","timestamp":"1637692646.093307000","cluster_id":"e3dc94b7-6f13-4c9f-bad8-da197ecc956c","node_id":1,"version":"v22.1.0-alpha.00000000-1480-g8bc5cb51a7","severity_numeric":2,"severity":"WARNING","goroutine":336,"file":"sql/sqlliveness/slinstance/slinstance.go","line":220,"entry_counter":174,"redactable":1,"tags":{"n":"1"},"message":"exiting heartbeat loop"}

Environment:

  • CockroachDB version: 22.0 (master branch)

Additional context
This bugfix should be backported to 21.2 and 21.1 if possible to enable smooth log collection for debugging.

@cameronnunez
Copy link
Contributor Author

cameronnunez commented Dec 15, 2021

Regarding debug zip, it seems it was originally designed to be a best effort utility with no guarantees to work for any configuration. Maybe there needs to be discussion if we want more guarantees. If we collectively decide we do want more guarantees, there's a number of things we'll need to do including ensuring a parser for every log format.

@cameronnunez
Copy link
Contributor Author

cc @thtruo for triage

@thtruo
Copy link
Contributor

thtruo commented Feb 22, 2022

This bubbled up again. Based on a followup with @cameronnunez, the Server team suggests it's best for Obs Infra to take ownership here. This is part of the transition where Obs Infra owns logging - so I'm updating the team label for us to triage cc @dhartunian

@thtruo thtruo added T-observability-inf and removed T-server-and-security DB Server & Security labels Feb 22, 2022
dhartunian added a commit to dhartunian/cockroach that referenced this issue Apr 4, 2022
Previously, our logging code did not have the ability to recognize and
decode JSON formatted log files. This led to problems when retrieving
logs via API endpoints and when running commands such as `merge-logs` to
process logs from debug.zip files.

This commit adds support for the json, json-compact, json-fluent, and
json-fluent-compact formats via one generalized JSON decoder.

Resolves cockroachdb#66684

Release note (ops change, cli change): debug zip and merge-logs commands
will now work with JSON formatted logs.
dhartunian added a commit to dhartunian/cockroach that referenced this issue Apr 22, 2022
Previously, our logging code did not have the ability to recognize and
decode JSON formatted log files. This led to problems when retrieving
logs via API endpoints and when running commands such as `merge-logs` to
process logs from debug.zip files.

This commit adds support for the json, json-compact, json-fluent, and
json-fluent-compact formats via one generalized JSON decoder.

Resolves cockroachdb#66684

Release note (ops change, cli change): debug zip and merge-logs commands
will now work with JSON formatted logs.
dhartunian added a commit to dhartunian/cockroach that referenced this issue Apr 23, 2022
Previously, our logging code did not have the ability to recognize and
decode JSON formatted log files. This led to problems when retrieving
logs via API endpoints and when running commands such as `merge-logs` to
process logs from debug.zip files.

This commit adds support for the json, json-compact, json-fluent, and
json-fluent-compact formats via one generalized JSON decoder.

Resolves cockroachdb#66684

Release note (ops change, cli change): debug zip and merge-logs commands
will now work with JSON formatted logs.
craig bot pushed a commit that referenced this issue May 18, 2022
79356: log: add support for decoding JSON logs r=cameronnunez,abarganier a=dhartunian

Previously, our logging code did not have the ability to recognize and
decode JSON formatted log files. This led to problems when retrieving
logs via API endpoints and when running commands such as `merge-logs` to
process logs from debug.zip files.

This commit adds support for the json, json-compact, json-fluent, and
json-fluent-compact formats via one generalized JSON decoder.

Resolves #66684

Release note (ops change, cli change): debug zip and merge-logs commands
will now work with JSON formatted logs.

Jira issue: CRDB-14742

81042: sql: support expression indexes in SHOW EXPERIMENTAL_FINGERPRINTS r=ajwerner a=stevendanna

Previously, SHOW EXPERIMENTAL_FINGERPRINTS would fail with an error as
it tried to directly select the 'crdb_internal_idx_expr' column.

Now, we construct a selection expression using the computed
expression.

Note that the current implementation of experimental_fingerprints
still doesn't work for inverted indexes. Tools like those
outlined in #59549 would provide a more generic way forward.

Release note (sql change): SHOW EXPERIMENTAL_FINGERPRINTS now supports
table with expression indexes.

81326: ui: create TimeScaleDropdown wrapper for key vizualizer r=Santamaura a=Santamaura

This patch introduces a new component to make the existing
TimeScaleDropdown component compatible with the wip key
vizualizer. Custom options and a new prop were provided to
make this compatability work.

Release note: None

![Screen Shot 2022-05-16 at 4 21 46 PM](https://user-images.githubusercontent.com/17861665/168680426-663f4b1d-d579-4ef5-8ac1-27cdc4cc6d9c.png)


81385: authors: add linaqiu22 to authors r=linaqiu22 a=linaqiu22



Co-authored-by: David Hartunian <[email protected]>
Co-authored-by: Steven Danna <[email protected]>
Co-authored-by: Santamaura <[email protected]>
Co-authored-by: linaqiu22 <[email protected]>
@craig craig bot closed this as completed in fa7facf May 18, 2022
blathers-crl bot pushed a commit that referenced this issue May 18, 2022
Previously, our logging code did not have the ability to recognize and
decode JSON formatted log files. This led to problems when retrieving
logs via API endpoints and when running commands such as `merge-logs` to
process logs from debug.zip files.

This commit adds support for the json, json-compact, json-fluent, and
json-fluent-compact formats via one generalized JSON decoder.

Resolves #66684

Release note (ops change, cli change): debug zip and merge-logs commands
will now work with JSON formatted logs.
@kenliu-crl
Copy link
Contributor

manually reviewed and updated

dhartunian added a commit to dhartunian/cockroach that referenced this issue Jun 21, 2022
Previously, our logging code did not have the ability to recognize and
decode JSON formatted log files. This led to problems when retrieving
logs via API endpoints and when running commands such as `merge-logs` to
process logs from debug.zip files.

This commit adds support for the json, json-compact, json-fluent, and
json-fluent-compact formats via one generalized JSON decoder.

Resolves cockroachdb#66684

Release note (ops change, cli change): debug zip and merge-logs commands
will now work with JSON formatted logs.
dhartunian added a commit to dhartunian/cockroach that referenced this issue Jun 29, 2022
Previously, our logging code did not have the ability to recognize and
decode JSON formatted log files. This led to problems when retrieving
logs via API endpoints and when running commands such as `merge-logs` to
process logs from debug.zip files.

This commit adds support for the json, json-compact, json-fluent, and
json-fluent-compact formats via one generalized JSON decoder.

Resolves cockroachdb#66684

Release note (ops change, cli change): debug zip and merge-logs commands
will now work with JSON formatted logs.
dhartunian added a commit to dhartunian/cockroach that referenced this issue Jul 6, 2022
Previously, our logging code did not have the ability to recognize and
decode JSON formatted log files. This led to problems when retrieving
logs via API endpoints and when running commands such as `merge-logs` to
process logs from debug.zip files.

This commit adds support for the json, json-compact, json-fluent, and
json-fluent-compact formats via one generalized JSON decoder.

Resolves cockroachdb#66684

Release note (ops change, cli change): debug zip and merge-logs commands
will now work with JSON formatted logs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-logging In and around the logging infrastructure. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) X-anchored-telemetry The issue number is anchored by telemetry references.
Projects
None yet
5 participants