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

Detect changes to datasources when using provisioning #12878

Open
bgagnon opened this issue Aug 10, 2018 · 35 comments
Open

Detect changes to datasources when using provisioning #12878

bgagnon opened this issue Aug 10, 2018 · 35 comments
Assignees
Labels

Comments

@bgagnon
Copy link

bgagnon commented Aug 10, 2018

What Grafana version are you using?

Grafana v5.0.3 (commit: 91162f3)

When changing datasource files, grafana should reload them automatically (without restart).
Grafana requires a restart to pick up changes to provisioned datasources, unlike dashboards.

The user case is a "git ops" setup where Grafana is exclusively configured by Git and CI jobs. This works well for dashboards, but not datasources.

@chrisduong
Copy link

Hi, while waiting for this feature. Do we have a command (API call) to reload its datasource manually.

@marefr
Copy link
Member

marefr commented Aug 24, 2018

@chrisduong No, the only http api available is the update datasource: http://docs.grafana.org/http_api/data_source/#update-an-existing-data-source

@bergquist
Copy link
Contributor

The reason we decided that datasources should not be reloaded is that we consider it configuration rather than content (dashboards) and I don't expect Grafana to reload its configuration when its configuration files changes.

I do understand the need for controlling datasources completly from configuration.. But right now I think a better way would be to add an API endpoint for reloading the configuration.

@dtshepherd
Copy link

dtshepherd commented Sep 15, 2018

