Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
${{ secrets.PUBLIC_ECR_REGISTRY }}/storedog/auth
${{ secrets.PUBLIC_ECR_REGISTRY }}/storedog/nginx
${{ secrets.PUBLIC_ECR_REGISTRY }}/storedog/frontend
${{ secrets.PUBLIC_ECR_REGISTRY }}/storedog/dbm
)

for i in "${IMAGES[@]}"
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,30 @@ For example: Turning `cart` off will disable Cart capabilities.
- Turn `wishlist` on by setting `wishlist` to `true`.
- Run the app and the wishlist functionality should be back on.

#### How to run the DBM backend to test the Database Monitoring in the product and incrementally improve for the workshop

- complete the startup steps up under Local Development to number 3
- in `services/frontend/site/featureFlags.config.json` find the object with `name:dbm` and set `active:true`
- run `docker-compose --profile dbm up -d`
- once all the containers are up, run `docker exec storedog-postgres-1 ./dbm_exec.sh` this will add a few things we need for dbm to the database
- run `docker restart storedog-postgres-1` to restart the postgres container

You should now see your logs in DBM!

Once the metrics are showing in DBM, direct the users to the `dbm.py` file in `services/dbm/dbm.py`.

Have them update the query to change the 2 `{random.randint(1, 7000)}` to `{random.randint(5000, 7000)}` so only the most popular items show in the ticker.

Then explain that preorder items get marked as false or `f` in the table once they are now regular items. Say that best practice would be to update the `items` table to include the items marked `f`. Now we will update the query to the following to only look at the `items` table.

```sql
SELECT *
FROM items
WHERE order_count::int > {random.randint(5000, 7000)}
```

This will greatly reduce the amount of cost per query

## Troubleshoot

<details>
Expand Down
29 changes: 27 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
command: yarn dev
depends_on:
- worker
- dd-agent
volumes:
- "./services/frontend/site:/storedog-app/site"
ports:
Expand All @@ -20,27 +21,36 @@ services:
- "80:80"
depends_on:
- frontend
- dd-agent
labels:
com.datadoghq.ad.logs: '[{"source": "nginx", "service": "nginx"}]'
networks:
- storedog-net
postgres:
image: postgres:13-alpine
restart: always
depends_on:
- dd-agent
environment:
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- 'postgres:/var/lib/postgresql/data'
- ./services/backend/db/restore:/docker-entrypoint-initdb.d
- ./services/backend/db/postgresql.conf:/postgresql.conf
- ./services/dbm/dbm_setup.sql:/etc/postgresql/13/main/dbm_setup.sql
- ./services/dbm/dbm_exec.sh:/dbm_exec.sh
labels:
com.datadoghq.ad.check_names: '["postgres"]'
com.datadoghq.ad.init_configs: '[{}]'
com.datadoghq.ad.instances: '[{"host":"%%host%%", "port":5432,"username":"datadog","password":"datadog"}]'
com.datadoghq.ad.logs: '[{"source":"postgresql","service":"postgresql"}]'
command: ["postgres", "-c", "config_file=/postgresql.conf"]
networks:
- storedog-net
redis:
image: redis:6.2-alpine
depends_on:
- dd-agent
volumes:
- 'redis:/data'
networks:
Expand All @@ -49,6 +59,7 @@ services:
depends_on:
- 'postgres'
- 'redis'
- 'dd-agent'
build:
context: ./services/backend
ports:
Expand All @@ -63,13 +74,15 @@ services:
DB_PORT: 5432
DISABLE_SPRING: 1
DD_APPSEC_ENABLED: 1
DD_AGENT_HOST: 172.43.0.1
networks:
- storedog-net
worker:
depends_on:
- 'postgres'
- 'redis'
- 'web'
- 'dd-agent'
build:
context: ./services/backend
command: bundle exec sidekiq -C config/sidekiq.yml
Expand All @@ -83,11 +96,13 @@ services:
DB_PORT: 5432
DISABLE_SPRING: 1
DD_APPSEC_ENABLED: 1
DD_AGENT_HOST: 172.43.0.1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the solve for the tcp connection errors

