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

Insert Page Break after title #141

Closed
pteratech opened this issue Jul 17, 2019 · 19 comments
Closed

Insert Page Break after title #141

pteratech opened this issue Jul 17, 2019 · 19 comments

Comments

@pteratech
Copy link

Would like to insert page break after title so the first page is the title page and the graphs start displaying on the second page. Thanks

@IzakMarais
Copy link
Owner

IzakMarais commented Jul 17, 2019 via email

@pteratech
Copy link
Author

pteratech commented Jul 17, 2019 via email

@pteratech
Copy link
Author

I am assuming that it is ignoring my template and using a default.
I created a templates directory /go/bin/templates and placed the template there
I added the command -templates texTemplate.tex (The file says too instead of to on the timeSpan section)
\date{[[.FromFormatted]]\too\[[.ToFormatted]]}
But the pdf output still says to

@IzakMarais
Copy link
Owner

IzakMarais commented Jul 18, 2019 via email

@pteratech
Copy link
Author

Here is my command.

sudo /home/zabbixcnr/go/bin/grafana-reporter -cmd_enable=1 -cmd_apiKey "APIKEY" -ip localhost:3000 -cmd_dashboard g08CgnSWz -cmd_ts from=now-1d -templates=/home/zabbixcnr/go/bin/templates -cmd_o testout.pdf

It generates the PDF but not from the template in the templates directory.

ls /home/zabbixcnr/go/bin/templates
texTemplate.tex

I changed this line in the template to see if it is working.
\date{[[.FromFormatted]]\\too\\[[.ToFormatted]]}
Attached result...
testout (5).pdf

@pteratech
Copy link
Author

Oh maybe it won't work from the command line.

@pteratech
Copy link
Author

http://x.x.x.x/api/v5/report/g08CgnSWz?apitoken="APIKEY"?template=texTemplate

This yeilds

Unauthorized, message: {"message":"Invalid API key"}

If I remove the

?template=texTemplate

it generates the PDF but not with the change I made.

Sorry - I feel really dumb right now.

@pteratech
Copy link
Author

I am sorry but it just ignores my templates= command - the results has the apikey removed.

zabbixcnr@zabbixcnr:~/go/bin$ ./grafana-reporter -cmd_enable=1 -cmd_apiKey "APIKEY" -ip localhost:3000 -cmd_dashboard g08CgnSWz -cmd_ts from=now-1d -cmd_o testout.pdf -templates=/home/zabbixcnr/go/bin/templates/

2019/07/18 21:15:29 grafana reporter, version: 2.1-0 hash:
2019/07/18 21:15:29 serving at ':8686' and using grafana at 'localhost:3000'
2019/07/18 21:15:29 Called with command line mode enabled, will save report to file and exit.
2019/07/18 21:15:29 Called with command line mode 'dashboard' 'g08CgnSWz'
2019/07/18 21:15:29 Called with command line mode 'apiKey'
2019/07/18 21:15:29 Called with command line mode 'apiVersion' 'v5'
2019/07/18 21:15:29 Called with command line mode 'outputFile' 'testout.pdf'
2019/07/18 21:15:29 Called with command line mode 'timeSpan' 'from=now-1d'
2019/07/18 21:15:29 Reporter called
2019/07/18 21:15:29 Called with api Token:
2019/07/18 21:15:29 Called without variable
2019/07/18 21:15:29 Called with dashboard: g08CgnSWz
2019/07/18 21:15:29 Called with time range: {now-1d now}
2019/07/18 21:15:29 Connecting to dashboard at http://localhost:3000/api/dashboards/uid/g08CgnSWz
2019/07/18 21:15:29 Populated dashboard datastructure: {Title:Huntwood Connections Report Description: VariableValues: Rows:[] Panels:[{Id:6 Type:graph Title:Fiber Link Traffic} {Id:4 Type:graph Title:Wireless Link Traffic} {Id:8 Type:graph Title:Fiber Link Uptime} {Id:2 Type:graph Title:Wireless Link UpTime}]}
2019/07/18 21:15:29 Downloading image 6 http://localhost:3000/render/d-solo/g08CgnSWz/_?from=now-1d&height=500&panelId=6&theme=light&to=now&width=1000
2019/07/18 21:15:29 Downloading image 8 http://localhost:3000/render/d-solo/g08CgnSWz/_?from=now-1d&height=500&panelId=8&theme=light&to=now&width=1000
2019/07/18 21:15:29 Downloading image 4 http://localhost:3000/render/d-solo/g08CgnSWz/_?from=now-1d&height=500&panelId=4&theme=light&to=now&width=1000
2019/07/18 21:15:29 Downloading image 2 http://localhost:3000/render/d-solo/g08CgnSWz/_?from=now-1d&height=500&panelId=2&theme=light&to=now&width=1000
2019/07/18 21:15:34 Calling LaTeX - preprocessing
2019/07/18 21:15:35 Calling LaTeX and building PDF
2019/07/18 21:15:35 Extracted filename from dashboard title: Huntwood Connections Report.pdf
2019/07/18 21:15:35 Report generated correctly

