Mention container name in logs.
Closed this issue · 4 comments
gsavelev commented
Is it possible to add container name, from which the message is coming, to log message?
sklyar commented
Yes, it's possible. You can add the "container_name" varibale to the log template option. For example:
docker run --log-driver=telegram \
--log-opt token="<bot_token>" \
--log-opt chat_id="<chat_id>" \
--log-opt template="{container_name}: {log}"
Also, check out other tags for additional options.
gsavelev commented
@sklyar, could you please give correct example of using template
directive in compose.yml?
sklyar commented
@gsavelev, I apologize for the mistake in my previous response. The correct format for the template directive should indeed use single curly braces and no dot. I will update the documentation accordingly.
To add the container name to the log message using Docker Compose, you can use the following configuration:
version: '3.8'
services:
my_service:
image: your/image
logging:
driver: telegram
options:
token: "<bot_token>"
chat_id: "<chat_id>"
template: "{container_name}: {log}"
gsavelev commented
Now it works properly well!
Thank you for such a useful plugin ✨