agent status output after fixes
==========
Logs Agent
==========
    Reliable: Sending compressed logs in HTTPS to agent-http-intake.logs.datadoghq.com on port 443
    BytesSent: 642355
    EncodedBytesSent: 92185
    LogsProcessed: 651
    LogsSent: 759

  container_collect_all
  ---------------------
    - Type: docker
      Service: storedog-dbm
      Source: storedog-dbm
      Status: OK
      Inputs:
        38867147581eff5f9db8b8ac550861b5fa9091e2dc281d1348654924b272871b
      Bytes Read: 531
      Pipeline Latency:
        Average Latency (ms): 0
        24h Average Latency (ms): 0
        Peak Latency (ms): 0
        24h Peak Latency (ms): 0
    - Type: docker
      Service: redis
      Source: redis
      Status: OK
      Inputs:
        806e394bca692eb253365cd5948b776042e29b453c66df9edaf5692b5de8527a
      Bytes Read: 1400
      Pipeline Latency:
        Average Latency (ms): 0
        24h Average Latency (ms): 0
        Peak Latency (ms): 0
        24h Peak Latency (ms): 0
    - Type: docker
      Service: agent
      Source: agent
      Status: OK
      Inputs:
        d11e307af8e186922804c9168986d5a0b62d70328b70a33cea75ab4ec6cbb2c8
      Bytes Read: 77443
      Pipeline Latency:
        Average Latency (ms): 0
        24h Average Latency (ms): 0
        Peak Latency (ms): 3
        24h Peak Latency (ms): 3
    - Type: docker
      Service: storedog-frontend
      Source: storedog-frontend
      Status: OK
        The log file tailer could not be made, falling back to socket
      Inputs:
        1d66a2f080dbcac5776c004923b5ae4c2ff5a92b2c0e359d435a9a39d471b55f
      Bytes Read: 9325
      Pipeline Latency:
        Average Latency (ms): 0
        24h Average Latency (ms): 0
        Peak Latency (ms): 0
        24h Peak Latency (ms): 0
    - Type: docker
      Service: storedog-worker
      Source: storedog-worker
      Status: OK
      Inputs:
        e1219a669848bba7dbe27f9c17288fab3e456ccf94c388ebe9de66f6ffc076e8
      Bytes Read: 0
      Pipeline Latency:
        Average Latency (ms): 0
        24h Average Latency (ms): 0
        Peak Latency (ms): 0
        24h Peak Latency (ms): 0
    - Type: docker
      Service: storedog-web
      Source: storedog-web
      Status: OK
      Inputs:
        0b952a80bbb217232e3f3bcc41ed592b1cf5323762645abd2c539a3174fb5807
      Bytes Read: 0
      Pipeline Latency:
        Average Latency (ms): 0
        24h Average Latency (ms): 0
        Peak Latency (ms): 0
        24h Peak Latency (ms): 0

  docker
  ------
    - Type: docker
      Service: discounts
      Source: python
      Status: OK
      Inputs:
        5e58af55aee69b932391d25a298b957144fcfe3720db2b790823e7f55995fcd2
      Bytes Read: 1616
      Pipeline Latency:
        Average Latency (ms): 0
        24h Average Latency (ms): 0
        Peak Latency (ms): 0
        24h Peak Latency (ms): 0
    - Type: docker
      Service: postgresql
      Source: postgresql
      Status: OK
      Inputs:
        5f5962c945c3285ef0abe4378ea02fa58897ae1fc1afafa66661ce62a754683f
      Bytes Read: 494
      Pipeline Latency:
        Average Latency (ms): 0
        24h Average Latency (ms): 0
        Peak Latency (ms): 0
        24h Peak Latency (ms): 0
    - Type: docker
      Service: ads
      Source: python
      Status: OK
      Inputs:
        8bd2b5bc49b180f1263de39f459d07629ddca1f57a93c15b68508492b798548e
      Bytes Read: 1186
      Pipeline Latency:
        Average Latency (ms): 0
        24h Average Latency (ms): 0
        Peak Latency (ms): 0
        24h Peak Latency (ms): 0
    - Type: docker
      Service: ads-java
      Source: java
      Status: OK
      Inputs:
        f45d6e533f4188c829b4e74d41ae499bfed0164532deedb91c6bc99d0fa1148c
      Bytes Read: 4503
      Pipeline Latency:
        Average Latency (ms): 0
        24h Average Latency (ms): 0
        Peak Latency (ms): 0
        24h Peak Latency (ms): 0
    - Type: docker
      Service: nginx
      Source: nginx
      Status: OK
      Inputs:
        44f125a1980489581ae12d3128e10c84ed450f01d64e64a1482780306c6aae4f
      Bytes Read: 0
      Pipeline Latency:
        Average Latency (ms): 0
        24h Average Latency (ms): 0
        Peak Latency (ms): 0
        24h Peak Latency (ms): 0

networks:
- storedog-net
ads:
depends_on:
- postgres
- dd-agent
environment:
- FLASK_APP=ads.py
- FLASK_DEBUG=1
Expand Down Expand Up @@ -116,6 +131,7 @@ services:
discounts:
depends_on:
- postgres
- dd-agent
environment:
- FLASK_APP=discounts.py
- FLASK_DEBUG=1
Expand Down Expand Up @@ -145,6 +161,7 @@ services:
auth:
depends_on:
- postgres
- dd-agent
profiles:
- csrf
environment:
Expand All @@ -171,6 +188,7 @@ services:
dbm:
depends_on:
- postgres
- dd-agent
profiles:
- dbm
environment:
Expand Down Expand Up @@ -201,19 +219,25 @@ services:
- DD_APM_ENABLED=true
- DD_APM_NON_LOCAL_TRAFFIC=true
- DD_LOGS_ENABLED=true
- DD_HOSTNAME=172.43.0.4
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be set to make sure we are able to send logs into the agent since by default it uses localhost

- DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
- DD_CONTAINER_EXCLUDE="name:datadog-agent"
- DD_CONTAINER_EXCLUDE=name datadog-agent
- DD_HOSTNAME_TRUST_UTS_NAMESPACE=true
ports:
- "8126:8126"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /proc/:/host/proc/:ro
- /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
- ./services/backend/db/dd-agent-conf.yaml:/conf.d/postgres.d/conf.yaml
networks:
- storedog-net
storedog-net:
ipv4_address: 172.43.0.4
Comment on lines +234 to +235
Copy link
Contributor Author

@devindford devindford Apr 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting a static IP for the agent so it doesn't change

ads-java:
build:
context: ./services/ads/java
depends_on:
- dd-agent
environment:
- DD_SERVICE=ads-java
- DD_AGENT_HOST=dd-agent
Expand Down Expand Up @@ -243,6 +267,7 @@ services:
depends_on:
- web
- discounts
- dd-agent
networks:
- storedog-net

Expand Down
Loading