blackcowmoo / grafana-google-analytics-datasource

Grafana Google Analytics datasource
https://grafana.com/grafana/plugins/blackcowmoo-googleanalytics-datasource/
Apache License 2.0
38 stars 17 forks source link

[BUG] - When trying to test the connection I always get: failed to check plugin health: health check failed #51

Closed hananmalka closed 1 year ago

hananmalka commented 2 years ago

Describe the bug I strictly follow the steps of how to generate the jwt file. After creating it, when trying to validate the connection - I'm keep getting the error: failed to check plugin health: health check failed Grafana Version & Plugin Version

Grafana version: 8.5.4 Plugin version: 0.1.4

lcc3108 commented 2 years ago

image If you attach a message when the plugin fails like the image above, it will be easier to identify the cause.

hananmalka commented 2 years ago

@lcc3108 Attached below: Screen Shot 2022-06-28 at 22 06 29

lcc3108 commented 2 years ago

The message I set to print is as below. error messages

Success message

but "Plugin health check failed" not exist

Additional grafana logs are required.

For the plugin log, please find and paste the line logger=plugin.blackcowmo-googleanalytics-datasource

If you want to be more certain, you can adjust the log level and attach the log above.

hananmalka commented 2 years ago

The only log message I get by the plugin is this one: INFO [07-03|01:09:42] Profiler logger=plugin.blackcowmoo-googleanalytics-datasource enabled=false

However, as you can see below, the plugin does installed:

Screen Shot 2022-07-03 at 1 00 27

Additional info:

Hope you can help as this plugin is truly important for me

lcc3108 commented 2 years ago

Docker allows the log to fly at runtime. You must leave a log after trying to set up the plugin.

As a result of the test on m1 MacBook, it worked normally.

MathiasTP commented 2 years ago

Getting the same error on windows machine. Running docker 8.5.0 locally

hananmalka commented 2 years ago

Running on docker v8.2.0 locally as well

JoyGoodLife commented 2 years ago

Getting the same error on MBP. Running docker grafana-enterprise:8.5.6 locally

hananmalka commented 2 years ago

@lcc3108 - Any update? Looks like several users get this error

lcc3108 commented 2 years ago

It's hard to know without the log.

Additionally, we are going to proceed with the following.(v0.1.5)

hananmalka commented 2 years ago

@lcc3108 Hi, According to grafana documentation, looks like grafana tries to check health in datasource, and since you don't have such endpoint - the check failed and then I'm not able to install and use this plugin.

Take a look here: https://grafana.com/docs/grafana/latest/developers/http_api/data_source/#check-data-source-health-by-id

Does it sounds reasonable? Can you help how to fix this as I really need this plugin.

sina-developer commented 2 years ago

Hi I have the same issue I think I can help you with logs:

logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2022-08-29T04:39:24.89+0000 lvl=eror msg="Plugin health check failed" error="failed to check plugin health: health check failed" remote_addr=3.8.189.30 traceID=00000000000000000000000000000000 logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2022-08-29T04:39:24.89+0000 lvl=eror msg="Request Completed" method=GET path=/api/datasources/2/health status=500 remote_addr=3.8.189.30 time_ms=1014 duration=1.014955697s size=85 referer=http://157.90.105.158:8002/datasources/edit/zP8sLEZVk traceID=00000000000000000000000000000000 logger=plugin.blackcowmoo-googleanalytics-datasource t=2022-08-29T04:39:25.52+0000 lvl=info msg=Profiler enabled=false

this is the logs when I click on save and test I tried on WSL docker desktop v 4.11.1 with grafana v8.5.9 and on Ubuntu Server 18.02 with grafana v8.5.10 and on both environment it failed on health check

aboulay commented 2 years ago

I have the same issue that we can see here. I have modified the content from the plugin to print the Error logs from what I see here.

I currently run the plugin inside

In my case, the error remains the same (Grafana health check problem) :

logger=context traceID=00000000000000000000000000000000 userId=3 orgId=3 uname=<hidden> t=2022-08-30T08:30:47.62+0000 lvl=eror msg="Plugin health check failed" error="failed to check plugin health: health check failed" remote_addr=213.245.110.18 traceID=00000000000000000000000000000000
logger=context traceID=00000000000000000000000000000000 userId=3 orgId=3 uname=<hidden> t=2022-08-30T08:30:47.62+0000 lvl=eror msg="Request Completed" method=GET path=/api/datasources/1/health status=500 remote_addr=213.245.110.18 time_ms=457 duration=457.892589ms size=85 referer=http://<hidden>/datasources/edit/72uHLwZ4k traceID=00000000000000000000000000000000
logger=plugin.blackcowmoo-googleanalytics-datasource t=2022-08-30T08:30:48.27+0000 lvl=info msg=Profiler enabled=false

