grafana-operator
grafana-operator copied to clipboard
Auto-enable app plugins via operator.
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": []
}...
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
@theSuess Will look into this, however, there should be a flag to do this automatically. Pending his investigation
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 does this apply to all App plugins or only some of them?