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: allowing import dashboards from URL #43

Merged
merged 16 commits into from
Sep 4, 2019

Conversation

jjaferson
Copy link
Contributor

Importing dashboards from a URL (in addition to json inside the CR)

https://issues.jboss.org/browse/INTLY-2983

Verification Steps

  1. Deploy Grafana operator
  2. Deploy a dashboard with URL field, there is a CR example file DashboardFromURL.yaml
  3. Access Grafana UI and verify if the dashboard was imported from URL
  4. Delete the Grafana dashboard CR
  5. Change/Remove the URL in the grafana dashboard CR to an invalid one
  6. Deploy the dashboard again and check if it fallback to the json field

@jjaferson jjaferson requested a review from pb82 August 30, 2019 16:01
@pb82
Copy link
Collaborator

pb82 commented Aug 30, 2019

@jjaferson i think you need to rebase against the master branch to resolve the conflict

@pb82
Copy link
Collaborator

pb82 commented Sep 2, 2019

@jjaferson please also update the dashboards documentation

valid, err := r.isJsonValid(d)
json := r.loadDashboardFromURL(d)
if json != "" {
d.Spec.Json = json
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't this still be overwriting the json field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but only if the downloaded json is valid. The only other way I can see of not overwriting the json is changing the function UpdateDashboard in the kubeHelper.go

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's ok, maybe we can pass in the json instead of the whole dashboard to this function.

@@ -209,6 +219,43 @@ func (r *ReconcileGrafanaDashboard) importDashboard(d *i8ly.GrafanaDashboard) (r
return reconcile.Result{}, err
}

func (r *ReconcileGrafanaDashboard) loadDashboardFromURL(d *i8ly.GrafanaDashboard) string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it make sense to return (string, error) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had the function returning errors at first but If an error occur while downloading a dashboard it won't stop dashboards from being imported as it will use the json field in the CR as a fallback, that is why I decided to just log the errors instead of return them.

I am not sure whether it's the best approach, let me know your thoughts on that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rather return an error from this function and add an error check (and log) where it's called.

@jjaferson jjaferson requested a review from pb82 September 4, 2019 09:39
@jjaferson jjaferson merged commit 0cceed5 into grafana:master Sep 4, 2019
NissesSenap pushed a commit to NissesSenap/grafana-operator that referenced this pull request Mar 10, 2023
NissesSenap pushed a commit to NissesSenap/grafana-operator that referenced this pull request Mar 14, 2023
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.

2 participants