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

customize heigh from Panel #150

Closed
Midas1989 opened this issue Aug 22, 2019 · 5 comments
Closed

customize heigh from Panel #150

Midas1989 opened this issue Aug 22, 2019 · 5 comments

Comments

@Midas1989
Copy link

Hello,
I know the subject has been raised repeatedly.

I have a panel (table) which is slightly longer than 500.

Can I customize the code to give Table more?

or is there already another possibility?

I have the same problem with Grafana directly. Under Panel - Share - Link it does the same for me.

Thanks

@IzakMarais
Copy link
Owner

This duplicates #72.

Can I customize the code to give Table more? ... I have the same problem with Grafana directly. Under Panel - Share - Link it does the same for me.

Yes you should be able to do that. When calling Grafana via Panel > Share > Direct link rendered image, you should get a URL like http://x.x.x.x:3000/render/dashboard-solo/db/dashboard-name?from=1561526109646&to=1561532980199&panelId=4&width=1000&height=500

You can modify the height parameter to change the size of the returned image.

In the reporter source, this gets set here.

@Midas1989
Copy link
Author

Midas1989 commented Aug 26, 2019

Hello, thanks for the answer.

I changed it here. If I then
/root/go/bin/grafana-reporter -cmd_enable=1 -cmd_apiKey myapikey -ip localhost:3000 -cmd_dashboard 557gdsHZG -cmd_ts from=now-1M%2FM -cmd_o /home/admin/out4.pdf
I get:

2019/08/26 12:27:24 grafana reporter, version: 2.2-1 hash: 40c2d53
2019/08/26 12:27:24 serving at ':8686' and using grafana at 'http://localhost:3000'
2019/08/26 12:27:24 SSL check enforced
2019/08/26 12:27:24 Called with command line mode enabled, will save report to file and exit.
2019/08/26 12:27:24 Called with command line mode 'dashboard' '557gdsHZG'
2019/08/26 12:27:24 Called with command line mode 'apiKey' 'My_API_Key'
2019/08/26 12:27:24 Called with command line mode 'apiVersion' 'v5'
2019/08/26 12:27:24 Called with command line mode 'outputFile' '/home/admin/out4.pdf'
2019/08/26 12:27:24 Called with command line mode 'timeSpan' 'from=now-1M%2FM'
2019/08/26 12:27:24 Reporter called
2019/08/26 12:27:24 Called with api Token: MYAPITOKEN
2019/08/26 12:27:24 Called without variable
2019/08/26 12:27:24 Called with dashboard: 557gdsHZG
2019/08/26 12:27:24 Called with time range: {now-1M/M now}
2019/08/26 12:27:24 Connecting to dashboard at http://localhost:3000/api/dashboards/uid/557gdsHZG
2019/08/26 12:27:24 Populated dashboard datastructure: {Title:Webservices Description: VariableValues: Rows:[] Panels:[{Id:9 Type:table Title:SLA Prozesse} {Id:16 Type:graph Title:URL Check}]}
2019/08/26 12:27:24 Downloading image 9 http://localhost:3000/render/d-solo/557gdsHZG/_?from=now-1M%2FM&height=500&panelId=9&theme=light&to=now&width=1000
2019/08/26 12:27:24 Downloading image 16 http://localhost:3000/render/d-solo/557gdsHZG/_?from=now-1M%2FM&height=500&panelId=16&theme=light&to=now&width=1000
2019/08/26 12:27:27 Calling LaTeX - preprocessing
2019/08/26 12:27:27 Calling LaTeX and building PDF
2019/08/26 12:27:27 Extracted filename from dashboard title: Webservices.pdf
2019/08/26 12:27:27 Report generated correctly
Oh, yeah. I have grafana 6 running

Best regards

@IzakMarais
Copy link
Owner

From that log doesn't look like you changed the height. You might have to use some debugging skills: log your changes to the output to convince yourself that they are having an effect.

@Midas1989
Copy link
Author

Midas1989 commented Aug 29, 2019

i changed the following values in the api.go.
if p.Is(SingleStat) {
values.Add("width", "300")
values.Add("height", "150")
} else if p.Is(Text) {
values.Add("width", "1000")
values.Add("height", "100")
} else {
values.Add("width", "1000")
values.Add("height", "800")
}

I also deleted the api.go, dashboard.go and time.go and executed the cli command and noticed that the program works anyway.

Could it be that these settings are in the binary and the configs don't matter?

Also I have tried the *_test.go files

Best regards

Update

[root@krzzabbix01 go]# grep -iHr height *
Binary file bin/grafana-reporter matches
Binary file pkg/linux_amd64/github.com/IzakMarais/reporter/grafana.a matches
src/github.com/IzakMarais/reporter/grafana/api_test.go: So(requestURI, ShouldContainSubstring, "height=150")
src/github.com/IzakMarais/reporter/grafana/api_test.go: Convey(fmt.Sprintf("The %s client should request text panels with a small height", clientDesc), func() {
src/github.com/IzakMarais/reporter/grafana/api_test.go: So(requestURI, ShouldContainSubstring, "height=100")
src/github.com/IzakMarais/reporter/grafana/api_test.go: So(requestURI, ShouldContainSubstring, "height=500")
src/github.com/IzakMarais/reporter/grafana/api.go: values.Add("height", "150")
src/github.com/IzakMarais/reporter/grafana/api.go: values.Add("height", "100")
src/github.com/IzakMarais/reporter/grafana/api.go: values.Add("height", "800")

=

grafana-reporter -cmd_enable=1 -cmd_apiKey eyJrIjoiRmx0dklVckpFSlRTY3E4VEVnc1NKYkx4NTlDTUNWVlIiLCJuIjoiZXhwb3J0IiwiaWQiOjF9 -ip localhost:3000 -cmd_dashboard 557gdsHZG -cmd_ts from=now-1M%2FM -cmd_o /home/admin/4.pdf

=

2019/08/29 10:31:13 Downloading image 9 http://localhost:3000/render/d-solo/557gdsHZG/_?from=now-1M%2FM&height=500&panelId=9&theme=light&to=now&width=1000
2019/08/29 10:31:13 Downloading image 16 http://localhost:3000/render/d-solo/557gdsHZG/_?from=now-1M%2FM&height=500&panelId=16&theme=light&to=now&width=1000

@IzakMarais
Copy link
Owner

Go is a compiled language (like C++ and Java), not an interpreted language (like Ruby or Python), so after making your source changes, you need to build the program again. Rerunning the go install command from the readme should do the trick. To be sure you could first delete the grafana-reporter binary.

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

2 participants