However, I have start to use the Explorer button with the datasource and it looks like there is a missing field:

logger=plugin.blackcowmoo-googleanalytics-datasource t=2022-08-30T08:31:37.9+0000 lvl=eror msg=Query error="Required AccountID"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2022-08-30T08:31:37.9+0000 lvl=eror msg="Fail query" error="Required AccountID"

I think this is due to the file given to the plugin and perhaps I have done something wrong during the installation. In the plugin documentation, in the step Enter service account email at Generate a JWT file 8th step and Permissions add Read & Analyze, we can see a JWT file which is generated in the Google Analytics page but I hadn't found this option when I had register and I use the service account key retrieve in the step In the next step, click Create Key. Choose key type JSON and click Create. A JSON key file will be created and downloaded to your computer. (Look like the OP has done the same thing)

The current field in the given file:

I don't know if it can help but I hope we will find a solution together. :)

EDIT: It look like I can miss the AccountId field and the auto-complete work well on it but the other component don't find informations about webpropertyId (No options found when I click on the field)

logger=plugin.blackcowmoo-googleanalytics-datasource t=2022-08-30T09:06:51+0000 lvl=eror msg=Query error="Required WebPropertyID"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2022-08-30T09:06:51+0000 lvl=eror msg="Fail query" error="Required WebPropertyID"

Or if I force the Id based on what I got in the GA Property Id interface, I got a 400 from the page:

logger=plugin.blackcowmoo-googleanalytics-datasource t=2022-08-30T09:07:13.27+0000 lvl=eror msg="getProfilesList fail" webpropertyId=<hidden> accountId=<hidden> error="googleapi: Error 400: invalid webPropertyId: <hidden>., badRequest"
gytiskv commented 2 years ago

Are there any updates regarding this issue?

image
DANISHFAYAZNAJAR commented 2 years ago

Any Updates on this?

hananmalka commented 2 years ago

@lcc3108 - Any updates?

luckbyq commented 2 years ago

