Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(localnet) - add localnet log aggregation tool #4758

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

mur-me
Copy link
Collaborator

@mur-me mur-me commented Sep 16, 2024

Issue

I've covered localnet deployment with the same tool set as higher networks - Promtail-Loki-Grafana.

image

What was done:

  • 3 Makefile commands to start and stop log aggregation - debug-start-log and debug-stop-log, debug-restart-log
  • these 2 new Makefile are just are wrappers between our localnet logs location, promtail-grafana-loki configs and the docker-compose file
  • WARNING - grafana runs in the anon access, just in case - DON'T RUN IT AGAINST PRODUCTION

Details:

  • test/logs_aggregator/start_log_aggregator.sh
  • go to test/logs_aggregator/ folder
  • find the current localnet logs folder
  • put it inside .env file in test/logs_aggregator/.env
  • this test/logs_aggregator/.env is a source of variables for docker-compose
  • start docker-compose detached
  • open the Grafana in browser
  • test/logs_aggregator/stop_log_aggregator.sh
    • just cleanup the test/logs_aggregator/.env
    • stop and remove docker compose

Test

Local run:

  • make debug-start-log
bash ./test/logs_aggregator/start_log_aggregator.sh
working in /home/uladzislau/go/src/github.com/harmony-one/harmony/test/logs_aggregator
/home/uladzislau/go/src/github.com/harmony-one/harmony/test/logs_aggregator
Current localnet logs are placed into '/home/uladzislau/go/src/github.com/harmony-one/harmony/tmp_log/log-20240916-175304'
CURRENT_SESSION_LOGS='/home/uladzislau/go/src/github.com/harmony-one/harmony/tmp_log/log-20240916-175304'
starting docker compose lor log aggregation
[+] Running 3/3
 ✔ Container logs_aggregator-promtail-1  Started                                                                                              1.2s 
 ✔ Container logs_aggregator-loki-1      Started                                                                                              1.2s 
 ✔ Container logs_aggregator-grafana-1   Started                                                                                              1.3s 
Opening Grafana
  • make debug-stop-log
working in /home/uladzislau/go/src/github.com/harmony-one/harmony/test/logs_aggregator
/home/uladzislau/go/src/github.com/harmony-one/harmony/test/logs_aggregator
[INFO] - stopping log aggregation
[+] Stopping 3/3
 ✔ Container logs_aggregator-loki-1      Stopped                                                                                              2.6s 
 ✔ Container logs_aggregator-promtail-1  Stopped                                                                                              0.6s 
 ✔ Container logs_aggregator-grafana-1   Stopped                                                                                              0.6s 
Going to remove logs_aggregator-promtail-1, logs_aggregator-grafana-1, logs_aggregator-loki-1
[+] Removing 3/0
 ✔ Container logs_aggregator-promtail-1  Removed                                                                                              0.0s 
 ✔ Container logs_aggregator-grafana-1   Removed                                                                                              0.0s 
 ✔ Container logs_aggregator-loki-1      Removed                                                                                              0.0s 
[INFO] - cleanup .env
  • make debug-stop-log-aggregator against already stopped/not-started localnet it will be failure

  • make debug-start-log-aggregator against not-started localnet it will be failure

  • make debug-restart-log:

bash ./test/logs_aggregator/stop_log_aggregator.sh
working in /home/uladzislau/go/src/github.com/harmony-one/harmony/test/logs_aggregator
/home/uladzislau/go/src/github.com/harmony-one/harmony/test/logs_aggregator
[INFO] - stopping log aggregation
[+] Stopping 3/3
 ✔ Container localnet-promtail  Stopped                                                                                                       0.6s 
 ✔ Container localnet-grafana   Stopped                                                                                                       0.6s 
 ✔ Container localnet-loki      Stopped                                                                                                       1.8s 
