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

Auto-enable app plugins via operator.

Open guilhermeferreyra opened this issue 1 year ago • 4 comments

I installed the Zabbix Plugin via the Dashboard Yaml file, but the plugin requires manual interaction to be enabled. It would be beneficial to automate the installation process by auto-enabling the plugin.

Here is the YAML that I used to install the plugin.

apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
  name: grafanadashboard-sample
  namespace: grafana
spec:
  resyncPeriod: 30s
  instanceSelector:
    matchLabels:
      dashboards: "grafana"
  plugins:
    - name: alexanderzobnin-zabbix-app
      version: 4.4.5
  json: >
    {
      "id": null,
      "title": "Simple Dashboard",
      "tags": [],
      "style": "dark",
      "timezone": "browser",
      "editable": true,
      "hideControls": false,
      "graphTooltip": 1,
      "panels": [],
      "time": {
        "from": "now-6h",
        "to": "now"
      },
      "timepicker": {
        "time_options": [],
        "refresh_intervals": []
      }...

300584617-2c81c57b-e742-4b7a-ad3a-99c2cf980fce

guilhermeferreyra avatar Jan 29 '24 19:01 guilhermeferreyra

I use this ansible task. Works perfectly with plugin 4.4.5 and Grafana 10.1.6

---
- name: Add datasources
  hosts: master
  gather_facts: no
  become: yes
  tasks:
    - name: Add Zabbix datasource
      kubernetes.core.k8s:
        state: present
        definition:
          apiVersion: grafana.integreatly.org/v1beta1
          kind: GrafanaDatasource
          metadata:
            name: "{{ deployment_name }}-datasource-zabbix"
            namespace: "{{ namespace }}"
          spec:
            valuesFrom:
            - targetPath: "jsonData.username"
              valueFrom:
                secretKeyRef:
                  name: "{{ deployment_name }}-zabbix-account"
                  key: "GF_SECURITY_ZABBIX_USER"
            - targetPath: "secureJsonData.password"
              valueFrom:
                secretKeyRef:
                  name: "{{ deployment_name }}-zabbix-account"
                  key: "GF_SECURITY_ZABBIX_PASSWORD"
            instanceSelector:
              matchLabels:
                dashboards: "{{ deployment_name }}"
            plugins:
                - name: alexanderzobnin-zabbix-app
                  version: "{{ zabbix_plugin_version }}"
            datasource:
              uid: "DSZABBIX"
              name: my-zabbix
              type: "alexanderzobnin-zabbix-datasource"
              access: server
              url: https://my.zabbix.tld/api_jsonrpc.php
              isDefault: true
              jsonData:
                "authType": "userLogin"
                "dbConnectionDatasourceId": 1
                "dbConnectionEnable": true
                "disableDataAlignment": false
                "trends": true
                "trendsFrom": ""
                "trendsRange": ""
                "username": ${GF_SECURITY_ZABBIX_USER}
              secureJsonData:
                "password": ${GF_SECURITY_ZABBIX_PASSWORD}
              editable: true

I also use Postgresql connection deployed with provisioning

"dbConnectionDatasourceId": 1
"dbConnectionEnable": true

Just disable this if you don't need it

Tualua avatar Jan 30 '24 07:01 Tualua

@theSuess Will look into this, however, there should be a flag to do this automatically. Pending his investigation

hubeadmin avatar Jan 30 '24 12:01 hubeadmin

Alright, the difference is between app and datasource plugins. App plugins currently need to be enabled manually or using a provisioning file. This is something we should be able to implement by either using an init container or config map which will provide a plugin provisioning file like this:

apiVersion: 1

apps:
  - type: alexanderzobnin-zabbix-app
    disabled: false

theSuess avatar Jan 31 '24 15:01 theSuess

@theSuess does this apply to all App plugins or only some of them?

pb82 avatar Feb 06 '24 12:02 pb82