You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Monitoring containerized microservices with a centralized logging architecture.
3
+
A test project for learning microservices observability through: **centralized logging** and **distributed tracing**.
4
4
5
-
## Dependencies
5
+
## Requirements
6
6
7
7
- Docker Compose v1.23.2
8
+
- OSX or GNU/Linux operating system
8
9
9
-
## Setup
10
+
## Development Setup
10
11
11
-
1.Signup with an ELK SaaS provider like [Logz.io](logz.io) to obtain an authentication token. Then for each microservice, rename `example.env` to `.env` and supply the needed secrets.
12
+
1.Clone this repo and open the root folder in an IDE like *Visual Studio Code*.
12
13
13
-
2.Run the following commands.
14
+
2.For each microservice, rename `example.env` to `.env` and supply the needed secrets.
14
15
15
-
docker-compose build --pull
16
-
docker-compose up -d --force-recreate
17
-
18
-
3. Then log into your ELK SaaS and view your microservices logs.
16
+
3. Start all microservices in *development mode*.
17
+
18
+
docker-compose -f docker-compose.dev.yml \
19
+
up -d --build
20
+
21
+
> Development mode is important for 2 reasons.
22
+
> - Changes to a service's source files will automatically restart/rebuild the docker service to show the changes.
23
+
> - You can attach a remote debugger from your IDE to the docker process for seemless debugging like placing breakpoints and watching variables.
24
+
> - NOTE: When you edit a service's source files, the docker process will restart, severing your remote debugger connection. So, you'd need to reattach the debugger again.
25
+
26
+
4. Attach the IDE's debugger to the desired service. Follow these steps in Visual Studio Code: *shift+cmd+D > Select a debug configuration > F5*.
27
+
> All Visual Studio Code debug configurations are stored in *.vscode/launch.json*. You can modify configs as you see fit.
28
+
29
+
### Useful dev commands
30
+
31
+
# list all running services
32
+
docker-compose -f docker-compose.dev.yml ps
33
+
34
+
# stop all services
35
+
docker-compose -f docker-compose.dev.yml down
36
+
37
+
# restart only all [or specific] service
38
+
docker-compose -f docker-compose.dev.yml \
39
+
up -d --no-deps --build [service-name]
40
+
41
+
# tail logs from all [or specific] service
42
+
docker-compose logs -f [service-name]
43
+
44
+
## Production Setup
45
+
46
+
TODO
47
+
48
+
- Signup with an ELK SaaS provider like [Logz.io](logz.io) to obtain an authentication token. Then for each microservice, rename `example.env` to `.env` and supply the needed secrets.
49
+
- Then log into your ELK SaaS and view your microservices logs.
19
50
20
51
## Project Documentation
21
52
@@ -27,6 +58,16 @@ I wrote an accompanying [article](https://hackernoon.com/monitoring-containerize
27
58
28
59
## Notes
29
60
61
+
- You can update a single service/container while the entire suite is running using the following command
62
+
63
+
docker-compose -f docker-compose.dev.yml \
64
+
up -d --no-deps --build <service_name>
65
+
66
+
docker-compose -f docker-compose.prod.yml \
67
+
up -d --no-deps --build <service_name>
68
+
69
+
> `--build` recreates the container from its image/dockerfile and `--no-deps` ensures dependent services aren't affected.
70
+
30
71
### Docker Networking
31
72
32
73
By default each containerized process runs in an isolated network namespace. For inter-container communication, place them in the same network namespace...as seen in *docker-compose.yml*.
@@ -36,8 +77,21 @@ By default each containerized process runs in an isolated network namespace. For
36
77
1. You can pass secrets for a microservice using the `env_file` attribute in *docker-compose.yml*.
37
78
2. Microservices can communicate using their service names if they are in the same docker network.
38
79
80
+
### How do you debug an app running in a container (i.e breakpoints and watch variables etc.)?
81
+
?
82
+
- You can tail the logs from all services using `docker-compose [-f <file>] logs -f`.
83
+
39
84
### Improvement Considerations
40
85
41
86
1.**Name Duplication:** The value of the `API_SERVER_ADDRESS` variable in *user-simulator/.env* depends on the service name `api-server` specified in *docker-compose.yml*. If we rename the service, we must also change the variable. Is there a way to make this DRY?
42
87
43
-
2. In the log-shipper container, I had to install a logz.io-specific plugin. Can't this step be eliminated since fluentd is capable of connecting to https endpoints without plugins?
88
+
2. In the log-shipper container, I had to install a logz.io-specific plugin. Can't this step be eliminated since fluentd is capable of connecting to https endpoints without plugins?
89
+
90
+
3. Use sub-second precision for fluentd timestamps (probably best to use nanoseconds.)
0 commit comments