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

Support Grafana 5.0 API changes #28

Closed
cchance27 opened this issue Feb 12, 2018 · 8 comments
Closed

Support Grafana 5.0 API changes #28

cchance27 opened this issue Feb 12, 2018 · 8 comments
Assignees

Comments

@cchance27
Copy link

Has this been tested against the 5.0 rework? As i know the dashboard permalinks have been changed etc. I'm gonna prep a box to test it but was wondering if the devs have checked it for compatability yet?

@IzakMarais
Copy link
Owner

Nope, sorry. I have not checked yet.

A PR would be welcome. I wonder what would be the best approach to handle such a breaking change? One could release a new version that only works with 5.0 and have the old version work with pre 5.0 grafana. Or it could support both via a grafana-version flag...

@h4cc
Copy link

h4cc commented Feb 28, 2018

Does not work fully. The PNGs seem to be downloaded, but are not displayed in the generated PDF.

@IzakMarais
Copy link
Owner

I just downloaded grafana 5.0 and tested against the latest master of grafana-reporter. Everything seems to work fine. Closing this issue until I get some concrete examples to the opposite.

@IzakMarais
Copy link
Owner

IzakMarais commented Mar 1, 2018

Hmm from the docs I see:

New uid-based routes in the dashboard API have been introduced to retrieve and delete dashboards. The corresponding slug-based routes have been deprecated and will be removed in a future release.

Will see if I can support the new API, to avoid nasty surprises in a future release when the deprectation happens.

@IzakMarais IzakMarais reopened this Mar 1, 2018
@IzakMarais IzakMarais changed the title 5.0 support? Support Grafana 5.0 API changes Mar 1, 2018
@highkeep
Copy link

highkeep commented Mar 2, 2018

Not the greatest workaround, but I didn't have time to look for a better working solution at the moment. I personally left in the original for backwards compatibility. Regardless, it does look like rows are being fazed out.

type dashContainer struct {
	Dashboard Dashboard // This seemed to make more sense to me.
	Meta      struct {
		Slug string
	}
}

func (dc dashContainer) NewDashboard(variables url.Values) Dashboard {
	var dash Dashboard
	dash.Title = sanitizeLaTexInput(dc.Dashboard.Title)
	dash.Description = sanitizeLaTexInput(dc.Dashboard.Description)
	dash.VariableValues = sanitizeLaTexInput(getVariablesValues(variables))

	if len(dc.Dashboard.Rows) == 0 {
		for _, p := range dc.Dashboard.Panels {
			p.Title = sanitizeLaTexInput(p.Title)
			dash.Panels = append(dash.Panels, p)
		}
		return dash
	}
	for _, row := range dc.Dashboard.Rows {
		row.Title = sanitizeLaTexInput(row.Title)
		dash.Rows = append(dash.Rows, row)
		for _, p := range dc.Dashboard.Panels {
			p.Title = sanitizeLaTexInput(p.Title)
			dash.Panels = append(dash.Panels, p)
		}
	}
        return dash
}

@IzakMarais
Copy link
Owner

IzakMarais commented Mar 2, 2018

Regardless, it does look like rows are being fazed out.

Yes and this type of solution for supporting both seems to be required, since old imported dashboards still return rows when fetched via the new API Grafana 5.

IzakMarais pushed a commit that referenced this issue Mar 5, 2018
@IzakMarais IzakMarais self-assigned this Mar 5, 2018
@IzakMarais IzakMarais mentioned this issue Mar 5, 2018
IzakMarais pushed a commit that referenced this issue Mar 5, 2018
Necessary for #28.
New version JSON doesn't have rows, instead panels have moved to the top level.
We still need to support the old version seamlessly,
since even a v5 grafana can return the old structure.
Presumably this grafana behaviour is to support backwards compatibility.
It seems old dashboards still return the old structrue,
while new dashboards greated with Grafana 5 return the new structure.
IzakMarais pushed a commit that referenced this issue Mar 5, 2018
Partially addresses  #28.
Still support Grafana v4 via existing reporter API. Add new API to use with
Grafana v5.
IzakMarais pushed a commit that referenced this issue Mar 5, 2018
Necessary for #28.
New version JSON doesn't have rows, instead panels have moved to the top level.
We still need to support the old version seamlessly,
since even a v5 grafana can return the old structure.
Presumably this grafana behaviour is to support backwards compatibility.
It seems old dashboards still return the old structrue,
while new dashboards greated with Grafana 5 return the new structure.
IzakMarais pushed a commit that referenced this issue Mar 5, 2018
Necessary for #28.
New version JSON doesn't have rows, instead panels have moved to the top level.
We still need to support the old version seamlessly,
since even a v5 grafana can return the old structure.
Presumably this grafana behaviour is to support backwards compatibility.
It seems old dashboards still return the old structrue,
while new dashboards greated with Grafana 5 return the new structure.
@IzakMarais
Copy link
Owner

Dashboard Dashboard // This seemed to make more sense to me.

I missed this bug (was introduced in a recent PR). Luckily it seems harmless. Fixed it now while making the other changes.

@IzakMarais
Copy link
Owner

The v2.0.0 release addresses this issue.

https://github.com/IzakMarais/reporter/releases/tag/v2.0.0

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

No branches or pull requests

4 participants