Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull JSON from GitHub into Grafana for persistent existance of a dashboard #1447

Closed
vsomwanshi opened this issue Mar 12, 2024 · 6 comments
Closed
Labels
question Further information is requested stale

Comments

@vsomwanshi
Copy link

In our environment we have operator based Grafana installation.

Whenever grafana-deployment-* pods restarts grafana dashboard is getting vanished, so upon investigating we found that there are few below steps we can execute for the persistent existance of the dashboard.

  1. create a repo and push your json

  2. open the json file and click on raw button which will generate a URL

  3. copy the URL and create a configmap or secret using that URL : kubectl create configmap grafana-dashboard --from-literal=dashboard.json="$(curl -sSL https://raw.github.ibm.com/vishavjeet-somwanshi/xxxxxxxxx)"

  4. mount this configmap/secret as volume and volume mount in grafana dashboard deployment yaml configuration

template:
    spec:
      containers:
        - name: grafana
          # Other container configuration
          volumeMounts:
            - name: grafana-dashboard-config
              mountPath: /etc/grafana/provisioning/dashboards
              readOnly: true
      volumes:
        - name: grafana-dashboard-config
          configMap:
            name: grafana-dashboard
            items:
              - key: dashboard.json
                path: dragon-sre.json
  1. refer this mounter volume and Set the GF_PATHS_PROVISIONING environment variable to point to the directory where Grafana will load dashboards on every restart :
          env:
            - name: GF_PATHS_PROVISIONING
              value: /etc/grafana/provisioning

While modifying the grafana deployment getting below error warning, as grafana installation is operator based so unable to modify the objects.

This resource is managed by Grafana G dragon-grafana and any modifications may be overwritten. Edit the managing resource to preserve changes.

Can anyone help on this issue.

@pb82
Copy link
Collaborator

pb82 commented Mar 12, 2024

you can specify a URL to fetch the dashboard json from, we have an example for this: https://github.com/grafana/grafana-operator/blob/master/examples/dashboard_from_url/resources.yaml

@theSuess theSuess added the question Further information is requested label Mar 12, 2024
@vsomwanshi
Copy link
Author

vsomwanshi commented Mar 12, 2024

@pb82 You mean do i need to create a separate dashboard under All instances which would be managed by kind: Grafana instance ?

If so, I have created a GrafanaDashboard object however it is still not persistant

apiVersion: integreatly.org/v1alpha1
kind: GrafanaDashboard
metadata:
  name: test
  namespace: grafana
spec:
  url: >-
    https://github.ibm.com/xxxxxxxx/xxxxxxx/xxxxxxxxxxxxx
   instanceSelector:
    matchLabels:
      dashboards: "grafana"

Any grafana documentation link for reference.

@NissesSenap
Copy link
Collaborator

@vsomwanshi a Kubernets deployment isn't persistent.
Either you need to use a volume for your grafana instance as documented here: https://grafana.github.io/grafana-operator/docs/examples/persistent_volume/readme/

I wouldn't suggest doing this for production, though. Instead, I would use a separate postgres instance as documented here: https://grafana.com/docs/grafana/latest/setup-grafana/installation/#supported-databases

@vsomwanshi
Copy link
Author

@NissesSenap We have operator based grafana installation in our RedHat Openshift on AWS cluster.

Since, it's operator based it is not allowed to modify the grafana-deployment configuration as it is managed by Grafana object.

[1] I may need to look for an option to customize this grafana instance https://grafana.github.io/grafana-operator/docs/grafana/

[2] I was trying to execute below steps to create a dashboard using URL https://grafana.github.io/grafana-operator/docs/examples/dashboard_from_url/readme/ however, when i am trying to apply it is automatically removing the instanceselector parameters which is not applying on the GrafanaDashboard object

spec:
  instanceSelector:
    matchLabels:
      dashboards: "grafana"

Any suggestions please

@NissesSenap
Copy link
Collaborator

@vsomwanshi we have designed the operator to allow for any changes to the deployment.
If you want to add a volume, you can for example follow this example https://grafana.github.io/grafana-operator/docs/examples/persistent_volume/readme/.

If you are having issues I would suggest trying the exact examples, don't do any changes to it and first see that those work.
When see that the example is working as intended, you can start doing modifications to match the config you want.

Copy link

This issue hasn't been updated for a while, marking as stale, please respond within the next 7 days to remove this label

@github-actions github-actions bot added the stale label Apr 26, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested stale
Projects
None yet
Development

No branches or pull requests

4 participants