divinity666 / ruby-grafana-reporter

Reporting Service for Grafana
MIT License
66 stars 5 forks source link

GrafanaError: The specified dashboard 'xxx' does not exist. (Grafana :: DashboardDoesNotExistError) #13

Closed DimitrovMiro closed 1 year ago

DimitrovMiro commented 2 years ago

Describe the issue Hello, I have configured the reporter to point to grafana instance which is not public accessible, so I have generated API key, reader role for the org2. When trying to create report, I receive the following error GrafanaError: The specified dashboard 'xxx' does not exist. (Grafana :: DashboardDoesNotExistError) The API key is configured for the correct organization the -w switch is telling the communication is successful Testing connection to 'https://grafana.xxx.com:443' with API key..., [2021-10-xxx #90280] INFO -- : Reporter is running with NON-Admin privileges on grafana. done. Access to grafana is permitted as NON-Admin.Specify path where templates shall be stored [./templates]: ./templates

I am creating a link in the dashboard settings, by calling my template. http://localhost:8815/render?var-template=miro_report In the template I only have the following config grafana_panel_image::2[dashboard="Iq_1Q6VMz",width="100%"] Also I have tried with image::3- same issue this is the url of the dashboard https://grafana.xxxxx.com/d/Iq_1Q6VMz/xxxx The config file of the reporter is as follows grafana: default: host: https://grafana.xxxxx.com:443 api_key: xxxxxxxx

grafana-reporter: report-class: GrafanaReporter::Asciidoctor::Report templates-folder: ./templates reports-folder: ./reports report-retention: 24 webservice-port: 8815 .... Also the demo report created during the configuration wizard did not find any report === AlertsTableIncludeProcessor

No example found for GrafanaReporter::Asciidoctor::AlertsTableIncludeProcessor in the dashboards.

=== AnnotationsTableIncludeProcessor

No example found for GrafanaReporter::Asciidoctor::AnnotationsTableIncludeProcessor in the dashboards.

=== PanelImageBlockMacro

No example found for GrafanaReporter::Asciidoctor::PanelImageBlockMacro in the dashboards.

=== PanelImageInlineMacro

No example found for GrafanaReporter::Asciidoctor::PanelImageInlineMacro in the dashboards.

=== PanelPropertyInlineMacro

No example found for GrafanaReporter::Asciidoctor::PanelPropertyInlineMacro in the dashboards.

=== PanelQueryTableIncludeProcessor

No example found for GrafanaReporter::Asciidoctor::PanelQueryTableIncludeProcessor in the dashboards.

=== PanelQueryValueInlineMacro

No example found for GrafanaReporter::Asciidoctor::PanelQueryValueInlineMacro in the dashboards.

=== SqlTableIncludeProcessor

No example found for GrafanaReporter::Asciidoctor::SqlTableIncludeProcessor in the dashboards.

=== SqlValueInlineMacro

No example found for GrafanaReporter::Asciidoctor::SqlValueInlineMacro in the dashboards.

=== ShowHelpIncludeProcessor

No example found for GrafanaReporter::Asciidoctor::ShowHelpIncludeProcessor in the dashboards.

=== ShowEnvironmentIncludeProcessor

No example found for GrafanaReporter::Asciidoctor::ShowEnvironmentIncludeProcessor in the dashboards. .......................................................................................................................................... Application call

Template file (if applicable)

Configuration file

grafana: default: host: https://grafana.xxxxx.com:443 api_key: xxxxxxxx

grafana-reporter: report-class: GrafanaReporter::Asciidoctor::Report templates-folder: ./templates reports-folder: ./reports report-retention: 24 webservice-port: 8815 Environment (please complete the following information):

divinity666 commented 2 years ago

Thanks a lot for using the reporter and for the detailed report!

It is very strange, that the demo report was unable to determine demo templates from your dashboards.

Here some thoughts to get closer:

1) Did you already create some dashboards including some panels prior calling the demo report creation? 2) Is the reporter really it really stating dashboard 'xxx' does not exist, or was this just a placeholder for your dashboard named 'Iq_1Q6VMz'? 3) You used the panel id '2' resp. '3' in your grafana_panel_image calls. Do you these panel ids exist on your dashboard named 'Iq_1Q6VMz'? You may check that by calling 'https://grafana.xxxxx.com/d/Iq_1Q6VMz/xxxx?orgId=1&viewPanel=2' 4) Does your grafana link configuration also append the variables, i.e. the "Variables" checkbox is checked? If not, please check it and try the URL again. 5) Which grafana version are you running? Are you running grafana on the same windows machine? 6) Try setting your host in the configuration file without the port specification (as it is default HTTPS anyway). You may also try to recreate your demo report and see if it is working better then. 7) Which datasource do you use in your panels (though this should be independent for the grafana_panel_image calls)?