Going to remove localnet-grafana, localnet-promtail, localnet-loki
[+] Removing 3/0
 ✔ Container localnet-loki      Removed                                                                                                       0.1s 
 ✔ Container localnet-grafana   Removed                                                                                                       0.1s 
 ✔ Container localnet-promtail  Removed                                                                                                       0.1s 
[INFO] - cleanup .env
bash ./test/logs_aggregator/start_log_aggregator.sh
working in /home/uladzislau/go/src/github.com/harmony-one/harmony/test/logs_aggregator
/home/uladzislau/go/src/github.com/harmony-one/harmony/test/logs_aggregator
Current localnet logs are placed into '/home/uladzislau/go/src/github.com/harmony-one/harmony/tmp_log/log-20240920-122014'
CURRENT_SESSION_LOGS='/home/uladzislau/go/src/github.com/harmony-one/harmony/tmp_log/log-20240920-122014'
starting docker compose lor log aggregation
[+] Running 3/3
 ✔ Container localnet-loki      Started                                                                                                       0.6s 
 ✔ Container localnet-grafana   Started                                                                                                       0.7s 
 ✔ Container localnet-promtail  Started                                                                                                       0.5s 
Opening Grafana

Unit Test Coverage

Before:

<!-- copy/paste 'go test -cover' result in the directory you made change -->

After:

<!-- copy/paste 'go test -cover' result in the directory you made change -->

Test/Run Logs

Operational Checklist

  1. Does this PR introduce backward-incompatible changes to the on-disk data structure and/or the over-the-wire protocol?. (If no, skip to question 8.)

    YES|NO

  2. Describe the migration plan.. For each flag epoch, describe what changes take place at the flag epoch, the anticipated interactions between upgraded/non-upgraded nodes, and any special operational considerations for the migration.

  3. Describe how the plan was tested.

  4. How much minimum baking period after the last flag epoch should we allow on Pangaea before promotion onto mainnet?

  5. What are the planned flag epoch numbers and their ETAs on Pangaea?

  6. What are the planned flag epoch numbers and their ETAs on mainnet?

    Note that this must be enough to cover baking period on Pangaea.

  7. What should node operators know about this planned change?

  8. Does this PR introduce backward-incompatible changes NOT related to on-disk data structure and/or over-the-wire protocol? (If no, continue to question 11.)

    YES|NO

  9. Does the existing node.sh continue to work with this change?

  10. What should node operators know about this change?

  11. Does this PR introduce significant changes to the operational requirements of the node software, such as >20% increase in CPU, memory, and/or disk usage?

TODO

@mur-me mur-me self-assigned this Sep 16, 2024
@mur-me mur-me mentioned this pull request Sep 18, 2024
@sophoah
Copy link
Contributor

sophoah commented Sep 20, 2024

hey @mur-me good job on this. I made a few comments, please address. Additionally, I've managed to run the stack with my localnet !

@sophoah
Copy link
Contributor

sophoah commented Sep 20, 2024

hey @GheisMohammadi @Frozen please test the stack, this PR is for you guys

@mur-me
Copy link
Collaborator Author

mur-me commented Sep 20, 2024

hey @mur-me good job on this. I made a few comments, please address. Additionally, I've managed to run the stack with my localnet !

Addressed all the comments, added a few improvements like restart and anon accces to the grafana

@mur-me mur-me requested a review from sophoah September 20, 2024 09:41
…nymus access - it will directly open explore page now, add log commands to the help
@mur-me mur-me force-pushed the feature/add_localnet_log_aggregation branch from 8adf4b6 to 432dc20 Compare September 20, 2024 11:26
@sophoah sophoah changed the title feat(localnet) - add localnet log aggregation with Promtail-Loki-Grafana feat(localnet) - add localnet log aggregation tool Sep 23, 2024
@mur-me mur-me requested a review from sophoah September 23, 2024 10:56
@sophoah sophoah merged commit 797511c into dev Sep 24, 2024
4 checks passed
@sophoah sophoah deleted the feature/add_localnet_log_aggregation branch September 24, 2024 04:09
@sophoah sophoah mentioned this pull request Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants