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

[Bug]: Failed to manifest dashboard when modifying lib #555

Open
wilfriedroset opened this issue Jan 10, 2025 · 4 comments
Open

[Bug]: Failed to manifest dashboard when modifying lib #555

wilfriedroset opened this issue Jan 10, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@wilfriedroset
Copy link

wilfriedroset commented Jan 10, 2025

Grizzly Version

0.6.1

Expected Behavior

Dashboards manifestion works without error when any of the files in the watchList are modified.

Actual Behavior

Users might want to create reusable lib. As such they will start grizzly and watch several path. This is similar to what is documented here https://grafana.github.io/grizzly/server/, this is also what is done in [grafonnet examples(https://github.com/grafana/grafonnet/tree/main/examples/redMethod). Depending on what you are work on, user could edit either the dashboard itself or the underlying reusable lib.
However when grizzly detect a change in the underlying lib the manifestion fails

➜  reproducer docker compose up
[+] Running 2/0
 ✔ Container grafana  Created                                                                                                                                                                            0.0s
 ✔ Container grizzly  Recreated                                                                                                                                                                          0.1s
Attaching to grafana, grizzly
grafana  | logger=plugins.registration t=2025-01-10T13:22:54.913338607Z level=error msg="Could not register plugin" pluginId=xychart error="plugin xychart is already registered"
grafana  | logger=plugins.initialization t=2025-01-10T13:22:54.913475793Z level=error msg="Could not initialize plugin" pluginId=xychart error="plugin xychart is already registered"
grizzly  | level=info msg="[watcher] Watching for changes"
grizzly  | Listening on http://localhost:8080/
grizzly  | level=error msg="[watcher] Error: parse error in '/mnt/dashboards/examples/redMethod/lib/redDashboard/main.libsonnet': RUNTIME ERROR: couldn't manifest function as JSON\n\tField \"addApplication\"\t\n\tDuring manifestation\t\n"
grizzly  | level=warning msg="[watcher] error: parse error in '/mnt/dashboards/examples/redMethod/lib/redDashboard/main.libsonnet': RUNTIME ERROR: couldn't manifest function as JSON\n\tField \"addApplication\"\t\n\tDuring manifestation\t\n"
grizzly  | level=error msg="[watcher] Error: parse error in '/mnt/dashboards/examples/redMethod/lib/redDashboard/main.libsonnet': RUNTIME ERROR: couldn't manifest function as JSON\n\tField \"addApplication\"\t\n\tDuring manifestation\t\n"
grizzly  | level=warning msg="[watcher] error: parse error in '/mnt/dashboards/examples/redMethod/lib/redDashboard/main.libsonnet': RUNTIME ERROR: couldn't manifest function as JSON\n\tField \"addApplication\"\t\n\tDuring manifestation\t\n"

In this case, user could workaround the error by restarting grizzly at each change but it is cumbersome and make the watch feature less useful.

Steps to Reproduce

  1. git clone https://github.com/grafana/grafonnet /tmp/grafonnet
  2. cd /tmp/grafonnet/examples/redMethod && jb init
  3. start the stack as described in the docker-compose below
  4. Open grizzly on localhost:8080 (or equivalent)
  5. Browse the dashboard
  6. Modify /tmp/grafonnet/examples/redMethod/lib/redDashboard/main.libsonnet
---
services:
  grafana:
    image: grafana/grafana:11.4.0
    container_name: grafana
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_LOG_LEVEL=warning
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:3000/api/health"]
      interval: 5s
      retries: 5
      start_period: 1s
      timeout: 10s

  grizzly:
    image: grafana/grizzly:0.6.1
    container_name: grizzly
    volumes:
      # git clone https://github.com/grafana/grafonnet /tmp/grafonnet
      - /tmp/grafonnet:/mnt/dashboards
    ports:
      - 8080:8080
    command:
      - serve
      - -w
      - /mnt/dashboards/examples/redMethod/main.libsonnet
      - /mnt/dashboards/examples/redMethod
    environment:
      - GRAFANA_URL=http://grafana:3000
      - GRAFANA_USER=admin
      - GRAFANA_TOKEN=password
    depends_on:
      grafana:
        condition: service_healthy
        restart: true
@wilfriedroset wilfriedroset added the bug Something isn't working label Jan 10, 2025
@malcolmholmes
Copy link
Collaborator

This is NOT a bug in Grizzly.

You are attempting to run the Grafonnet examples, particularly the redMethod one, but you are using the library main.libsonnet as the entry point. That library is designed to be used by other jsonnet code, not to be run directly. Instead, you should call the examples/redMethod/main.libsonnet file. This one should load everything correctly.

@wilfriedroset
Copy link
Author

I'm a bit confused as I specifically call grizzly with /mnt/dashboards/examples/redMethod/main.libsonnet which is different than /mnt/dashboards/examples/redMethod/lib/redDashboard/main.libsonnet (the underlying lib).

Is there something wrong in my reproducer?

@malcolmholmes
Copy link
Collaborator

Can you execute examples/redMethod/main.libsonnet via Jsonnet?

@wilfriedroset
Copy link
Author

I could have been more explicit in the introduction.
When I run serve -w examples/redMethod/main.libsonnet it works as expected and the dashboard is reloaded each time I modify examples/redMethod/main.libsonnet
When I run serve -w examples/redMethod/main.libsonnet /mnt/dashboards/examples/redMethod it works as expected only when I modify examples/redMethod/main.libsonnet, when I modify anything under examples/redMethod/lib I have the error above.

If this is not a bug, what is the best way to structure your dashboards and lib while keeping the watch features that does not throw an error like couldn't manifest function as JSON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants