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

refactor: move localnet monitoring to profile #2574

Merged
merged 2 commits into from
Jul 29, 2024
Merged

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Jul 26, 2024

Description

Move monitoring stack to a profile. Now you can easily turn on monitoring with export COMPOSE_ARGS='--profile monitoring' for any docker compose job.

Also add loki and promtail to allow working with logs. Add a simple log dashboard to allow exploration:

image

Summary by CodeRabbit

  • New Features

    • Introduced enhanced Docker Compose configurations for local network setup, including new services: Grafana, Prometheus, ZetaChain Exporter, Loki, and Promtail.
    • Added a new Grafana dashboard for log browsing, with advanced filtering and visualization capabilities.
    • Implemented a new data source configuration for Loki in Grafana, allowing log queries alongside existing metrics.
  • Bug Fixes

    • Streamlined Docker Compose command usage by consolidating into a single variable, improving overall command management.

Copy link
Contributor

coderabbitai bot commented Jul 26, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Walkthrough

The recent changes enhance the Docker Compose setup and monitoring capabilities of the application. A new variable DOCKER_COMPOSE improves command flexibility, while several new services for monitoring, including Grafana and Prometheus, have been added to the Docker Compose configuration. Additionally, a new Grafana dashboard for log browsing has been introduced, along with configurations for Promtail to facilitate log scraping. These modifications streamline service management and bolster observability.

Changes

File Path Change Summary
Makefile Introduced DOCKER_COMPOSE variable for streamlined Docker Compose commands, removed monitoring service commands.
contrib/localnet/docker-compose.yml Added new services: grafana, prometheus, zetachain-exporter, loki, and promtail, enhancing monitoring setup.
contrib/localnet/grafana/dashboards/log_browser.json New file added to define a Grafana dashboard for dynamic log browsing with filtering capabilities.
contrib/localnet/grafana/datasource.yaml Added a new data source entry for Loki, enabling log querying alongside Prometheus metrics.
contrib/localnet/promtail/config.yaml New configuration for Promtail establishes log scraping from Docker and provides settings for log ingestion to Loki.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DockerCompose
    participant Grafana
    participant Prometheus
    participant Loki
    participant Promtail

    User->>DockerCompose: Start services
    DockerCompose->>Prometheus: Initialize metrics collection
    DockerCompose->>Loki: Initialize log storage
    DockerCompose->>Grafana: Setup dashboards
    DockerCompose->>Promtail: Configure log scraping

    Promtail->>Docker: Discover containers
    Promtail->>Loki: Push logs
    Grafana->>Prometheus: Query metrics
    Grafana->>Loki: Query logs
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gartnera gartnera requested a review from a team July 26, 2024 21:05
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (4)
contrib/localnet/docker-compose.yml (4)

314-329: Missing prometheus.yml configuration file

The prometheus service configuration in docker-compose.yml specifies a volume mount for ./prometheus/prometheus.yml, but this file is missing. Please ensure that the prometheus.yml file exists at the specified path and is correctly configured.

  • Ensure the prometheus.yml file is present at ./prometheus/prometheus.yml.
  • Verify the correctness of the prometheus.yml configuration to avoid runtime issues.
Analysis chain

Ensure proper volume mounting and dependency configuration for prometheus.

The prometheus service is configured correctly with the necessary volumes and dependencies. Verify that the prometheus.yml file exists in the specified path and is correctly configured.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and correctness of Prometheus configuration file.

# Test: Check if the prometheus.yml file exists. Expect: The file should exist.
test -f ./prometheus/prometheus.yml && echo "prometheus.yml exists" || echo "prometheus.yml missing"

Length of output: 92


295-313: Missing Grafana configuration files and directories

The datasource.yaml file and the dashboards directory specified in the grafana service configuration are missing. This will prevent the Grafana service from starting correctly. Please ensure the following:

  • Create the datasource.yaml file at ./grafana/datasource.yaml with the necessary datasource configurations.
  • Create the dashboards directory at ./grafana/dashboards and populate it with the required dashboard configuration files.

These steps are crucial for the proper functioning of the Grafana service.

Analysis chain

