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

Restart grafana after updating dashboards #319

Closed
wants to merge 2 commits into from
Closed

Restart grafana after updating dashboards #319

wants to merge 2 commits into from

Conversation

samuelallan72
Copy link
Contributor

This ensures that dashboard changes are picked up by grafana.

Fixes #303

@chanchiwai-ray
Copy link

chanchiwai-ray commented Apr 9, 2024

Did not apply this patch directly, but I tried /charm/bin/pebble restart grafana, and it will force refresh the dashboards.

@samuelallan72
Copy link
Contributor Author

samuelallan72 commented Apr 9, 2024

Note that we should take a second pass sometime to optimise calls to grafana_restart(), to avoid it being restarted too many times. This will need more investigation of the code to move calls around so that it is only restarted once when necessary, and we don't miss places where it should be restarted.

@mmkay
Copy link
Contributor

mmkay commented May 2, 2024

Hi @samuelallan72, thank you for your contribution! There seems to be a reload API that might update the dashboards without going through the whole Grafana restart: https://grafana.com/docs/grafana/latest/developers/http_api/admin/#reload-provisioning-configurations

Could you have a look if that doesn't fix your issue in a better way?

@samuelallan72
Copy link
Contributor Author

@mmkay this may work, but it would involve adding a lot more logic to the charm:

  • a admin user on grafana for internal use by the charm (the charm currently creates an admin user, but doesn't manage it after that - eg. the user could change the password)
  • how to handle the case where a user changes the charm's internal admin user
  • a method to call the grafana api endpoint here

I think this is probably more work than is worth it to fix this bug? Also we seem to restart grafana fairly often on changes; we've just missed restarting in this case. What are your thoughts on this?

@samuelallan72
Copy link
Contributor Author

Hi @mmkay , could you take another look at this? Thanks :)

This ensures that dashboard changes are picked up by grafana.

Fixes #303
@mmkay mmkay requested a review from a team as a code owner June 27, 2024 11:09
@mmkay
Copy link
Contributor

mmkay commented Jun 27, 2024

Hi @mmkay , could you take another look at this? Thanks :)

Hey @samuelallan72 - I've rebased the branch to newest main and integration tests seem to be failing in the PR. At first sight it looks like there might be errors around the restart timing so this might require a deeper look. We have the issue in our team's minds so will likely get back to it in near future.

@samuelallan72
Copy link
Contributor Author

Thanks for looking into it @mmkay ! I don't have much time right now to investigate the tests, but I can try when I do have time if you haven't already. 😁

Note that there may be a better or more efficient method for deciding when to restart grafana to get it to pick up the dashboard changes. This was just a method that worked for me and seemed a reasonable starting point.

@samuelallan72
Copy link
Contributor Author

Closing because this appears to have been fixed elsewhere. :) See #303

@samuelallan72 samuelallan72 deleted the fix-updating-dashboards branch September 10, 2024 05:14
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.

Grafana-k8s not rendering new dashboard from grafana-agent-k8s when the relation in between stays joined
4 participants