Skip to content

Conversation

@DaMandal0rian
Copy link
Contributor

@DaMandal0rian DaMandal0rian commented Feb 21, 2025

User description

Since logging instance and VM are running same machine, change the grafana instance to use a different port.


PR Type

Enhancement


Description

  • Changed Grafana instance port from 3000 to 3300.

  • Updated docker-compose.yml to reflect the new port configuration.

  • Added a new grafana.ini file for explicit port configuration.


Changes walkthrough 📝

Relevant files
Enhancement
docker-compose.yml
Update Grafana port and related configurations                     

logging/victoriametrics/deployment/docker/docker-compose.yml

  • Changed Grafana port mapping from 3000 to 3300.
  • Updated Traefik labels to use the new port.
  • Modified external URL references to reflect the new port.
  • Added a volume mapping for grafana.ini.
  • +4/-3     
    grafana.ini
    Add Grafana configuration file for port setup                       

    logging/victoriametrics/deployment/docker/grafana.ini

  • Added a new configuration file for Grafana.
  • Explicitly set the HTTP server port to 3300.
  • +2/-0     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @github-actions
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Port Configuration Consistency

    Ensure that the new port configuration (3300) is consistently applied across all relevant services and does not conflict with other services running on the same machine.

      ports:
        - 3300:3300
      volumes:
        - grafanadata:/var/lib/grafana
        - ./provisioning/datasources/prometheus-datasource/single.yml:/etc/grafana/provisioning/datasources/single.yml
        - ./provisioning/dashboards:/etc/grafana/provisioning/dashboards
        - ./../../dashboards/victoriametrics.json:/var/lib/grafana/dashboards/vm.json
        - ./../../dashboards/vmagent.json:/var/lib/grafana/dashboards/vmagent.json
        - ./../../dashboards/vmalert.json:/var/lib/grafana/dashboards/vmalert.json
        - ./grafana.ini:/etc/grafana/grafana.ini
      restart: always
      labels:
        - traefik.enable=true
        - traefik.http.services.grafanavm.loadbalancer.server.port=3300
        - traefik.http.routers.grafanavm.rule=Host(`grafana.vmetrics.subspace.network`)
        - traefik.http.routers.grafanavm.tls.certresolver=le
        - traefik.http.routers.grafanavm.entrypoints=websecure
        - traefik.docker.network=traefik-proxy
      networks:
        - vm_net
        - traefik-proxy
    
    # vmalert executes alerting and recording rules
    vmalert:
      container_name: vmalert
      image: victoriametrics/vmalert:v1.111.0
      depends_on:
        - "victoriametrics"
        - "alertmanager"
      ports:
        - 8880:8880
      volumes:
        - ./rules/alerts.yml:/etc/alerts/alerts.yml
        - ./rules/alerts-health.yml:/etc/alerts/alerts-health.yml
        - ./rules/alerts-vmagent.yml:/etc/alerts/alerts-vmagent.yml
        - ./rules/alerts-vmalert.yml:/etc/alerts/alerts-vmalert.yml
      command:
        - "--datasource.url=http://victoriametrics:8428/"
        - "--remoteRead.url=http://victoriametrics:8428/"
        - "--remoteWrite.url=http://vmagent:8429/"
        - "--notifier.url=http://alertmanager:9093/"
        - "--rule=/etc/alerts/*.yml"
        # display source of alerts in grafana
        - "--external.url=http://127.0.0.1:3300" #grafana outside container
        - '--external.alert.source=explore?orgId=1&left={"datasource":"VictoriaMetrics","queries":[{"expr":{{.Expr|jsonEscape|queryEscape}},"refId":"A"}],"range":{"from":"{{ .ActiveAt.UnixMilli }}","to":"now"}}'
    Explicit Port Configuration

    Verify that the explicit port configuration in grafana.ini aligns with the changes made in docker-compose.yml and is correctly loaded by the Grafana instance.

    [server]
    http_port = 3300  # Change this to your desired port

    @github-actions
    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Ensure Traefik port matches Grafana

    Confirm that the Traefik configuration for
    traefik.http.services.grafanavm.loadbalancer.server.port matches the updated Grafana
    port to prevent routing issues.

    logging/victoriametrics/deployment/docker/docker-compose.yml [76]

    -- traefik.http.services.grafanavm.loadbalancer.server.port=3300
    +- traefik.http.services.grafanavm.loadbalancer.server.port=3300 # Ensure consistency with Grafana port
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion to confirm consistency between Traefik's configuration and the updated Grafana port is valid and helps prevent routing issues. Adding a comment improves clarity and maintainability.

    Medium
    General
    Verify the new port avoids conflicts

    Ensure that the new port 3300 does not conflict with any other services running on
    the host machine to avoid potential port binding issues.

    logging/victoriametrics/deployment/docker/docker-compose.yml [64]

    -- 3300:3300
    +- 3300:3300 # Ensure no port conflicts
    Suggestion importance[1-10]: 6

    __

    Why: While the suggestion to ensure no port conflicts is valid and important, it is not actionable in the code itself but rather a verification step. Adding a comment about port conflicts is a minor improvement for clarity.

    Low
    Verify external URL reflects changes

    Verify that the --external.url parameter in the configuration correctly reflects the
    updated Grafana port to ensure proper external access.

    logging/victoriametrics/deployment/docker/docker-compose.yml [106]

    -- "--external.url=http://127.0.0.1:3300" #grafana outside container
    +- "--external.url=http://127.0.0.1:3300" # Ensure this matches the updated Grafana port
    Suggestion importance[1-10]: 6

    __

    Why: The suggestion to verify the --external.url parameter is consistent with the updated Grafana port is valid. However, it is more of a verification step, and the added comment provides only a minor improvement to the code.

    Low

    @DaMandal0rian DaMandal0rian merged commit 148d161 into main Feb 21, 2025
    1 check passed
    @DaMandal0rian DaMandal0rian deleted the change-vmetrics-grafana-port branch February 21, 2025 12:28
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    3 participants