A
A
Alexander Vladimirovich2022-02-17 15:00:45
MongoDB
Alexander Vladimirovich, 2022-02-17 15:00:45

How to view query log for mongodb running in docker?

Greetings!
Have mongodb running in docker
docker-compose.yml

version: '3.1'

services:

  mongo:
    image: mongo
    network_mode: bridge
    ports:
      - 27017:27017
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: myUserAdmin
      MONGO_INITDB_ROOT_PASSWORD: myUserAdmin


how to see the request that is currently being executed to the database?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim, 2022-02-17
@Viji

Change Dockerfile for Mongo and run it as recommended - https://stackoverflow.com/questions/15204341/mongo...
mongod --profile=1 --slowms=1 &
log will be saved to /var/log/mongodb/ mongodb.log Go
to the mongo container and see...

A
Alexander Karabanov, 2022-02-17
@karabanov

In the mongo config, specify the path to the log /proc/self/fd/2(probably you can configure it on the fly with some kind of request or pass it as a command line argument, I can’t say for sure I’m not familiar with mongo), then you can watch the logs docker logs -f container_nameor docker-compose logs -f service_name
It should work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question