Hey all :slightly_smiling_face: I’m interested in ...
# orm-help
h
Hey all 🙂 I’m interested in monitoring my local Docker DB a bit, in order to see how many DB hits my different resolvers create. How would I go about that?
👍 2
d
There are plenty of monitoring solutions for most databases. Overview from the official postgres wiki, for example: https://wiki.postgresql.org/wiki/Monitoring
h
Thanks 🙂 Using MySQL fwiw. I’ve tried connecting MySQL Workbench to 127.0.0.1:3306 with
root
and
prisma
, but it says it can’t connect
d
I don’t recall if the default docker compose the CLI generates maps the DB to a local port. Look at
docker ps
if the port is mapped.
j
It should. At least for PG. I'm using pgadmin4 on my PGdb started with default docker-compose from Prisma cli.
👍 1
h
It says so, at least.
docker ps
produces
Copy code
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS                    NAMES
6cd22fda6974        prismagraphql/prisma:1.8   "/bin/sh -c /app/sta…"   2 weeks ago         Up 3 hours          0.0.0.0:4466->4466/tcp   database_prisma_1
93955422979c        mysql:5.7                  "docker-entrypoint.s…"   2 weeks ago         Up 3 hours          3306/tcp                 database_mysql_1
shit, formatting went wrong, sorry - but the DB says
3306/tcp
under PORTS
So in my mind, I should be able to connect to it using MySQL Workbench on Hostname
127.0.0.1
and Port:
3306
with username
root
and password
prisma
(according to the config), but it says “Failed to connect”
d
No, the DB is not mapped. the container port 3306 is bound, but not mapped, meaning you can access the container on that port via the docker internal network. Mapped would look like the prisma container
<...>:3306->3306
j
Under ports in you docker-compose:mysql you might've forgotten to do "3306:3306", and just "3306". The extra one is needed to bind outside the container. Like @dpetrick mentioned.
h
Ah, I see, that makes sense. How would I do that? I pretty much just used Prisma’s getting started config:
Copy code
version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.8
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: mysql
            host: mysql
            port: 3306
            user: root
            password: prisma
            migrations: true
  mysql:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: prisma
    volumes:
      - mysql:/var/lib/mysql
volumes:
  mysql:
d
Copy code
mysql:
    image: mysql:5.7
    restart: always
    ports:
    - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: prisma
    volumes:
      - mysql:/var/lib/mysql
👍 1
j
Copy code
version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.8
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: mysql
            host: mysql
            port: 3306
            user: root
            password: prisma
            migrations: true
  mysql:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: prisma
    volumes:
      - mysql:/var/lib/mysql
    ports:
      - "3306:3306"
volumes:
  mysql:
I think!
Dang @dpetrick beat me to it...
h
Thanks guys, it seems to work! 🙂
j
Gucci! Happy hacking! 🙂
gucci 1
h
Bonus question 😄 I can successfully connect using the workbench, and can see performance stats and a dashboard - nice! If I want to log exactly which SQL queries are run and inspect them, how would I go about that?
Found this https://stackoverflow.com/a/26618099/1409779 but that pane seems to only log queries performed from Workbench itself, not on the DB in general
j
There should probably be something you can toggle to have the MySQL daemon (running in the container) to log all requests. I detest Oracle, so I won't use it myself, but I know said feature exists for PostgreSQL.