Best regards

DimitrovMiro commented 2 years ago

Hi,

please find the answers below:

Did you already create some dashboards including some panels prior calling the demo report creation?- Yes, this is existing grafana which is running before that Is the reporter really it really stating dashboard 'xxx' does not exist, or was this just a placeholder for your dashboard named 'Iq_1Q6VMz'? - this was just a placeholder You used the panel id '2' resp. '3' in your grafana_panel_image calls. Do you these panel ids exist on your dashboard named 'Iq_1Q6VMz'? You may check that by calling 'https://grafana.xxxxx.com/d/Iq_1Q6VMz/xxxx?orgId=1&viewPanel=2'- by calling You may check that by calling 'https://grafana.xxxxx.com/d/Iq_1Q6VMz/xxxx?orgId=1&viewPanel=2' no dashboard is shown, because the dashboard is part of orgId 2, when I change the URL to orgId=2 then the dashboard is shown- 'https://grafana.xxxxx.com/d/Iq_1Q6VMz/xxxx?orgId=2&viewPanel=2' Does your grafana link configuration also append the variables, i.e. the "Variables" checkbox is checked? If not, please check it and try the URL again. - yes, it is checked Which grafana version are you running? 8.1.4 Are you running grafana on the same windows machine? - no, not on my local machine, grafana is pod in an AKS cluster Try setting your host in the configuration file without the port specification (as it is default HTTPS anyway). You may also try to recreate your demo report and see if it is working better then. - tried - same issue Which datasource do you use in your panels (though this should be independent for the grafana_panel_image calls)? - the specified one in the dashboard ID is prometheus datasource, but as you said, this should have nothing to do with grafana panel image calls

divinity666 commented 2 years ago

Looks like we got the point:

Your dashboard used orgId 2 instead of 1... I just figured out, that I unfortunately did not test that until now. I'll investigate and come back to this.

Thanks for your support.

DimitrovMiro commented 2 years ago

thank you, yes, my grafana has 2 organisations. If you want I can send you screenshots

divinity666 commented 2 years ago

Hm... my tests with a second organizations seem to be successfull anyway.

Is image rendering via grafana panel "Share" and "Direct image link" successfull?

DimitrovMiro commented 2 years ago

let me check

divinity666 commented 2 years ago

Another (stupid) idea that comes to my mind:

The reporter states, that it could not find the dashboard: Are you sure, the dashboard ID is properly copied? "l" and "I" look identical in Arial font.

DimitrovMiro commented 2 years ago

No, the dashboard ID is copy paste directly, no manual intervention

DimitrovMiro commented 2 years ago

Share link directly opens fine https://grafana.xxxxx.com/d/Iq_1Q6VMz/uptime-dashboard?orgId=2&refresh=30s&from=1634468143530&to=1634489743530

DimitrovMiro commented 2 years ago

on the dashboards there are many panels, might that be the issue?

divinity666 commented 2 years ago

I am a bit lost at the moment, where to search for the issue...

Any chance you could send me a temporary API Viewer (e.g. 2 days) key to your grafana instance? Maybe even a new (almost empty) organization with only one panel in it could help here. I honestly would love to understand and solve the issue.

DimitrovMiro commented 2 years ago

No, its not possible to give you temporary API key. When looking at the config and my steps, am I doing something wrong? The dashboard is having 7-8 panels, might that be an issue?

divinity666 commented 2 years ago

I use the reporter with dashboards with far more panels. I don't think the issue is related to that.

We had a similar issue a while ago, documented here: https://github.com/divinity666/ruby-grafana-reporter/issues/2 But looks like, you set it up properly.

