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] Provisioning Private Key #119

Closed teceP closed 3 months ago

teceP commented 3 months ago

Thanks for this plugin!

Id like to make a provisioning of the datasource in my helmcharts.

I tried:

          - name: Google Analytics
            uid: google-analytics
            type: blackcowmoo-googleanalytics-datasource
            access: proxy
            isDefault: false
            orgId: 1
            version: 1
            editable: false
            secureJsonData:
              jwt: "{\"type\":\"service_account\",\"project_id\":\"..\",\"private_key_id\":\"$GA_DS_PRIVATE_KEY_ID\",\"private_key:\":\"$GA_DS_PRIVATE_KEY\",\"client_email\":\"...\",\"client_id\":\"..\",\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"token_uri\":\"https://oauth2.googleapis.com/token\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\",\"client_x509_cert_url\":\"...\",\"universe_domain\": \"googleapis.com\"}"

and the GA_DS_PRIVATE_KEY value contains the private key:

-----BEGIN PRIVATE KEY-----\nMIIEvAIBADA.....65iyoBPd7Fr773.....KaTp2VX\nUvcVkjuFR....s6OrfuMDN+8Q+WWUD...xORlIfw==\n-----END PRIVATE KEY-----\n

When I want to test the connection to the Analytics API, I always get this error:

CheckHealth: Fail getPropetyListGet "https://analyticsadmin.googleapis.com/v1beta/accountSummaries?alt=json&pageSize=200&pageToken=&prettyPrint=false": private key should be a PEM or plain PKCS1 or PKCS8; parse error: asn1: syntax error: sequence truncated

I already tried to privisioning with plaintext in jsonData key and without the environment variable way, but this doesnt work neither. The private key (the value of the env var) is actually a valid private PKCS8 key.

What is the best (or any working) way to do this? Thanks in advance.

Grafana: 10.4.7 Plugin version: latest(?)

lcc3108 commented 3 months ago

I think the above comment is spam.

I will answer you after checking the contents of the issue.

teceP commented 3 months ago

Yeah me too, already reported this user. :)

I just figured it out! Instead of using a env var inside the json string, It work with this:

..
secureJsonData:
   jwt: $GA_DS_JWT

And inside of the GA_DS_JWT env var is the whole jwt json string.

I will close this issue now, thank you for your fast reply!