helm-charts
helm-charts copied to clipboard
[grafana] Functionality remove datasource on helm chart
What would you like to be added:
During a redeployment of the chart I want to modify the datasources
Why is this needed: I can't delete a datasource when updating my helm (The new data sources are only added to the old ones) Indeed, as indicated in the documentation (https://grafana.com/docs/grafana/latest/administration/provisioning/#datasources) you have to add the following information in the datasource.yaml
deleteDatasources:
- name: Graphite
orgId: 1
But in the file https://github.com/grafana/helm-charts/blob/main/charts/grafana/values.yaml we have only the field "datasources: {}" which allows only the addition of datasource
Describe the solution you'd like
Can you implement the functionality to allow to add in the charts/blob/main/charts/grafana/values.yaml an entry "deleteDatasources" which would add this in the configmap containing datasource.yaml
On the same level as datasources: [] you can also define a deleteDatasources: [].
For anyone looking into this issue, it looks like the helm template does not support deleteDatasources, only datasources. What I had to do to delete a datasource was manually edit the configmap and add deleteDatasources before the datasources field, then restart your pod.
Realistically, this wouldn't take much work to add that into the template
It does. Exactly as I had described above. No manual configMap editing needed.
On the same level as
datasources: []you can also define adeleteDatasources: [].
Ok but can you add this element directly in the HELM Template that you put at the disposal of the community ? (as it is the case for datasources: [])

Best regards
Opened a PR for it.
Opened a PR for it.
where?
I have just been running into this issue ...
Why was this closed? Apparently there was a PR,but it doesn't seem to have been merged.
Is there a reason to prefer not to implement deleteDatasources? It's an essential part of Grafana config, I can't understand this decision.
@tamcore what happened to this PR? any idea why it never got merged?
@joeloplot No idea. I thought i had raised the PR, but apparently i didn't. Anyhow, did it now. Although, as you will see, this is really nothing special. You just have to place to deleteDatasources entry in the right spot. No fancy implementation needed.
For anyone confused about how to remove a datasource that was added through a provisioning file, I'll try to give more details about what's likely happening.
If you are using Kubernetes and deploying Grafana tthrough the grafana helm chart in this repository, you may have enabled the functionality where there is a sidecar watching for configmaps labels with grafana_datasource=1 and then automatically adding that data to /etc/grafana/provisioning/datasources files. Once that happens, the datasource appears in Grafana and that's the end of it. Other charts like kube-prometheus-stack and loki-stack might have added their own datasources through the same mechanism (this is out of control by the grafana chart).
To remove datasources you have to:
- Stop the helm chart(s) from adding configmaps with
grafana_datasource=1(investigate how your chart(s) do that) - Tell Grafana that it should delete the datasources from its database (just removing the datasource definition is NOT enough):
- Manually: edit the configmap and add the
deleteDatasourceslist - Through the grafana helm chart: add the
deleteDatasourceslist todatasources['datasources.yaml].deleteDatasourcesand do a new release
Once the configmap is updated with deleteDatasources, the sidecar will pick this up and update the proper config file that Grafana pods use. They will see deleteDatasources and remove those datasources before adding new ones.
Why the grafana chart doesn't need any new functionality? Because it's simply passing whatever you have in the values.yaml file datasources to the configmap as-is. The PR by @tamcore only had to add a comment to help guide people but the functionality is actually built in Grafana. You just have to fill the proper YAML for it to work.
I've opted to edit the configmap manually because I didn't want to make two commits to remove some broken datasources that other charts added. One to add them to deleteDatasources and another commits to remove them from there (to avoid dead code).