@IzakMarais
Copy link
Owner

IzakMarais commented Jul 19, 2019

Oh maybe it won't work from the command line.

After reading through the source code I can confirm that this is a bug. The command line mode feature is very new.

http://x.x.x.x/api/v5/report/g08CgnSWz?apitoken="APIKEY"?template=texTemplate

When passing multiple query parameters in a URL, you should have one ? and then the rest be separated by &.

http://x.x.x.x/api/v5/report/g08CgnSWz?apitoken="APIKEY"&template=texTemplate

If successful, you would expect Called with template:... to appear in the logs.

@pteratech
Copy link
Author

I am looking in syslog and grafana log and do not see this. How do I determine where the log file is?
After making the change to the URL it still uses the default template.

@IzakMarais
Copy link
Owner

How do I determine where the log file is?
The reporter just logs to std out. It is the log you already posted in this comment.

Let's first confirm that you see the expected message in the log.
From the source code here and here you can see that it should be printing that message after successfully extracting the "template" URL query parameter.

@pteratech
Copy link
Author

Ahh there's the catch. That is not from a log file. That is from my console screen when I run the command from the command line. I did a copy and paste of my console screen.
Here is what is in syslog

Jul 22 08:30:41 zabbixcnr grafana-server[958]: t=2019-07-22T08:30:41-0700 lvl=info msg=Rendering logger=rendering path="d-solo/g08CgnSWz/?from=now-1d&height=500&panelId=6&theme=light&to=now&width=1000"
Jul 22 08:30:41 zabbixcnr grafana-server[958]: t=2019-07-22T08:30:41-0700 lvl=info msg=Rendering logger=rendering path="d-solo/g08CgnSWz/
?from=now-1d&height=500&panelId=4&theme=light&to=now&width=1000"
Jul 22 08:30:41 zabbixcnr grafana-server[958]: t=2019-07-22T08:30:41-0700 lvl=info msg=Rendering logger=rendering path="d-solo/g08CgnSWz/?from=now-1d&height=500&panelId=2&theme=light&to=now&width=1000"
Jul 22 08:30:41 zabbixcnr grafana-server[958]: t=2019-07-22T08:30:41-0700 lvl=info msg=Rendering logger=rendering path="d-solo/g08CgnSWz/
?from=now-1d&height=500&panelId=8&theme=light&to=now&width=1000"

Here is what is in grafana log

t=2019-07-22T08:30:41-0700 lvl=info msg=Rendering logger=rendering path="d-solo/g08CgnSWz/?from=now-1d&height=500&panelId=6&theme=light&to=now&width=1000"
t=2019-07-22T08:30:41-0700 lvl=info msg=Rendering logger=rendering path="d-solo/g08CgnSWz/
?from=now-1d&height=500&panelId=4&theme=light&to=now&width=1000"
t=2019-07-22T08:30:41-0700 lvl=info msg=Rendering logger=rendering path="d-solo/g08CgnSWz/?from=now-1d&height=500&panelId=2&theme=light&to=now&width=1000"
t=2019-07-22T08:30:41-0700 lvl=info msg=Rendering logger=rendering path="d-solo/g08CgnSWz/
?from=now-1d&height=500&panelId=8&theme=light&to=now&width=1000"

Here is my console (APIKEY deleted)

