Skip to content

Commit

Permalink
[batch] Add json parsing and severity to GCP Ops Agent config (hail-i…
Browse files Browse the repository at this point in the history
…s#14187)

Currently the Ops Agent does not do any parsing of the log message, so
the log entry in Google Logging looks like:

```
jsonPayload: {
  message: "{"severity":"INFO","levelname":"INFO","asctime":"2024-01-22 16:10:45,748","filename":"worker.py","funcNameAndLine":"<module>:3461","message":"closed","hail_log":1}"
}
```

The `parse_json` processor extracts the json fields from the message
into fields on the `jsonPayload` so it looks like this

```
jsonPayload: {
asctime: "2024-01-22 16:14:06,098"
filename: "worker.py"
funcNameAndLine: "<module>:180"
hail_log: 1
levelname: "INFO"
message: "CLOUD gcp"
}
```

and only the new `message` field is displayed in the Google Logging row
instead of the whole json.

This also adds a `severity` field on the log entry so filters such as
`SEVERITY!=INFO` work as expected.
  • Loading branch information
daniel-goldstein authored Jan 22, 2024
1 parent ae7b87f commit 2858259
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion batch/batch/cloud/gcp/driver/create_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,22 @@ def scheduling() -> dict:
- /batch/jvm-container-logs/jvm-*.log
record_log_file_path: true
processors:
parse_message:
type: parse_json
labels:
type: modify_fields
fields:
labels.namespace:
static_value: $NAMESPACE
labels.instance_id:
static_value: $INSTANCE_ID
severity:
move_from: jsonPayload.severity
service:
log_level: error
pipelines:
default_pipeline:
processors: [labels]
processors: [parse_message, labels]
receivers: [runlog, workerlog, jvmlog]
metrics:
Expand Down

0 comments on commit 2858259

Please sign in to comment.