DBUG[09-21|15:48:17] Querying for data source via SQL store logger=datasources id=1 orgId=1 DBUG[09-21|15:48:18] getWebpropertiesList logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource WebpropertiesList="map[itemsPerPage:1000 kind:analytics#webproperties startIndex:1 username:google-analytics@massive-incline-363010.iam.gserviceaccount.com]" DBUG[09-21|15:48:18] panic: runtime error: index out of range [0] with length 0 logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] goroutine 49 [running]: logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] main.(GoogleAnalyticsDataSource).CheckHealth(0xc00000c450, 0xf03798, 0xc0004424e0, 0xc00035f140, 0xc00000c450, 0x1, 0xc0001ca780) logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /build/pkg/datasource.go:80 +0x947 logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] github.com/grafana/grafana-plugin-sdk-go/internal/automanagement.(Manager).CheckHealth(0xc000403860, 0xf03798, 0xc0004424e0, 0xc00035f140, 0xc00034f2c0, 0x0, 0xc0001ca780) logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /go/pkg/mod/github.com/grafana/grafana-plugin-sdk-go@v0.134.0/internal/automanagement/manager.go:47 +0x28f logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] github.com/grafana/grafana-plugin-sdk-go/backend.(diagnosticsSDKAdapter).CheckHealth(0xc000120720, 0xf03798, 0xc0004424e0, 0xc000442510, 0xccdae0, 0x0, 0xef9ef8) logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /go/pkg/mod/github.com/grafana/grafana-plugin-sdk-go@v0.134.0/backend/diagnostics_adapter.go:48 +0xee logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] github.com/grafana/grafana-plugin-sdk-go/backend/grpcplugin.(diagnosticsGRPCServer).CheckHealth(0xc000403ac0, 0xf03798, 0xc0004424e0, 0xc000442510, 0xc000403ac0, 0x7fab6893eb40, 0xc0001146c0) logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /go/pkg/mod/github.com/grafana/grafana-plugin-sdk-go@v0.134.0/backend/grpcplugin/grpc_diagnostics.go:52 +0x51 logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] github.com/grafana/grafana-plugin-sdk-go/genproto/pluginv2._Diagnostics_CheckHealth_Handler.func1(0xf03798, 0xc0004424e0, 0xd242c0, 0xc000442510, 0x21, 0xc00009b270, 0x7fab8f5cd9f0, 0x20) logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /go/pkg/mod/github.com/grafana/grafana-plugin-sdk-go@v0.134.0/genproto/pluginv2/backend_grpc.pb.go:289 +0x89 logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] github.com/grpc-ecosystem/go-grpc-prometheus.(ServerMetrics).UnaryServerInterceptor.func1(0xf03798, 0xc0004424e0, 0xd242c0, 0xc000442510, 0xc00007e280, 0xc00000c3d8, 0xac00ba, 0xd47a20, 0xc00007e2a0, 0xc00007e280) logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /go/pkg/mod/github.com/grpc-ecosystem/go-grpc-prometheus@v1.2.0/server_metrics.go:107 +0xb0 logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1(0xf03798, 0xc0004424e0, 0xd242c0, 0xc000442510, 0xc00070e000, 0x0, 0xc00045db30, 0x40e2f8) logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:25 +0x63 logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1(0xf03798, 0xc0004424e0, 0xd242c0, 0xc000442510, 0xc00007e280, 0xc00000c3d8, 0xc00009dba0, 0x4a0f26, 0xd670a0, 0xc0004424e0) logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:34 +0xd7 logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] github.com/grafana/grafana-plugin-sdk-go/genproto/pluginv2._Diagnostics_CheckHealth_Handler(0xccdae0, 0xc000403ac0, 0xf03798, 0xc0004424e0, 0xc000114c60, 0xc00011b6e0, 0xf03798, 0xc0004424e0, 0xc000457500, 0x9b7) logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /go/pkg/mod/github.com/grafana/grafana-plugin-sdk-go@v0.134.0/genproto/pluginv2/backend_grpc.pb.go:291 +0x150 logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] google.golang.org/grpc.(Server).processUnaryRPC(0xc00043c000, 0xf0c938, 0xc00029c600, 0xc000584000, 0xc00011bd70, 0x13cfdc0, 0x0, 0x0, 0x0) logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /go/pkg/mod/google.golang.org/grpc@v1.41.0/server.go:1279 +0x52b logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] google.golang.org/grpc.(Server).handleStream(0xc00043c000, 0xf0c938, 0xc00029c600, 0xc000584000, 0x0) logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /go/pkg/mod/google.golang.org/grpc@v1.41.0/server.go:1608 +0xd0c logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] google.golang.org/grpc.(Server).serveStreams.func1.2(0xc000286040, 0xc00043c000, 0xf0c938, 0xc00029c600, 0xc000584000) logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /go/pkg/mod/google.golang.org/grpc@v1.41.0/server.go:923 +0xab logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] created by google.golang.org/grpc.(*Server).serveStreams.func1 logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] /go/pkg/mod/google.golang.org/grpc@v1.41.0/server.go:921 +0x1fd logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:18] plugin process exited logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource path="/var/lib/grafana/plugins/gpx_ blackcowmoo-googleanalytics-datasource_linux_amd64" pid=28 error="exit status 2" EROR[09-21|15:48:18] Plugin health check failed logger=context userId=1 orgId=1 uname=admin error="failed to check plugin health: health check failed" remote_addr=172.100.101.51 EROR[09-21|15:48:18] Request Completed logger=context userId=1 orgId=1 uname=admin method=GET path=/api/datasources/1/health status=500 remote_addr=172.100.101.51 timems=1525 size=40 referer=http://172.100.255.200:3000/datasources/edit/1/ DBUG[09-21|15:48:19] Restarting plugin logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource DBUG[09-21|15:48:19] starting plugin logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource path="/var/lib/grafana/plugins/gpx blackcowmoo-googleanalytics-datasource_linuxamd64" args="[/var/lib/grafana/plugins/gpx blackcowmoo-googleanalytics-datasource_linuxamd64]" DBUG[09-21|15:48:19] plugin started logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource path="/var/lib/grafana/plugins/gpx blackcowmoo-googleanalytics-datasource_linuxamd64" pid=43 DBUG[09-21|15:48:19] waiting for RPC address logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource path="/var/lib/grafana/plugins/gpx blackcowmoo-googleanalytics-datasource_linux_amd64" INFO[09-21|15:48:19] Profiler logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource enabled=false DBUG[09-21|15:48:19] Serving plugin logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource plugins="[data stream diagnostics resource]" DBUG[09-21|15:48:19] using plugin logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource version=2 DBUG[09-21|15:48:19] plugin address logger=plugins.backend pluginId=blackcowmoo-googleanalytics-datasource address=/tmp/plugin045954221 network=unix

