Azure / azure-cli

Azure Command-Line Interface
MIT License
4.02k stars 3k forks source link

Container Apps logs in follow mode exit after few seconds #28267

Open clemlesne opened 9 months ago

clemlesne commented 9 months ago

Describe the bug

When run, the command az containerapp logs show --follow exits after a few seconds. Thus, reading Container Apps logs from a terminal is extremely complicated.

Related command

az containerapp logs show --follow

Errors

No error. The process exit abruptly.

Issue script & Debug output

cli.azure.cli.command_modules.containerapp.custom: received raw log line: b'INFO:     127.0.0.1:59088 - "GET /health/liveness HTTP/1.1" 204 No Content'
INFO:     127.0.0.1:59088 - "GET /health/liveness HTTP/1.1" 204 No Content
cli.azure.cli.command_modules.containerapp.custom: received raw log line: b'INFO:     100.100.0.167:43568 - "GET / HTTP/1.1" 404 Not Found'
INFO:     100.100.0.167:43568 - "GET / HTTP/1.1" 404 Not Found
cli.azure.cli.command_modules.containerapp.custom: received raw log line: b'INFO:     127.0.0.1:58006 - "GET /health/liveness HTTP/1.1" 204 No Content'
INFO:     127.0.0.1:58006 - "GET /health/liveness HTTP/1.1" 204 No Content
cli.azure.cli.command_modules.containerapp.custom: received raw log line: b'INFO:     127.0.0.1:51088 - "GET /health/liveness HTTP/1.1" 204 No Content'
INFO:     127.0.0.1:51088 - "GET /health/liveness HTTP/1.1" 204 No Content
cli.azure.cli.command_modules.containerapp.custom: received raw log line: b'INFO:main:Answered call with XXX (4d1f5e00-5bc3-45b5-8632-c32ba52bd98d)'
INFO:main:Answered call with XXX (4d1f5e00-5bc3-45b5-8632-c32ba52bd98d)
cli.azure.cli.command_modules.containerapp.custom: received raw log line: b'INFO:     100.100.0.167:40640 - "POST /call/inbound HTTP/1.1" 200 OK'
INFO:     100.100.0.167:40640 - "POST /call/inbound HTTP/1.1" 200 OK
cli.knack.cli: Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0x1046c2ca0>, <function _x509_from_base64_to_hex_transform at 0x1046c2d40>]
cli.knack.cli: Event: CommandInvoker.OnFilterResult []
cli.knack.cli: Event: Cli.SuccessfulExecute []
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x104685300>]
az_command_data_logger: exit code: 0
cli.__main__: Command ran in 17.648 seconds (init: 0.178, invoke: 17.470)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3499 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/opt/homebrew/Cellar/azure-cli/2.56.0/libexec/bin/python /opt/homebrew/Cellar/azure-cli/2.56.0/libexec/lib/python3.11/site-packages/azure/cli/telemetry/__init__.py /Users/XXX/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.

Expected behaviour

Continue to read logs indefinitely.

Environment Summary

❯ az --version
azure-cli                         2.56.0

core                              2.56.0
telemetry                          1.1.0

Extensions:
aks-preview                      0.5.173
azure-devops                      0.26.0
communication                    1.8.0b1
containerapp                      0.3.46
load                               0.3.2
monitor-control-service               0.4.1

Dependencies:
msal                            1.24.0b2
azure-mgmt-resource             23.1.0b2

Python location '/opt/homebrew/Cellar/azure-cli/2.56.0/libexec/bin/python'
Extensions directory '/Users/XXX/.azure/cliextensions'

Python (Darwin) 3.11.7 (main, Dec  4 2023, 18:10:11) [Clang 15.0.0 (clang-1500.1.0.2.5)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 9 months ago

Thank you for opening this issue, we will look into it.

microsoft-github-policy-service[bot] commented 9 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @calvinsID.

Greedygre commented 9 months ago

Hi @clemlesne

I notice there is a message cli.__main__: Command ran in 17.648 seconds (init: 0.178, invoke: 17.470) in the debug log. The time is too short when using --follow, is the container in the containerapp restarting at that time?

On the other hand, az containerapp logs show: Show past logs and/or print logs in real time (with the --follow parameter). Note that the logs are only taken from one revision, replica, and container (for non-system logs).

It has Max connection open time, which is by designed.

We recommend you use log analytics to store and search logs.

Monitor logs in Azure Container Apps with Log Analytics | Microsoft Learn

Thanks