prometheus-operator: Grafana dashboards not getting persisted.
What did you do? Installed prometheus operator and kube prometheus using helm. Configured storagespec for grafana. (To persist grafana data)
What did you expect to see? Expect the dashboards created on grafana UI to persist even after pod restart.
What did you see instead? Under which circumstances? Grafana dashboards are not persisted
Environment
-
Kubernetes version information: Client Version: version.Info{Major:“1”, Minor:“9”, GitVersion:“v1.9.6”, GitCommit:“9f8ebd171479bec0ada837d7ee641dec2f8c6dd1”, GitTreeState:“clean”, BuildDate:“2018-03-21T15:21:50Z”, GoVersion:“go1.9.3”, Compiler:“gc”, Platform:“linux/amd64”} Server Version: version.Info{Major:“1”, Minor:“9”, GitVersion:“v1.9.6”, GitCommit:“9f8ebd171479bec0ada837d7ee641dec2f8c6dd1”, GitTreeState:“clean”, BuildDate:“2018-03-21T15:13:31Z”, GoVersion:“go1.9.3”, Compiler:“gc”, Platform:“linux/amd64”}
-
Kubernetes cluster kind: Kops
-
Manifests:
grafana:
storageSpec:
class: px-repl1
accessMode: ReadWriteOnce
resources:
requests:
storage: 2Gi
selector: {}
*Other Details
Issue is not with persisting the data. When I exec to the pod and check the path to which the volume is mounted, grafana.db (file), sessions (folder), plugins (folder) are found. this data gets persisted. But when i see in the UI newly created dashboards are not available even though the data is there, after restart of the pod.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 42 (10 by maintainers)
This repository is very opinionated about how Grafana is managed, if you don’t want to declaratively configure Grafana that’s fine, but it’s a non-goal for this project. I hope you understand and I’d highly recommend for you to try the declarative approach, as a stateful Grafana is an incredible pain to manage even though it’s not necessary and rollback are near impossible. We’ve been running Grafana in an entirely stateless way for years, and have had no problems with the approach.
I hope you understand. I’m closing this here as it’s out of scope for this project.
I’ve got the PersistentVolume created and the users and other items are persisted but not the dashboards or data sources. This is really a pain, I’d love to be able to not worry about my dashboards disappearing if the pod is restarted.
These are the steps we make to persist dashboards to outlive pod deletion:
Create your custom dashboard through the UI.
Click on the “Save” button which will pop up a “Cannot save provisioned dashboard” window. There you can click on the “Save JSON to file” button.
Save the json file to your computer.
Using kubectl command-line tool which is configured to communicate with your k8s cluster, create a new ConfigMap using the following command: kubectl create configmap my-custom-dashboard --from-file=path-to-file.json
Add a label to the newly created ConfigMap: kubectl label configmaps my-custom-dashboard grafana_dashboard=1
This is a huge pain and makes grafana unusable 😦 Really need a fix for this.
Dashboards are written as jsonnet code and checked into version control. When updated in version control, a redeploy of Grafana is triggered and Grafana is fully provisioned (both dashboards and datasources) from files using the Grafana provisioning features.
Users are managed by an external identity provider using the bitly/oauth2_proxy, and the following Grafana configurations:
That as jsonnet code that is (you can read here for more detail on how to customize your Grafana install via jsonnet):
And we have Grafana bind to the loopback interface, and because of the above settings any user successfully authenticated with Grafana is automatically created in Grafana. In the future we would like Grafana to also use the users login token for requests against Prometheus as then we can make use of authorization proxies for Prometheus so we can limit what a user can see through Grafana without any customization/configuration necessary.
We manage all alerts as Prometheus alerts that are also checked in to version control and deployed and reloaded by Prometheus whenever checked in.
We’re also running into some weirdness. But what is strange is that some assets are persisted. The following objects are persisted between pod restarts (things I have found so far):
Unfortunately Dashboards, Data Sources and other objects are totally lost after a pod deletion.
we went the PVC way for users persistence
(Did not read everything) You can use ConfigMaps to persist the dashboards instead and prometheus reloads them into you graphana server. Thats what i do
@den-is try this:
For me it is working with an existing PVC/PV, I am creating it before the first install of Grafana.
values.yaml
pv.yaml
pvc.yaml