zabbixcnr@zabbixcnr:~/go/bin$ ./grafana-reporter -cmd_enable=1 -cmd_apiKey "APIKEY" -ip localhost:3000 -cmd_dashboard g08CgnSWz -cmd_ts from=now-1d  -cmd_o testout.pdf -templates=/home/zabbixcnr/go/bin/
2019/07/22 08:30:41 grafana reporter, version: 2.1-0 hash: 
2019/07/22 08:30:41 serving at ':8686' and using grafana at 'localhost:3000'
2019/07/22 08:30:41 Called with command line mode enabled, will save report to file and exit.
2019/07/22 08:30:41 Called with command line mode 'dashboard' 'g08CgnSWz'
2019/07/22 08:30:41 Called with command line mode 'apiKey' 
2019/07/22 08:30:41 Called with command line mode 'apiVersion' 'v5'
2019/07/22 08:30:41 Called with command line mode 'outputFile' 'testout.pdf'
2019/07/22 08:30:41 Called with command line mode 'timeSpan' 'from=now-1d'
2019/07/22 08:30:41 Reporter called
2019/07/22 08:30:41 Called with api Token: 
2019/07/22 08:30:41 Called without variable
2019/07/22 08:30:41 Called with dashboard: g08CgnSWz
2019/07/22 08:30:41 Called with time range: {now-1d now}
2019/07/22 08:30:41 Connecting to dashboard at http://localhost:3000/api/dashboards/uid/g08CgnSWz
2019/07/22 08:30:41 Populated dashboard datastructure: {Title:Huntwood Connections Report Description: VariableValues: Rows:[] Panels:[{Id:6 Type:graph Title:Fiber Link Traffic} {Id:4 Type:graph Title:Wireless Link Traffic} {Id:8 Type:graph Title:Fiber Link Uptime} {Id:2 Type:graph Title:Wireless Link UpTime}]}
2019/07/22 08:30:41 Downloading image  6 http://localhost:3000/render/d-solo/g08CgnSWz/_?from=now-1d&height=500&panelId=6&theme=light&to=now&width=1000
2019/07/22 08:30:41 Downloading image  8 http://localhost:3000/render/d-solo/g08CgnSWz/_?from=now-1d&height=500&panelId=8&theme=light&to=now&width=1000
2019/07/22 08:30:41 Downloading image  4 http://localhost:3000/render/d-solo/g08CgnSWz/_?from=now-1d&height=500&panelId=4&theme=light&to=now&width=1000
2019/07/22 08:30:41 Downloading image  2 http://localhost:3000/render/d-solo/g08CgnSWz/_?from=now-1d&height=500&panelId=2&theme=light&to=now&width=1000
2019/07/22 08:30:46 Calling LaTeX - preprocessing
2019/07/22 08:30:47 Calling LaTeX and building PDF
2019/07/22 08:30:47 Extracted filename from dashboard title:  Huntwood Connections Report.pdf
2019/07/22 08:30:47 Report generated correctly
zabbixcnr@zabbixcnr:~/go/bin$

@IzakMarais
Copy link
Owner

OK, I think the new cmd_line mode option was confusing the issue here. Even when using the default web-server mode, the log files are still just sent to std out. If you run the service inside some service manager, like systemd, you should see all those same logs appearing in your journal that you saw when you ran from the commandline.

Be that as it may, after #143 has been fixed, this should be easier for you using only the command line mode. See this test I did as an example: #145 (comment).

@pteratech
Copy link
Author

Well then you must have a different version than I do.

zabbixcnr@zabbixcnr:~/go/bin$ ./grafana-reporter -cmd_enable=1 -cmd_apiKey -ip localhost:3000 -cmd_dashboard g08CgnSWz -cmd_ts from=now-1d -cmd_o testout.pdf
-cmd_template Commercial

flag provided but not defined: -cmd_template
Is my directory structure wrong?
Capture

@IzakMarais
Copy link
Owner

You need to use the new v2.2.1 release I made yesterday. Or just pull from master and rebuild the reporter.

@pteratech
Copy link
Author

OK now I get ---

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdflatex 2019.7.16) 29 JUL 2019 15:51
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**report.tex
(./report.tex
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
...

l.1 /
*
Here is how much of TeX's memory you used:
6 strings out of 492982
263 string characters out of 6134896
54077 words of memory out of 5000000
3671 multiletter control sequences out of 15000+600000
3640 words of font info for 14 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
5i,0n,4p,15b,14s stack positions out of 5000i,500n,10000p,200000b,80000s

! ==> Fatal error occurred, no output PDF file produced!

I looked at Commercial and it the line in it
\begin{document}
Not sure what or where ./report.tex is

@pteratech
Copy link
Author

Here is report.tex

/*
Copyright 2016 Vastech SA (PTY) LTD

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package report

const defaultTemplate = `
%Commercial.tex
%use square brackets as golang text templating delimiters
\documentclass{article}
\usepackage{graphicx}
\usepackage[margin=1in]{geometry}

\graphicspath{ {images/} }
\begin{document}
...

@pteratech
Copy link
Author

Even this template yields the same error

/*
Copyright 2016 Vastech SA (PTY) LTD

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package report

const defaultTemplate = `
%Commercial.tex
%use square brackets as golang text templating delimiters
\documentclass{article}

\begin{document}

\end{document}
`

@pteratech
Copy link
Author

Removed the following and now it works.

/*
   Copyright 2016 Vastech SA (PTY) LTD
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package report

const defaultTemplate = `

and the ` at the end

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