Ensure proper volume mounting and dependency configuration for grafana.

The grafana service is configured correctly with the necessary volumes, ports, and dependencies. Verify that the datasource.yaml and dashboard files exist in the specified paths and are correctly configured.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and correctness of Grafana configuration files.

# Test: Check if the datasource.yaml file exists. Expect: The file should exist.
test -f ./grafana/datasource.yaml && echo "datasource.yaml exists" || echo "datasource.yaml missing"

# Test: Check if the dashboards directory exists. Expect: The directory should exist.
test -d ./grafana/dashboards && echo "dashboards directory exists" || echo "dashboards directory missing"

Length of output: 190


369-383: Missing config.yaml file for promtail service

The config.yaml file required for the promtail service is missing from the specified path (./promtail/config.yaml). Please ensure that this configuration file is added to the correct location to allow the promtail service to function properly.

  • Ensure the config.yaml file is present at ./promtail/config.yaml.
  • Verify the contents of the config.yaml file to ensure it is correctly configured for Promtail.
Analysis chain

Ensure proper volume mounting and command configuration for promtail.

The promtail service is configured correctly with the necessary volumes and command. Verify that the config.yaml file exists in the specified path and is correctly configured.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and correctness of Promtail configuration file.

# Test: Check if the config.yaml file exists. Expect: The file should exist.
test -f ./promtail/config.yaml && echo "config.yaml exists" || echo "config.yaml missing"

Length of output: 81


330-355: Missing health check configurations for dependencies of zetachain-exporter.

The zetacore0 and eth services, which are dependencies for zetachain-exporter, are missing health check configurations. This is crucial for ensuring that these services are running properly before zetachain-exporter starts.

Please add appropriate health check configurations for the following services:

  • zetacore0
  • eth

This will ensure that the dependency conditions (service_healthy for zetacore0 and service_started for eth) are reliably met.

Analysis chain

Ensure proper environment variable configuration and dependency setup for zetachain-exporter.

The zetachain-exporter service is configured correctly with the necessary environment variables and dependencies. Verify that the environment variables are set correctly and the services it depends on are available.


Verify the dependencies and health check configurations for zetachain-exporter.

The environment variables for zetachain-exporter are correctly set. Now, verify that the dependencies (zetacore0 and eth) are properly defined and configured with the necessary health checks.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the environment variables for zetachain-exporter.

# Test: Check if the environment variables are set correctly. Expect: All variables should be set.
env_vars=("ETH_EVM_URL" "ZETA_EVM_URL" "ZETA_LCD_URL" "ZETA_TENDERMINT_URL" "ETH_CHAIN_ID" "ZETA_CHAIN_ID" "REFRESH_INTERVAL" "FAST_REFRESH_INTERVAL")
for var in "${env_vars[@]}"; do
  grep -q "$var" contrib/localnet/docker-compose.yml && echo "$var is set" || echo "$var is missing"
done

Length of output: 1316


Script:

#!/bin/bash
# Description: Verify the definitions and health check configurations for dependencies of zetachain-exporter.

# Test: Check if zetacore0 and eth services are defined and have health checks configured.
services=("zetacore0" "eth")
for service in "${services[@]}"; do
  echo "Checking service: $service"
  grep -A 10 "$service:" contrib/localnet/docker-compose.yml | grep -q "healthcheck" && echo "$service has health check configured" || echo "$service is missing health check configuration"
done

Length of output: 572

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 680cf6a and 8bac919.

Files selected for processing (5)
  • Makefile (4 hunks)
  • contrib/localnet/docker-compose.yml (1 hunks)
  • contrib/localnet/grafana/dashboards/log_browser.json (1 hunks)
  • contrib/localnet/grafana/datasource.yaml (1 hunks)
  • contrib/localnet/promtail/config.yaml (1 hunks)
Additional context used
yamllint
contrib/localnet/promtail/config.yaml

[error] 12-12: trailing spaces

(trailing-spaces)

contrib/localnet/grafana/datasource.yaml

[error] 20-20: no new line character at the end of file

(new-line-at-end-of-file)

Additional comments not posted (22)
contrib/localnet/promtail/config.yaml (4)