this is my grafana debug log

imyuanandyou commented 1 year ago

Encountered the same problem, is it related to the version of Google Analytics? I noticed that the plugin also supports GA4, and I am currently using GA4. Just my guess

lcc3108 commented 1 year ago

@imyuanandyou Currently, the latest version of the plug-in only supports UA.(GA4 Developing in https://github.com/blackcowmoo/Grafana-Google-Analytics-DataSource/tree/feature/backend/datasoruce/support-gav4)

We are planning to update the log message because it is difficult to look at the log one by one for this issue.

And I will go to the FAQ to check and update the action for each message.

Zakariaa222 commented 1 year ago

Hello, I too have the same problem, is there a solution to avoid this error message please :

Capture d’écran 2023-07-14 123136

when I added these two services in google cloud console, we can see the google analytics requests but we can't see the analytics reporting requests, maybe that's the problem? : Capture d’écran 2023-07-14 124833

lcc3108 commented 1 year ago

@Zakariaa222 Is the plugin version 0.2.0? Are there any other error messages? Is it UA or GA.

Zakariaa222 commented 1 year ago

@lcc3108 I am using version 0.2.0 the latest version. No, this is the only message I receive when I click on "Save & Test". It is UA(GA3)

Capture d’écran 2023-07-17 094421

lcc3108 commented 1 year ago

@Zakariaa222 Check FAQ

Has Google Analytics been granted permission to gcp service account?

I will check the problem of not getting the error message properly separately.

what's your grafana version?

Zakariaa222 commented 1 year ago

@lcc3108 My grafana version is 9.2.4 For Google Analytics access permission to gcp service account, I have already added account User Management as you see in the following picture : Capture d’écran 2023-07-17 111956

If you find a solution to this problem, please share it with us.

moovs commented 1 year ago

Hi, also encounted with this problem: grafana version 9.4.7 used UA plugin version 0.2.0 When I procced and go to Explore tab in Grafana I see that account ID is auto comleted and substituted, but I received error "Required WebPropertyID" looks like this field is not auto completed..

In Grafana logs I received the next:

logger=context userId=1 orgId=1 uname=superadmin t=2023-08-09T09:28:07.692948472Z level=error msg="Plugin health check failed" error="failed to check plugin health: health check failed" remote_addr=172.25.0.1 traceID=
logger=context userId=1 orgId=1 uname=superadmin t=2023-08-09T09:28:07.693113137Z level=error msg="Request Completed" method=GET path=/api/datasources/uid/n0y6tTe4k/health status=500 remote_addr=172.25.0.1 time_ms=241 duration=241.795289ms size=53 referer=http://grafana/datasources/edit/n0y6tfi5 handler=/api/datasources/uid/:uid/health
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-09T09:28:08.193179217Z level=info msg=Profiler enabled=false
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-09T09:28:08.195082684Z level=warn msg="Plugin process is running with elevated privileges. This is not recommended"

and when I go to the explore tab in grafana:

logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-09T09:28:01.484303147Z level=error msg=Query error="Required WebPropertyID"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-09T09:28:01.484435392Z level=error msg="Fail query" error="Required WebPropertyID"

It is from Grafana official site: https://grafana.com/docs/grafana/latest/developers/http_api/data_source/#check-data-source-health Maybe it's can help you to fix it.

Screenshot 2023-08-09 at 14 30 40
lcc3108 commented 1 year ago

Starting from 0.2.0, all error messages contain reasons for failure.

Additionally, the message "Plugin health check failed" seems to be sent by Grafana.

It appears that the plugin will probably restart under certain circumstances.

https://github.com/blackcowmoo/grafana-google-analytics-datasource/issues/51#issuecomment-1253902016 The log you uploaded is the old one, but I use the first profile and the first web properties for the Ga test, and it seems to pop up when it is empty.

However, it is difficult to check because I don't have any data to test.

I think we need to think about removing the data query during the health check.

If there is anyone who can support me with the sample Json file, please send me an email me Thank you.

moovs commented 1 year ago

I tried install v0.1.5 from source on the grafana server, but received the same error

lcc3108 commented 1 year ago

@moovs Could you please attach the debug log from plugin 0.2.0?

moovs commented 1 year ago

here is logs from my grafana when I press Save & Test button in grafana:

logger=context userId=1 orgId=1 uname=superadmin t=2023-08-21T14:24:32.146936796Z level=error msg="Plugin health check failed" error="failed to check plugin health: health check failed" remote_addr=172.25.0.1 traceID=
logger=context userId=1 orgId=1 uname=superadmin t=2023-08-21T14:24:32.147188545Z level=error msg="Request Completed" method=GET path=/api/datasources/uid/s9pW9oe4k/health status=500 remote_addr=172.25.0.1 time_ms=195 duration=195.190008ms size=53 referer=http://grafana/datasources/edit/s9pW9oe4k handler=/api/datasources/uid/:uid/health
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T14:24:32.380455532Z level=info msg=Profiler enabled=false
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T14:24:32.391233101Z level=warn msg="Plugin process is running with elevated privileges. This is not recommended"

I you know how to get more extented logs let me know please, I'll add it later

lcc3108 commented 1 year ago

change log.level=debug grafana.ini file

https://github.com/grafana/grafana/blob/main/conf/defaults.ini#L902

https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#log

moovs commented 1 year ago

here is debug logs when I press save and test:

logger=accesscontrol.service t=2023-08-21T15:43:45.715038028Z level=debug msg="fetch permissions from store" key=rbac-permissions-1-user-1
logger=accesscontrol.service t=2023-08-21T15:43:45.738408895Z level=debug msg="cache permissions" key=rbac-permissions-1-user-1
logger=accesscontrol.evaluator t=2023-08-21T15:43:45.751414833Z level=debug msg="matched scope" userscope=datasources:* targetscope=datasources:uid:s9pW9oe4k
logger=datasources t=2023-08-21T15:43:45.75181527Z level=debug msg="Received command to update data source" url=
logger=datasource t=2023-08-21T15:43:45.751845499Z level=debug msg="Applying default URL parsing for this data source type" type=blackcowmoo-googleanalytics-datasource url=
logger=datasource t=2023-08-21T15:43:45.751854504Z level=debug msg="Data source URL doesn't specify protocol, so prepending it with http:// in order to make it unambiguous" type=blackcowmoo-googleanalytics-datasource url=
logger=sqlstore.session t=2023-08-21T15:43:45.762979106Z level=debug msg="reusing existing session" transaction=true
logger=sqlstore.session t=2023-08-21T15:43:45.774871246Z level=debug msg="reusing existing session" transaction=true
logger=secrets.kvstore t=2023-08-21T15:43:45.813312139Z level=debug msg="got secret value" orgId=1 type=datasource namespace=" Google Analytics"
logger=sqlstore.session t=2023-08-21T15:43:45.83223541Z level=debug msg="reusing existing session" transaction=true
logger=sqlstore.session t=2023-08-21T15:43:45.855962388Z level=debug msg="reusing existing session" transaction=true
logger=secrets.kvstore t=2023-08-21T15:43:45.856579967Z level=debug msg="secret value updated" orgId=1 type=datasource namespace=" Google Analytics"
logger=sqlstore.transactions t=2023-08-21T15:43:45.856615183Z level=debug msg="skip committing the transaction because it belongs to a session created in the outer scope"
logger=sqlstore.transactions t=2023-08-21T15:43:45.856630044Z level=debug msg="skip committing the transaction because it belongs to a session created in the outer scope"
logger=secrets.kvstore t=2023-08-21T15:43:45.886029168Z level=debug msg="got secret value from cache" orgId=1 type=datasource namespace=" Google Analytics"
logger=accesscontrol.service t=2023-08-21T15:43:46.056235332Z level=debug msg="using cached permissions" key=rbac-permissions-1-user-1
logger=accesscontrol.service t=2023-08-21T15:43:46.551110155Z level=debug msg="using cached permissions" key=rbac-permissions-1-user-1
logger=accesscontrol.evaluator t=2023-08-21T15:43:46.551484031Z level=debug msg="matched scope" userscope=datasources:* targetscope=datasources:uid:s9pW9oe4k
logger=secrets.kvstore t=2023-08-21T15:43:46.563119807Z level=debug msg="got secret value from cache" orgId=1 type=datasource namespace=" Google Analytics"
logger=accesscontrol.service t=2023-08-21T15:43:46.740120455Z level=debug msg="using cached permissions" key=rbac-permissions-1-user-1
logger=datasources t=2023-08-21T15:43:46.740414194Z level=debug msg="Querying for data source via SQL store" uid=s9pW9oe4k orgId=1
logger=secrets.kvstore t=2023-08-21T15:43:46.755838045Z level=debug msg="got secret value from cache" orgId=1 type=datasource namespace=" Google Analytics"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006813929Z level=debug msg="panic: runtime error: index out of range [0] with length 0"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006861974Z level=debug msg=
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006871645Z level=debug msg="goroutine 10 [running]:"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006878334Z level=debug msg="github.com/blackcowmoo/grafana-google-analytics-dataSource/pkg/gav3.(*GoogleAnalytics).CheckHealth(0x1?, {0xe30fb8, 0xc00021a510}, 0xc000234220)"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006885806Z level=debug msg="\t/home/runner/work/grafana-google-analytics-datasource/grafana-google-analytics-datasource/pkg/gav3/analytics.go:102 +0x809"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006893318Z level=debug msg="main.(*GoogleAnalyticsDataSource).CheckHealth(0xc000234200, {0xe30fb8, 0xc00021a510}, 0x26?)"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006900108Z level=debug msg="\t/home/runner/work/grafana-google-analytics-datasource/grafana-google-analytics-datasource/pkg/datasource.go:74 +0x189"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006906104Z level=debug msg="github.com/grafana/grafana-plugin-sdk-go/internal/automanagement.(*Manager).CheckHealth(0xc00007ef00?, {0xe30fb8, 0xc00021a510}, 0xc00021b8f0)"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006923621Z level=debug msg="\t/home/runner/go/pkg/mod/github.com/grafana/grafana-plugin-sdk-go@v0.134.0/internal/automanagement/manager.go:47 +0x1f9"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006930058Z level=debug msg="github.com/grafana/grafana-plugin-sdk-go/backend.(*diagnosticsSDKAdapter).CheckHealth(0xc000288ca0, {0xe30fb8, 0xc00021a510}, 0x0?)"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.00695178Z level=debug msg="\t/home/runner/go/pkg/mod/github.com/grafana/grafana-plugin-sdk-go@v0.134.0/backend/diagnostics_adapter.go:48 +0x124"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006968325Z level=debug msg="github.com/grafana/grafana-plugin-sdk-go/backend/grpcplugin.(*diagnosticsGRPCServer).CheckHealth(0xa9adf3?, {0xe30fb8?, 0xc00021a510?}, 0xc00020f958?)"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006975061Z level=debug msg="\t/home/runner/go/pkg/mod/github.com/grafana/grafana-plugin-sdk-go@v0.134.0/backend/grpcplugin/grpc_diagnostics.go:52 +0x2b"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007006495Z level=debug msg="github.com/grafana/grafana-plugin-sdk-go/genproto/pluginv2._Diagnostics_CheckHealth_Handler.func1({0xe30fb8, 0xc00021a510}, {0xc609e0?, 0xc00021a540})"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007014213Z level=debug msg="\t/home/runner/go/pkg/mod/github.com/grafana/grafana-plugin-sdk-go@v0.134.0/genproto/pluginv2/backend_grpc.pb.go:289 +0x78"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007021436Z level=debug msg="github.com/grpc-ecosystem/go-grpc-prometheus.(*ServerMetrics).UnaryServerInterceptor.func1({0xe30fb8, 0xc00021a510}, {0xc609e0, 0xc00021a540}, 0xc36820?, 0xc000216708)"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007029263Z level=debug msg="\t/home/runner/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-prometheus@v1.2.0/server_metrics.go:107 +0x87"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007035727Z level=debug msg="github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1({0xe30fb8?, 0xc00021a510?}, {0xc609e0?, 0xc00021a540?})"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.00704281Z level=debug msg="\t/home/runner/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:25 +0x3a"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007065416Z level=debug msg="github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1({0xe30fb8, 0xc00021a510}, {0xc609e0, 0xc00021a540}, 0xc000099a58?, 0xc09e60?)"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.00707192Z level=debug msg="\t/home/runner/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:34 +0xbe"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007082072Z level=debug msg="github.com/grafana/grafana-plugin-sdk-go/genproto/pluginv2._Diagnostics_CheckHealth_Handler({0xc0e8c0?, 0xc000471010}, {0xe30fb8, 0xc00021a510}, 0xc000650070, 0xc000348900)"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007089215Z level=debug msg="\t/home/runner/go/pkg/mod/github.com/grafana/grafana-plugin-sdk-go@v0.134.0/genproto/pluginv2/backend_grpc.pb.go:291 +0x138"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007095729Z level=debug msg="google.golang.org/grpc.(*Server).processUnaryRPC(0xc0004b2000, {0xe35e58, 0xc000202820}, 0xc00022a120, 0xc0003490b0, 0x1368720, 0x0)"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007104798Z level=debug msg="\t/home/runner/go/pkg/mod/google.golang.org/grpc@v1.55.0/server.go:1337 +0xdf3"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007113023Z level=debug msg="google.golang.org/grpc.(*Server).handleStream(0xc0004b2000, {0xe35e58, 0xc000202820}, 0xc00022a120, 0x0)"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007119884Z level=debug msg="\t/home/runner/go/pkg/mod/google.golang.org/grpc@v1.55.0/server.go:1714 +0xa36"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007127762Z level=debug msg=google.golang.org/grpc.(*Server).serveStreams.func1.1()
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007143995Z level=debug msg="\t/home/runner/go/pkg/mod/google.golang.org/grpc@v1.55.0/server.go:959 +0x98"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007184691Z level=debug msg="created by google.golang.org/grpc.(*Server).serveStreams.func1"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.007192218Z level=debug msg="\t/home/runner/go/pkg/mod/google.golang.org/grpc@v1.55.0/server.go:957 +0x18c"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.013575831Z level=debug msg="plugin process exited" path=/var/lib/grafana/plugins/blackcowmoo-googleanalytics-datasource/gpx_blackcowmoo-googleanalytics-datasource_linux_amd64 pid=73 error="exit status 2"
logger=context userId=1 orgId=1 uname=superadmin t=2023-08-21T15:43:47.013795672Z level=error msg="Plugin health check failed" error="failed to check plugin health: health check failed" remote_addr=172.25.0.1 traceID=
logger=context userId=1 orgId=1 uname=superadmin t=2023-08-21T15:43:47.013952946Z level=error msg="Request Completed" method=GET path=/api/datasources/uid/s9pW9oe4k/health status=500 remote_addr=172.25.0.1 time_ms=285 duration=285.652873ms size=53 referer=http://domain/datasources/edit/s9pW9oe4k handler=/api/datasources/uid/:uid/health
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.722704411Z level=debug msg="Restarting plugin"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.722890099Z level=debug msg="starting plugin" path=/var/lib/grafana/plugins/blackcowmoo-googleanalytics-datasource/gpx_blackcowmoo-googleanalytics-datasource_linux_amd64 args=[/var/lib/grafana/plugins/blackcowmoo-googleanalytics-datasource/gpx_blackcowmoo-googleanalytics-datasource_linux_amd64]
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.725269824Z level=debug msg="plugin started" path=/var/lib/grafana/plugins/blackcowmoo-googleanalytics-datasource/gpx_blackcowmoo-googleanalytics-datasource_linux_amd64 pid=85
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.725368414Z level=debug msg="waiting for RPC address" path=/var/lib/grafana/plugins/blackcowmoo-googleanalytics-datasource/gpx_blackcowmoo-googleanalytics-datasource_linux_amd64
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.743388902Z level=info msg=Profiler enabled=false
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.743794635Z level=debug msg="Serving plugin" plugins="[diagnostics resource data stream]"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.745006267Z level=debug msg="using plugin" version=2
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.745035094Z level=debug msg="plugin address" address=/tmp/plugin208478619 network=unix
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.749944768Z level=warn msg="Plugin process is running with elevated privileges. This is not recommended"
logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.750006168Z level=debug msg="Plugin restarted"
lcc3108 commented 1 year ago

@moovs index out of range at analytics.go 102 line

logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006813929Z level=debug msg="panic: runtime error: index out of range [0] with length 0"

https://github.com/blackcowmoo/grafana-google-analytics-datasource/blob/master/pkg/gav3/analytics.go#L102

do you have ga3(UA) profile?

or

https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries/list?hl=en

use this google analytics api page(try this method)

moovs commented 1 year ago

I think that it's UA profile, but I don't know how to check it, I just created json file in GCP as described in the instruction. it's fields that contain in my json file:

Screenshot 2023-08-22 at 14 03 26
lcc3108 commented 1 year ago

This is the official api homepage of Google Analytics.

Please run it as shown in the picture. After that, can you mask the result file and share it?

{
  "kind": "analytics#accountSummaries",
  "username": "dlacocjf32@gmail.com",
  "totalResults": 1,
  "startIndex": 1,
  "itemsPerPage": 10,
  "items": [
    {
      "id": "145****",
      "kind": "analytics#accountSummary",
      "name": "Default Account for Firebase",
      "webProperties": [
        {
          "kind": "analytics#webPropertySummary",
          "id": "UA-1457****",
          "name": "gitblog",
          "internalWebPropertyId": "24912***",
          "level": "STANDARD",
          "websiteUrl": "http://lcc3108.github.io",
          "profiles": [
            {
              "kind": "analytics#profileSummary",
              "id": "23100****",
              "name": "전체 웹사이트 데이터",
              "type": "WEB"
            }
          ]
        }
      ]
    }
  ]
}

image

moovs commented 1 year ago

@lcc3108 looks like it's UA profile

{
  "kind": "analytics#accountSummaries",
  "username": "****",
  "totalResults": 4,
  "startIndex": 1,
  "itemsPerPage": 10,
  "items": [
    {
      "id": "2*****",
      "kind": "analytics#accountSummary",
      "name": "Default Account for Firebase",
      "webProperties": []
    },
    {
      "id": "2******",
      "kind": "analytics#accountSummary",
      "name": "***",
      "webProperties": []
    },
    {
      "id": "2***",
      "kind": "analytics#accountSummary",
      "webProperties": [
        {
          "kind": "analytics#webPropertySummary",
          "id": "UA-2******",
          "name": "******",
          "internalWebPropertyId": "2******",
          "level": "STANDARD",
          "websiteUrl": "http://1******",
          "profiles": [
            {
              "kind": "analytics#profileSummary",
              "id": "2*******",
              "name": "*",
              "type": "WEB"
            }
          ]
        }
      ]
    },
  ]
}
lcc3108 commented 1 year ago

@lcc3108 looks like it's UA profile

{
  "kind": "analytics#accountSummaries",
  "username": "****",
  "totalResults": 4,
  "startIndex": 1,
  "itemsPerPage": 10,
  "items": [
    {
      "id": "2*****",
      "kind": "analytics#accountSummary",
      "name": "Default Account for Firebase",
      "webProperties": []
    },
    {
      "id": "2******",
      "kind": "analytics#accountSummary",
      "name": "***",
      "webProperties": []
    },
    {
      "id": "2***",
      "kind": "analytics#accountSummary",
      "webProperties": [
        {
          "kind": "analytics#webPropertySummary",
          "id": "UA-2******",
          "name": "******",
          "internalWebPropertyId": "2******",
          "level": "STANDARD",
          "websiteUrl": "http://1******",
          "profiles": [
            {
              "kind": "analytics#profileSummary",
              "id": "2*******",
              "name": "*",
              "type": "WEB"
            }
          ]
        }
      ]
    },
  ]
}

@moovs UA is correct.

logger=plugin.blackcowmoo-googleanalytics-datasource t=2023-08-21T15:43:47.006885806Z level=debug msg="\t/home/runner/work/grafana-google-analytics-datasource/grafana-google-analytics-datasource/pkg/gav3/analytics.go:102 +0x809"

The debug log shows that GA3 (UA) has been health checked.

Now that we know the exact cause, we just need to patch it.

Thanks for your help.

moovs commented 1 year ago

ok thanks, if need some help, let me know..

lcc3108 commented 1 year ago

Access the 0th account, property, and profile of the array during health check.

If the 0th array was empty at this time, the plug-in was restarted due to incorrect memory access, and Grafana sent a health check failure message.

The modified pr is merged and will be included in 0.2.1.

0.2.1 can be used only after the test is conducted and submitted to the grafana for approval.

hananmalka commented 1 year ago

@lcc3108 Any expectations about the release of 0.2.1?

lcc3108 commented 1 year ago

@hananmalka Commutiny plugin are released only with Grafana approval.

Currently awaiting review of the grafana.

I submitted a plugin update request at 08/24 11:50PM KST and currently awaiting review.