I did not test the reporter with a AKS running grafana instance. Maybe there is a similar issue, as when using Snap (refer also here: https://github.com/divinity666/ruby-grafana-reporter/issues/8)?

Please try a call to grafana_panel_property in a template. Is that working?

Please provide a reduced failing template including the complete debug log.

DimitrovMiro commented 2 years ago

how to get the debug log

divinity666 commented 2 years ago

The debug log is the complete console output, which appears when calling the reporter with the -d DEBUG option.

DimitrovMiro commented 2 years ago

the debug output below

I, [2021-10-21T19:58:53.424595 #83620] INFO -- : Server listening on port 8815... D, [2021-10-21T19:59:03.103900 #83620] DEBUG -- : Received request: GET /render?var-template=miro_report&from=now-6h&to=now HTTP/1.1 D, [2021-10-21T19:59:03.104166 #83620] DEBUG -- : query_parameters: {"var-template"=>["miro_report"], "from"=>["now-6h"], "to"=>["now"]} I, [2021-10-21T19:59:03.122140 #83620] INFO -- : 1 report(s) in progress: 0% (running 0 secs) I, [2021-10-21T19:59:03.123078 #83620] INFO -- : Report started at 2021-10-21 19:59:03 +0300 D, [2021-10-21T19:59:03.133057 #83620] DEBUG -- : Document attributes: {"convert-backend"=>"pdf", "imagesdir"=>"./images", "var-template"=>"miro_report", "from"=>"now-6h", "to"=>"now"} D, [2021-10-21T19:59:03.133564 #83620] DEBUG -- : Received request: GET /view_report?report_id=1120 HTTP/1.1 D, [2021-10-21T19:59:03.134352 #83620] DEBUG -- : query_parameters: {"report_id"=>["1120"]} D, [2021-10-21T19:59:03.138046 #83620] DEBUG -- : Template ./templates/miro_report.adoc contains 1 calls of grafana reporter functions. D, [2021-10-21T19:59:03.145923 #83620] DEBUG -- : Processing PanelImageBlockMacro (instance: default, dashboard: Iq_1Q6VMz, panel: 2) D, [2021-10-21T19:59:03.146738 #83620] DEBUG -- : Requesting https://grafana.xxxx.com/api/frontend/settings with '' and timeout '60' D, [2021-10-21T19:59:03.586156 #83620] DEBUG -- : Received response # D, [2021-10-21T19:59:03.599798 #83620] DEBUG -- : Requesting https://grafana.xxx.com/api/dashboards/uid/Iq_1Q6VMz with '' and timeout '60' D, [2021-10-21T19:59:04.008063 #83620] DEBUG -- : Received response # E, [2021-10-21T19:59:04.015406 #83620] ERROR -- : GrafanaError: The specified dashboard 'Iq_1Q6VMz' does not exist. (Grafana::DashboardDoesNotExistError) I, [2021-10-21T19:59:04.112881 #83620] INFO -- : Report creation ended after 1 seconds with status 'finished' D, [2021-10-21T19:59:23.501003 #83620] DEBUG -- : Received request: GET /view_report?report_id=1120 HTTP/1.1 D, [2021-10-21T19:59:23.501175 #83620] DEBUG -- : query_parameters: {"report_id"=>["1120"]} D, [2021-10-21T19:59:23.503433 #83620] DEBUG -- : Returning PDF report at ./reports/gf_pdf_20211021-83620-el80rr

divinity666 commented 2 years ago

Thanks for the LOG. To me it looks as if there is something wrong with the API Key Authentication:

D, [2021-10-21T19:59:03.599798 #83620] DEBUG -- : Requesting https://grafana.xxx.com/api/dashboards/uid/Iq_1Q6VMz with '' and timeout '60' D, [2021-10-21T19:59:04.008063 #83620] DEBUG -- : Received response #Net::HTTPForbidden:0x0000000002b5b218

To validate, please change the ˋapi_keyˋ in your reporter configuration to simply something else and retry your test above. I would expect the log to look identical. Could you kindly check?

Maybe you could also try using an ADMIN API key to check if that is working.

Hopefully this brings us a bit closer :-)

divinity666 commented 2 years ago

Another question: Are you REALLY sure, you created the API key in the right grafana organization?

DimitrovMiro commented 2 years ago

yes

DimitrovMiro commented 2 years ago

now the following error GrafanaError: The specified panel id '1' does not exist on the dashboard 'Iq_1Q6VMz'. (Grafana::PanelDoesNotExistError)

the template is

grafana_panel_image::1[dashboard="Iq_1Q6VMz",width="100%"]

tried with image 2, 3 - same error

divinity666 commented 2 years ago

Please post the complete log.

DimitrovMiro commented 2 years ago

[2021-10-21T22:54:39.826999 #122024] DEBUG -- : Template ./templates/miro_report.adoc contains 2 calls of grafana reporter functions. D, [2021-10-21T22:54:39.829273 #122024] DEBUG -- : Processing PanelImageBlockMacro (instance: default, dashboard: Iq_1Q6VMz, panel: 1) D, [2021-10-21T22:54:39.830245 #122024] DEBUG -- : Requesting https://grafana.xxx.com/api/frontend/settings with '' and timeout '60' D, [2021-10-21T22:54:40.259224 #122024] DEBUG -- : Received response # D, [2021-10-21T22:54:40.265013 #122024] DEBUG -- : Requesting https://grafana.xxx.com/api/dashboards/uid/Iq_1Q6VMz with '' and timeout '60' D, [2021-10-21T22:54:40.600145 #122024] DEBUG -- : Received response # E, [2021-10-21T22:54:40.606776 #122024] ERROR -- : GrafanaError: The specified panel id '1' does not exist on the dashboard 'Iq_1Q6VMz'. (Grafana::PanelDoesNotExistError) D, [2021-10-21T22:54:40.613746 #122024] DEBUG -- : Processing PanelImageBlockMacro (instance: default, dashboard: hjhK-Aznz, panel: 1) D, [2021-10-21T22:54:40.615671 #122024] DEBUG -- : Requesting https://grafana.xxx.com/api/dashboards/uid/hjhK-Aznz with '' and timeout '60' D, [2021-10-21T22:54:41.291386 #122024] DEBUG -- : Received response # E, [2021-10-21T22:54:41.307797 #122024] ERROR -- : GrafanaError: The specified panel id '1' does not exist on the dashboard 'hjhK-Aznz'. (Grafana::PanelDoesNotExistError) I, [2021-10-21T22:54:41.397573 #122024] INFO -- : Report creation ended after 2 seconds with status 'finished' D, [2021-10-21T22:54:43.188802 #122024] DEBUG -- : Received request: GET /view_report?report_id=1240 HTTP/1.1 D, [2021-10-21T22:54:43.189054 #122024] DEBUG -- : query_parameters: {"report_id"=>["1240"]} D, [2021-10-21T22:54:43.196996 #122024] DEBUG -- : Returning PDF report at ./reports/gf_pdf_20211021-122024-1inyorc

divinity666 commented 2 years ago

How was the API key set for these logs? A "wrong" API key or the ADMIN API key? How does the log look for the other case?

DimitrovMiro commented 2 years ago

Hi, why does it work only with admin key and not with viewer. My panel IDs were wrong, but it works only with admin key, why?

divinity666 commented 2 years ago

Ok, it is working now with admin key? First of all this is good news.

Anyway the reporter should also be working with viewer permissions, as it won't call any modification actions via the grafana API.

If fine with you, I would like to close this ticket now. I am currently working on a next release, also including additional debug information especially for HTTP calls. Hopefully we can get more information out it then.

DimitrovMiro commented 2 years ago

Ok, but do you have any idea why it can't find dashboards with viewer key

divinity666 commented 2 years ago

No, I don't have an idea for that. Let's check it our with the next release.

divinity666 commented 2 years ago

I just released the new version 0.5.0. Please retest with the VIEWER API key. If it is not working, please provide the DEBUG log here for the next deep dive.

Maybe also add include::grafana_environment[] to the demo report and provide the results here.

divinity666 commented 2 years ago

Any updates? Otherwise I'll close the case because of missing information within the next days.

DimitrovMiro commented 2 years ago

let me test with the latest version

DimitrovMiro commented 2 years ago

Hi,

with viewer key, same issue

Processing PanelImageBlockMacro (instance: default, dashboard: hjhK-Aznz, panel: 998) D, [2021-12-12T14:49:58.046039 #22452] DEBUG -- : Requesting http://localhost:3000/api/dashboards/uid/hjhK-Aznz with '' and timeout '60' D, [2021-12-12T14:49:58.082955 #22452] DEBUG -- : Received response # D, [2021-12-12T14:49:58.082998 #22452] DEBUG -- : HTTP response body: {"message":"Access denied to this dashboard"} E, [2021-12-12T14:49:58.083055 #22452] ERROR -- : GrafanaError: The specified dashboard 'hjhK-Aznz' does not exist. (Grafana::DashboardDoesNotExistError)

divinity666 commented 2 years ago

Thanks for staying with the reporter!

The extended logging now shows, that there seems to be something wrong with the viewer key provided. You can simply try to debug on your side, when using e.g. curl like so:

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: YOUR_VIEWER_KEY_HERE" http://localhost:3000/api/dashboards/uid/hjhK-Aznz

This request should return a JSON format including the information about your dashboard configuration. In your case this will return a HTTP 403 Forbidden with the message {"message":"Access denied to this dashboard", which is raised by grafana, if you do not have sufficient privileges.

Calling this grafana API anyway will only require VIEWER permissions.

To get some insights, what is visible to your VIEWER API key, you may also want to try include::grafana_environment[] and post the results.

Would be great, to get some feedback after you tested the call above.

Are you sure the VIEWER API key is still valid and created in the correct grafana organization?

divinity666 commented 1 year ago

closing due to missing feedback