1-3: LGTM!

The server configuration for HTTP and gRPC ports is correctly set.


5-6: LGTM!

The positions configuration is correctly set to /tmp/positions.yaml.


8-9: LGTM!

The client URL for Loki is correctly set to http://loki:3100/loki/api/v1/push.


11-19: LGTM!

The scrape configuration for Docker containers is correctly set.

Tools
yamllint

[error] 12-12: trailing spaces

(trailing-spaces)

contrib/localnet/grafana/datasource.yaml (2)

Line range hint 1-16:
LGTM!

The Prometheus data source configuration remains unchanged and is correctly set.

Tools
yamllint

[error] 20-20: no new line character at the end of file

(new-line-at-end-of-file)


17-20: LGTM!

The Loki data source configuration is correctly set.

Tools
yamllint

[error] 20-20: no new line character at the end of file

(new-line-at-end-of-file)

contrib/localnet/grafana/dashboards/log_browser.json (7)

2-21: LGTM!

The annotations configuration is correctly set.


24-24: LGTM!

The description of the dashboard is clear and concise.


31-163: LGTM!

The panels configuration for Prometheus and Loki data sources is correctly set.


165-165: LGTM!

The refresh interval is correctly set to 5 seconds.


169-201: LGTM!

The templating configuration for Loki data sources is correctly set.


202-204: LGTM!

The time range is correctly set from now-30m to now.


208-208: LGTM!

The title of the dashboard is correctly set to Log Browser.

contrib/localnet/docker-compose.yml (2)

387-387: Ensure proper definition of volume grafana_storage.

The grafana_storage volume is defined correctly. Verify that it is used appropriately in the grafana service.


357-368: Ensure proper command configuration for loki.

The loki service is configured correctly with the necessary command. Verify that the local-config.yaml file exists in the specified path and is correctly configured.

Makefile (7)

7-9: Introduction of DOCKER_COMPOSE variable.

The DOCKER_COMPOSE variable is defined correctly and enhances flexibility by allowing additional arguments to be passed to Docker Compose.


215-215: Usage of DOCKER_COMPOSE variable in start-localnet-skip-build.

The DOCKER_COMPOSE variable is used correctly to start the localnet.


219-219: Usage of DOCKER_COMPOSE variable in stop-localnet.

The DOCKER_COMPOSE variable is used correctly to stop the localnet.


242-242: Usage of DOCKER_COMPOSE variable in start-e2e-test.

The DOCKER_COMPOSE variable is used correctly to start the e2e test.


247-247: Usage of DOCKER_COMPOSE variable in start-e2e-admin-test.

The DOCKER_COMPOSE variable is used correctly to start the e2e admin test.


252-252: Usage of DOCKER_COMPOSE variable in start-e2e-performance-test.

The DOCKER_COMPOSE variable is used correctly to start the e2e performance test.


296-296: Usage of DOCKER_COMPOSE variable in start-upgrade-test.

The DOCKER_COMPOSE variable is used correctly to start the upgrade test.

contrib/localnet/promtail/config.yaml Show resolved Hide resolved
contrib/localnet/grafana/datasource.yaml Show resolved Hide resolved
Copy link
Contributor

@morde08 morde08 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

LGTM

@lumtis lumtis added this pull request to the merge queue Jul 29, 2024
Merged via the queue into develop with commit 9faeb15 Jul 29, 2024
28 checks passed
@lumtis lumtis deleted the monitoring-profile branch July 29, 2024 09:58
gartnera added a commit that referenced this pull request Jul 31, 2024
gartnera added a commit that referenced this pull request Jul 31, 2024
* fix(ci): use static preparams for zetaclient by default (#2587)

* refactor: move localnet monitoring to profile (#2574)

Co-authored-by: Lucas Bertrand <[email protected]>

* fix(e2e): update performance test parameters and bump go-tss (#2563)

* fix(e2e): increase performance test timeouts

* bump go-tss

* fix(ci): remove job concurrency (#2595)

* ci: run on PRs to all base branches

---------

Co-authored-by: Lucas Bertrand <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Skip changelog CI check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants