mahendrapaipuri / grafana-dashboard-reporter-app

A Grafana plugin app to create PDF reports of dashboards
Apache License 2.0
47 stars 4 forks source link

failed to generate in windows server #14

Closed veenone closed 4 months ago

veenone commented 6 months ago

Hi @mahendrapaipuri ,

First of all thank you for providing new solution on the reporter. however I faced some issues which prevents me to generate the report. I'm currently using Windows to host grafana.

there are some points I'd like to report in this ticket.

if I enable HTTPS connection logger=plugin.mahendrapaipuri-dashboardreporter-app t=2024-04-02T15:54:53.360885+07:00 level=warn msg="failed to walk through grafana-image-renderer plugin dir" pluginID=mahendrapaipuri-dashboardreporter-app endpoint=callResource err="CreateFile \\var\\lib\\grafana\\plugins\\grafana-image-renderer: The system cannot find the path specified." logger=plugin.mahendrapaipuri-dashboardreporter-app t=2024-04-02T15:55:03.4194279+07:00 level=error msg="error generating report" endpoint=callResource err="error fetching dashboard eMN1BVRGk: error executing request for https://myserver:3000/api/dashboards/uid/eMN1BVRGk: Get \"https://myserver:3000/api/dashboards/uid/eMN1BVRGk\": net/http: TLS handshake timeout" pluginID=mahendrapaipuri-dashboardreporter-app

if I use HTTP logger=plugin.mahendrapaipuri-dashboardreporter-app t=2024-04-02T14:58:56.0972119+07:00 level=warn msg="failed to walk through grafana-image-renderer plugin dir" endpoint=callResource err="CreateFile \\var\\lib\\grafana\\plugins\\grafana-image-renderer: The system cannot find the path specified." pluginID=mahendrapaipuri-dashboardreporter-app logger=plugin.mahendrapaipuri-dashboardreporter-app t=2024-04-02T14:58:56.1482157+07:00 level=error msg="error generating report" endpoint=callResource err="error fetching dashboard eMN1BVRGk: error executing request for https://myserver:3000/api/dashboards/uid/eMN1BVRGk: Get \"https://myserver:3000/api/dashboards/uid/eMN1BVRGk\": http: server gave HTTP response to HTTPS client" pluginID=mahendrapaipuri-dashboardreporter-app

basically, :

Thank you for your support

mahendrapaipuri commented 6 months ago

Hey, thanks for the detailed info.

Firstly, I never tested the plugin on windows as I don't have access to a windows machine. Maybe you can help me to support it. Could you please tell me what are the default paths that Grafana is using for windows? Especially, the plugin uses Grafana data path to look for grafana-image-renderer plugin.

Regarding HTTP issue, I think you have changed Grafana to run without TLS but you have not configured the plugin to use HTTP. That is why the plugin is making requests to HTTPS endpoint. I think you need to tell plugin the Grafana URL either by provisioning method or env var GF_APP_URL (I m sorry I m on my phone so can't easily link you to appropriate doc links). How are you configuring Grafana App URL for the plugin?

mahendrapaipuri commented 6 months ago

@veenone Could you please try this patch? You can download the zipped plugin folder, unzip it in your Grafana plugins directory and restart the Grafana. Here is the PR that attempts to support windows.

Cheers!

veenone commented 6 months ago

hi @mahendrapaipuri ,

I have tried to apply the patch, however I still got the same error using http configuration : image

on https, still error as well. this time with TLS handhsake error during generation of the dashboard

mahendrapaipuri commented 6 months ago

@veenone Cheers for testing

In your logs this line

error executing request for https://myserver:3000/api/dashboards/uid/eMN1BVRGk: Get \"https://myserver:3000/api/dashboards/uid/eMN1BVRGk\":

is saying that plugin is making API requests to HTTPS rather than HTTP. By default plugin will always make API requests to localhost under HTTP unless you have explicitly changed the default settings using provisioning. Could you please share your provisoning config for the plugin and Grafana config?

mahendrapaipuri commented 6 months ago

I have done a quick test on AWS EC2 windows instance and the nightly release of plugin is working as expected. Here are the relevant logs:

INFO [04-05|09:13:54] provisioned config                       logger=plugin.mahendrapaipuri-dashboardreporter-app skipTlsCheck=false dashboardMode=default dataPath= endpoint=callResource layout=simple persistData=false pluginID=mahendrapaipuri-dashboardreporter-app orientation=portrait appUrl=http://localhost:3000 maxRenderWorkers=2.000
INFO [04-05|09:13:54] Grafana data path found                  logger=plugin.mahendrapaipuri-dashboardreporter-app GF_PATHS_DATA=C:\\Users\\Administrator\\Downloads\\grafana-enterprise-10.4.1.windows-amd64\\grafana-v10.4.1\\data endpoint=callResource pluginID=mahendrapaipuri-dashboardreporter-app
INFO [04-05|09:15:24] Usage stats are ready to report          logger=infra.usagestats
INFO [04-05|09:17:00] Rendering                                logger=rendering renderer=plugin path="d-solo/adhsxhderludcd/_?panelId=1"
INFO [04-05|09:17:19] Request Completed                        logger=context userId=1 orgId=1 uname=admin method=GET path=/api/live/ws status=-1 remote_addr=[::1] time_ms=69 duration=69.7162ms size=0 referer= handler=/api/live/ws status_source=server
INFO [04-05|09:22:16] Rendering                                logger=rendering renderer=plugin path="d-solo/adhsxhderludcd/_?panelId=1&from=now-1h&height=500&theme=light&to=now"
INFO [04-05|09:22:33] Request Completed                        logger=context userId=1 orgId=1 uname=admin method=GET path=/api/live/ws status=-1 remote_addr=[::1] time_ms=45 duration=45.7098ms size=0 referer= handler=/api/live/ws status_source=server
INFO [04-05|09:22:54] Rendering                                logger=rendering renderer=plugin path="d-solo/adhsxhderludcd/_?from=now-1h&height=500&panelId=1&theme=light&to=now&width=1000"
INFO [04-05|09:23:07] Request Completed                        logger=context userId=1 orgId=1 uname=admin method=GET path=/api/live/ws status=-1 remote_addr=[::1] time_ms=19 duration=19.6965ms size=0 referer= handler=/api/live/ws status_source=server
INFO [04-05|09:23:15] report generated                         logger=plugin.mahendrapaipuri-dashboardreporter-app dash_uid=adhsxhderludcd endpoint=callResource pluginID=mahendrapaipuri-dashboardreporter-app user=admin
veenone commented 5 months ago

hello @mahendrapaipuri ,

sorry for the late reply. please find my config file, which is pretty standard. most of it are in default defaults.txt

mahendrapaipuri commented 5 months ago

@veenone Could you try with latest version? I have tweaked few things the way plugin gets its config.

Cheers

veenone commented 5 months ago

hi @mahendrapaipuri ,

I have tested the latest version here. I also updated the image renderer plugin to the latest one.

however, I got different behavior now, it returns unauthorized error :

logger=context t=2024-04-25T19:06:37.9725463+07:00 level=warn msg="failed to look up session from cookie" error="user token not found" logger=context userId=0 orgId=0 uname= t=2024-04-25T19:06:37.9755401+07:00 level=warn msg=Unauthorized error="user token not found" remote_addr=x.x.x.1 traceID= logger=context userId=0 orgId=0 uname= t=2024-04-25T19:06:37.9765402+07:00 level=info msg="Request Completed" method=GET path=/api/plugins/mahendrapaipuri-dashboardreporter-app/resources/report status=401 remote_addr=x.x.x.1 time_ms=17 duration=17.0761ms size=40 referer=http://i2j6serv2v0004:3000/ handler=/api/plugins/:pluginId/resources/*

there's also a bit different behavior when I set the link using the hostname and using the ip address. as this result abive came up when I use ip address,

the following returns when I use hostname in the link

logger=plugin.mahendrapaipuri-dashboardreporter-app t=2024-04-25T19:32:15.7451111+07:00 level=error msg="error generating report" pluginID=mahendrapaipuri-dashboardreporter-app endpoint=callResource err="error fetching dashboard eMN1BVRGk: error executing request for https://myhostname:3000/api/dashboards/uid/eMN1BVRGk: Get \"https://myhostname:3000/api/dashboards/uid/eMN1BVRGk\": http: server gave HTTP response to HTTPS client" logger=context userId=1 orgId=1 uname=admin t=2024-04-25T19:32:15.7451111+07:00 level=error msg="Request Completed" method=GET path=/api/plugins/mahendrapaipuri-dashboardreporter-app/resources/report status=500 remote_addr=x.x.x.1 time_ms=6 duration=6.2446ms size=24 referer=http://myhostname:3000/login handler=/api/plugins/:pluginId/resources/* logger=context userId=0 orgId=0 uname= t=2024-04-25T19:32:15.8011418+07:00 level=info msg="Request Completed" method=GET path=/favicon.ico status=302 remote_addr=x.x.x.1 time_ms=0 duration=993.1µs size=29 referer= handler=public-assets

btw, please find my configuration in the attachment defaults.txt

mahendrapaipuri commented 5 months ago

In the config you linked, you are using http and not https. Do you have a reverse proxy infront of Grafana that terminates TLS? If so, on which port that reverse proxy is running? When you access Grafana in the browser, what is the URL you are using? I mean you can mask the hostname but I am interested in protocol and port. I am curious where the plugin is picking up https from.

Did you provision the plugin as described here? If not, could you try with default provisioning file provided in the repo?

Cheers!

veenone commented 5 months ago

I have provision the plugin according to the readme description, I see it loaded properly in the log and in the app section.

I will try to use your provision file later. However in my case, I'm deploying grafana without docker, I set it up as a simple windows service without any reverse proxy configured. Just a default http connection

mahendrapaipuri commented 5 months ago

@veenone Cheers for the details. Could you please post all the log lines from the plugin? At some point, plugin will write the current config to logs and that can give us some leads on where the plugin is picking up https from. I am talking about a log line as follows:

INFO [04-05|09:13:54] provisioned config                       logger=plugin.mahendrapaipuri-dashboardreporter-app skipTlsCheck=false dashboardMode=default dataPath= endpoint=callResource layout=simple persistData=false pluginID=mahendrapaipuri-dashboardreporter-app orientation=portrait appUrl=http://localhost:3000 maxRenderWorkers=2.000

Cheers

veenone commented 4 months ago

@mahendrapaipuri,

sorry for the delay, please find the log lines from the plugin plugin_log.txt

mahendrapaipuri commented 4 months ago

According to the logs you sent me, you are using appUrl in the provisioned config as https://myserver:3000. Check the following line in your logs:

log_stdout:209737: logger=plugin.mahendrapaipuri-dashboardreporter-app t=2024-04-25T19:16:03.0171001+07:00 level=info msg="provisioned config" dashboardMode=default dataPath= maxRenderWorkers=2 persistData=false skipTlsCheck=false **appUrl=https://myserver:3000** endpoint=callResource layout=simple orientation=landscape pluginID=mahendrapaipuri-dashboardreporter-app

But the config that you has posted earlier uses http server and not https. Could you please set the appUrl in the provisioned config to http://myserver:3000 (without TLS) and restart the Grafana server? Also, please try the new v1.3.0 version of the plugin. I have fixed and improved few things.

veenone commented 4 months ago

hello @mahendrapaipuri ,

I have no progress even after using v.1.3.0 where it still has the same problem.

As a matter of fact, the plugin works smoothly in my other Grafana server that I installed on Ubuntu server, and it looks great actually!

never the less, I also still need the one in Windows.

please find my last logs & config I specifically run to test the report generation in Windows

grafanalog.zip

mahendrapaipuri commented 4 months ago

@veenone I am sorry that it is still not working for you on Windows. The plugin per se is proved to be working well on Windows as I got feedback from a Windows user.

The logs that you sent me do not indicate that you actually made any attempt to generate a report. Could you follow the following steps:

If it still does not work, please send me all the logs in debug mode right from loading of plugin.

veenone commented 4 months ago

@mahendrapaipuri ,

I have a great news that report generation on Windows is successfully generated now :) basically what I did :

Maybe the issue was on the version.. but since it's solved now I think I can close the ticket ;)

Thank you for your thorough support !