I ran into this issue today. However, my problem was during initial deploy of the grafana chart + configmap. There is a race condition where the sidecar may not load the new `datasources.yaml file into the provisioning folder before the main grafana pod loads. This means we need to bounce grafana no matter what during initial provisioning of a stack.

It seems if grafana itself isn't planning to continuous update datasources from the provisioning directory, the kubernetes deployment should help synchronize the install. What makes things worse, you can't guarantee when the grafana pod restarts that the sidecar container will start first.

@swtch1
Copy link
Contributor

swtch1 commented Oct 9, 2018

@dtshepherd I'm guessing from your comment that you're using the stable/grafana helm chart. I was having the same issue so I forked their chart and have the datasource processing happening in an init container. Also doing secret injection there.

@dtshepherd
Copy link

@swtch1 Yep, I've been trying to avoid forking the stable charts if at all possible. I may go down that route. Not sure what's worse, forking the chart, or creating a custom grafana docker image.

@lswith
Copy link

lswith commented Oct 9, 2018

I'd love if someone just made a PR against the chart. It would help immensely. It seems this bug could take a while.

@dtshepherd
Copy link

What do you think would be the fix against the chart? Just support an init container? Or volume mount for provisioning?

@lswith
Copy link

lswith commented Oct 10, 2018

yeah I think initContainer is probably the way to go considering its what @swtch1 is using.

@swtch1
Copy link
Contributor

swtch1 commented Oct 11, 2018

I've got some changes I can submit. No guarantee they'll take it since it changes the methodology a bit but I'll link the PR here in case anyone wants to fork it. Give me a week to get caught up at work.

@swtch1
Copy link
Contributor

swtch1 commented Oct 22, 2018

I have submitted the PR to the helm charts repository. No idea if they will merge it in but forking mine should get this initContainer behavior you're looking for and avoid the race condition that causes this to miss some of all of the datasources from configmaps.

@lswith @dtshepherd

@michaelbannister
Copy link

Should this issue (as originally raised) be closed, now that #16579 is merged? (Thanks very much for that, @aocenas!)

@marefr
Copy link
Member

marefr commented Jun 28, 2019

@michaelbannister it depends of the issue author is satisfied with the support of manually reloading via HTTP API endpoint.

@aocenas
Copy link
Member

aocenas commented Jul 9, 2019

@marefr I remember talking with @bergquist about eventually implementing this feature, and the manual reloading API being a precursor to this but not sure if it got planned (do not see it in the backend project) or was just in some backlog for unscheduled future. In any case even if author can manage with the manual reload this probably should be kept open to at least get feedback whether more people want this feature.

@michaelbannister
Copy link

michaelbannister commented Jul 9, 2019

In which case, I'll say that having provisioning configs auto-reload would be really good for my team - we sync dashboards from git to a GCS bucket and have a process sitting next to Grafana that periodically syncs from GCS to the filesystem. Having discovered the reload API, we're using that, but if Grafana automatically picked up the changes that'd be simpler.

Or, even better: provision dashboards from remote storage like GCS/S3/Git
Edit: I see that's been rejected at #11879

@marefr marefr added the prio/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough interest in it. label Jul 9, 2019
@marefr
Copy link
Member

marefr commented Jul 9, 2019

@aocenas yeah lets keep it open so that people interested can upvote it.

@vijayakumarbathini
Copy link

+1

we are looking for this feature

@sancyx
Copy link

sancyx commented Mar 19, 2020

+1

also looking for this feature

@Morriz
Copy link

Morriz commented Apr 2, 2020

+1

@bergquist bergquist self-assigned this Apr 2, 2020
@anarcher
Copy link

+1

1 similar comment
@Hmerac
Copy link
Contributor

Hmerac commented Apr 24, 2020

+1

@njbarber
Copy link

+1

I have a custom solution for the Helm chart issue with makes changes to the kiwigrid/k8s-sidecar and makes use of the reload and delete API when ConfigMaps are added and deleted, respectively. The changes are quite specific, so there probably isn't a set of parameters that could be added to the image to make it generally useful.

Would this be a potential solution? To have the chart use a custom image which does the former?

@sancyx
Copy link

sancyx commented May 26, 2020

Hi @njbarber, I've also prepared a similar change to grafana chart helm/charts@master...sancyx:reaload_datasources, however this only works for the reload, it's not able to delete the datasource because it uses the stock k8s-sidecar. I I think your solution is slightly better, do you have this grafana specific k8s-sidecar in a PR? I think if you can make that change / image public, you should make a PR to grafana chart to use that side-car. I don't see a better solution right now.

@StevenCyb
Copy link

StevenCyb commented Aug 21, 2020

Currently I am working on a mechanism to distribute configurations to some Grafana instances. Now I am also facing this challenge. In my case reloading the data sources via API is tedious, because I cannot get the admin user/pw without a lot of overhead and manual administration.

Maybe we can add an command to reload via CLI?

So I'm also interested.

@LudwigHoff
Copy link

+1

For me it is an old fashioned "I don't know where prometheus is" until my single-instance prometheus registers itself with consul.

Hoping to use consul-template to update ip:port using an in-container sidecar (containerpilot).

As a previous poster notes, using the api is tedious due to the security.

As it stands I now need to front prometheus behind a load balancer - probably an nginx instance with consul-template, cos nginx does support CLI config reload.

@qaiserali
Copy link

+1
I am also facing the same issue. I tried to import dashboard via configmap but it doesn't show on grafana. #27748

@aniketd
Copy link

aniketd commented Oct 11, 2020

Case:

  • using prometheus-operator
  • grafana helm chart: v5.3.0
  • grafana: v7.0.3

Observation:

  • dashboards are updated automatically upon changes to the ConfigMaps, but
  • datasources do not.

Having datasources also update automatically like the dashboards do, would be very helpful.

@gjed
Copy link
Contributor

gjed commented Dec 23, 2020

+1

@Rohlik
Copy link
Contributor

Rohlik commented Jul 21, 2021

You can use API call to reload Grafana provisioned stuff - https://grafana.com/docs/grafana/latest/http_api/admin/#reload-provisioning-configurations

@vpedosyuk
Copy link

The POST /api/admin/provisioning/datasources/reload approach doesn't work for those who use SSO with disabled basic auth. Datasources auto-reload would make perfect sense in this scenario.

@adimitris
Copy link

+1

@Breee
Copy link

Breee commented Feb 22, 2023

Makes absolutely no sense to me that this does not exist.
This logic already exists for Dashboards: https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards
The grafana team or the community should implement a similar mechanism for datasources and plugins.

@ospiegel91
Copy link

ospiegel91 commented Jun 27, 2023

please understand the importance of this... still an issue in 2023

@danilocmd
Copy link

+1

1 similar comment
@haqa
Copy link

haqa commented Nov 15, 2023

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests