Skip to content

Commit 61886ea

Browse files
nnshah1rmccorm4
andauthored
Logging format cherry-picks (#7253)
--------- Co-authored-by: Ryan McCormick <[email protected]>
1 parent 5fe2e58 commit 61886ea

File tree

7 files changed

+652
-15
lines changed

7 files changed

+652
-15
lines changed

docs/protocol/extension_logging.md

+80-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ the `$string` representation of the log setting and the “value” is a `$strin
6969
`$bool`, or `$number` representation of the setting value. Currently, the
7070
following log settings are defined:
7171

72-
- "log_file" : a `$string` parameter defining the file where the log outputs will be saved. If an empty string is specified, log outputs will stream to the console.
72+
- "log_file" : a `$string` log file location where the log outputs will be saved. If empty, log outputs are streamed to the console.
7373

7474
- "log_info" : a `$boolean` parameter that controls whether the Triton server logs INFO level messages.
7575

@@ -117,8 +117,14 @@ $log_setting_request =
117117
}
118118
```
119119

120-
When a `$log_setting` JSON is received (defined above), only the specified
121-
settings will be updated.
120+
When a `$log_setting` JSON is received (defined above), only the
121+
specified settings will be updated. Currently, the following log
122+
settings (described above) can be updated:
123+
- "log_info"
124+
- "log_warning"
125+
- "log_error"
126+
- "log_verbose_level"
127+
- "log_format"
122128

123129
### Example Usage
124130
The logging protocol extension can be invoked using the curl library in the following manner (assuming
@@ -196,3 +202,74 @@ message LogSettingsResponse
196202
map<string, SettingValue> settings = 1;
197203
}
198204
```
205+
206+
## Logging Formats
207+
208+
The logging extension offers two logging formats. The formats have a
209+
common set of fields but differ in how the timestamp for a log entry
210+
is represented. Messages are serialized according to JSON encoding
211+
rules by default. This behavior can be disabled by setting the
212+
environment variable TRITON_SERVER_ESCAPE_LOG_MESSAGES to "0" when
213+
launching the server but can not be changed through the logging
214+
extension.
215+
216+
Log entries can be single-line or multi-line. Multi-line entries have
217+
a single optional heading followed by the structured representation of
218+
an object such as a table or protobuf message. Multi-line entries end
219+
when the next log entry begins.
220+
221+
1. TRITONSERVER_LOG_DEFAULT
222+
223+
### Single-line Entry
224+
```
225+
<level><month><day><hour>:<min>:<sec>.<usec> <pid> <file>:<line>] <message>
226+
```
227+
Example:
228+
```
229+
I0520 20:03:25.829575 3355 model_lifecycle.cc:441] "AsyncLoad() 'simple'"
230+
```
231+
### Multi-line Entry
232+
```
233+
<level><month><day><hour>:<min>:<sec>.<usec> <pid> <file>:<line>] <heading>
234+
<object>
235+
```
236+
Example:
237+
238+
```
239+
I0520 20:03:25.912303 3355 server.cc:676]
240+
+--------+---------+--------+
241+
| Model | Version | Status |
242+
+--------+---------+--------+
243+
| simple | 1 | READY |
244+
+--------+---------+--------+
245+
```
246+
247+
248+
2. TRITONSERVER_LOG_ISO8601
249+
250+
### Single-line Entry
251+
```
252+
<year>-<month>-<day>T<hour>:<min>:<sec>Z <level> <pid> <file>:<line>] <message>
253+
```
254+
255+
Example:
256+
```
257+
2024-05-20T20:03:26Z I 3415 model_lifecycle.cc:441] "AsyncLoad() 'simple'"
258+
```
259+
260+
### Multi-line Entry
261+
```
262+
<year>-<month>-<day>T<hour>:<min>:<sec>Z <level> <pid> <file>:<line>] <heading>
263+
<object>
264+
```
265+
266+
Example:
267+
268+
```
269+
2024-05-20T20:03:26Z I 3415 server.cc:676]
270+
+--------+---------+--------+
271+
| Model | Version | Status |
272+
+--------+---------+--------+
273+
| simple | 1 | READY |
274+
+--------+---------+--------+
275+
```

qa/L0_backend_config/test.sh

+23-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@
2525
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2626
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727

28+
# Parses default-max-batch-size log record
29+
#
30+
# Example log record:
31+
# I0521 02:12:37.402353 161 backend_model.cc:503] "Adding default backend config setting: default-max-batch-size,4
32+
parse_default_max_batch_size() {
33+
echo $(python3 -c "print('$1'.split(',')[1].strip('\"'))")
34+
}
35+
36+
# Returns backend configuration json
37+
# message from server log file path
38+
#
39+
# Example: config_map = $(get_config_map server.log)
40+
get_config_map() {
41+
BACKEND_CONFIG_MAP=$(grep "backend configuration:" $1)
42+
echo $(python3 -c "backend_config='$BACKEND_CONFIG_MAP'.split('] \"backend configuration:\n')[1].rstrip('\"');print(backend_config)")
43+
}
44+
2845
REPO_VERSION=${NVIDIA_TRITON_SERVER_VERSION}
2946
if [ "$#" -ge 1 ]; then
3047
REPO_VERSION=$1
@@ -88,7 +105,7 @@ else
88105
if [ "$RESULT_LOG_LINE" != "" ]; then
89106

90107
# Pick out the logged value of the default-max-batch-size which gets passed into model creation
91-
RESOLVED_DEFAULT_MAX_BATCH_SIZE=$(awk -v line="$RESULT_LOG_LINE" 'BEGIN {split(line, a, "]"); split(a[2], b, ": "); split(b[2], c, ","); print c[2]}')
108+
RESOLVED_DEFAULT_MAX_BATCH_SIZE=$(parse_default_max_batch_size "${RESULT_LOG_LINE}")
92109

93110
if [ "$RESOLVED_DEFAULT_MAX_BATCH_SIZE" != "4" ]; then
94111
echo "*** FAILED: Found default-max-batch-size not equal to the expected default-max-batch-size. Expected: default-max-batch-size,4, Found: $RESOLVED_DEFAULT_MAX_BATCH_SIZE \n"
@@ -117,7 +134,7 @@ for ((i=0; i < ${#POSITIVE_TEST_ARGS[@]}; i++)); do
117134
if [ "$RESULT_LOG_LINE" != "" ]; then
118135

119136
# Pick out the logged value of the default-max-batch-size which gets passed into model creation
120-
RESOLVED_DEFAULT_MAX_BATCH_SIZE=$(awk -v line="$RESULT_LOG_LINE" 'BEGIN {split(line, a, "]"); split(a[2], b, ": "); split(b[2], c, ","); print c[2]}')
137+
RESOLVED_DEFAULT_MAX_BATCH_SIZE=$(parse_default_max_batch_size "${RESULT_LOG_LINE}")
121138

122139
if [ "$RESOLVED_DEFAULT_MAX_BATCH_SIZE" != "${POSITIVE_TEST_ANSWERS[$i]}" ]; then
123140
echo "*** FAILED: Found default-max-batch-size not equal to the expected default-max-batch-size. Expected: ${POSITIVE_TEST_ANSWERS[$i]}, Found: $RESOLVED_DEFAULT_MAX_BATCH_SIZE \n"
@@ -330,8 +347,8 @@ if [ "$SERVER_PID" == "0" ]; then
330347

331348
else
332349
# Count number of default configs
333-
BACKEND_CONFIG_MAP=$(grep -a "backend configuration:" $SERVER_LOG -A 1 | grep -v "backend configuration")
334-
DEFAULT_CONFIG_COUNT=$(echo $BACKEND_CONFIG_MAP | jq -r | jq '.["cmdline"]' | jq 'length')
350+
BACKEND_CONFIG_MAP=$(get_config_map $SERVER_LOG)
351+
DEFAULT_CONFIG_COUNT=$(echo $BACKEND_CONFIG_MAP | jq -r | jq '.["cmdline"]' | jq length)
335352
if [ $DEFAULT_CONFIG_COUNT -lt 4 ]; then
336353
echo "*** FAILED: Expected number of default configs to be at least 4 but found: $DEFAULT_CONFIG_COUNT\n"
337354
RET=1
@@ -361,7 +378,7 @@ if [ "$SERVER_PID" == "0" ]; then
361378

362379
else
363380
# Count number of default configs
364-
BACKEND_CONFIG_MAP=$(grep -a "backend configuration:" $SERVER_LOG -A 1 | grep -v "backend configuration")
381+
BACKEND_CONFIG_MAP=$(get_config_map $SERVER_LOG)
365382
CONFIG_VALUE=$(echo $BACKEND_CONFIG_MAP | jq -r | jq '.["cmdline"]' | jq -r '.["min-compute-capability"]')
366383

367384
if [ $CONFIG_VALUE != $MIN_COMPUTE_CAPABILITY ]; then
@@ -385,7 +402,7 @@ if [ "$SERVER_PID" == "0" ]; then
385402

386403
else
387404
# Count number of default configs
388-
BACKEND_CONFIG_MAP=$(grep -a "backend configuration:" $SERVER_LOG -A 1 | grep -v "backend configuration")
405+
BACKEND_CONFIG_MAP=$(get_config_map $SERVER_LOG)
389406
TOTAL_CONFIG_COUNT=$(echo $BACKEND_CONFIG_MAP | jq -r | jq '.["cmdline"]' | jq 'length')
390407

391408
if [ $TOTAL_CONFIG_COUNT -ne $EXPECTED_CONFIG_COUNT ]; then

0 commit comments

Comments
 (0)