grafana-operator icon indicating copy to clipboard operation
grafana-operator copied to clipboard

[Bug] Unable to use grafana-sentry-datasource plugin

Open bukovjanmic opened this issue 2 years ago • 2 comments

Describe the bug When testing grafana-sentry-datasource plugin, we ran into several problems, two of which our showstoppers:

  • the operator does not parse plugins from data sources. Contrary to the documentation (and as we studied from source code), the plugins names seem not to be automatically parsed from the GrafanaDatasource CR. It seems only GrafanaDashboard are processed.
  • the necessary params for this plugins are thrown out from CR, as such fields are not defined in CRDs.

We worked around the first problen by manually specifiying GF_INSTALL_PLUGINS env variable as stated in documentation.

However,, for the second problem, the datasource needs to be specified like this:

https://grafana.com/grafana/plugins/grafana-sentry-datasource/

datasources:
  - name: Sentry
    type: grafana-sentry-datasource
    access: proxy
    orgId: 1
    version: 1
    editable: false
    jsonData:
      url: https://sentry.io
      orgSlug: xxxxxxxxxxxxx
    secureJsonData:
      authToken: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Both jsonData.orgSlug and secureJsonData.authToken are not defined in the CRD, and thus are pruned from CR. As a result, the datasource does not work.

Version Grafana Operartor 4.4.1

To Reproduce Try to create the datasource

Expected behavior

  • plugin is parsed from the DataSource definition
  • jsonData and secureJsonData are preserved and passed to plugin

For the second problem, it should be enough to add:

x-kubernetes-preserve-unknown-fields: true

to the jsonData and secureJsonData properties in the CRD definiton, as it would be quite costly to synthetize all possible Json values for all plugins that are available for Grafana (per Kubernetes documentaion https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/).

For the first problem, I believe similar logic should be implemented as with Datasources, either via explicit plugin section in GrafanaDatasource spec or derive it from the spec.datasources.type property.

Thanks,

Michal

bukovjanmic avatar Jun 13 '22 09:06 bukovjanmic

@bukovjanmic the documentation is misleading here and should be updated: https://github.com/grafana-operator/grafana-operator/blob/master/documentation/plugins.md#install-plugins-as-dependencies-of-datasources-or-dashboards

We don't support plugins defined in data sources. You'll have to add them to a dashboard. Regarding the other issue, x-kubernetes-preserve-unknown-fields: true might be worth trying. We currently whitelist every param explicitely and quite a few of them are missing.

pb82 avatar Jun 14 '22 12:06 pb82

will be fixed by #803

pb82 avatar Jul 26 '22 11:07 pb82