Can't remove/update provisioned datasource

What Grafana version and what operating system are you using?

Grafana v10.1.5 (849c612fcb)

What are you trying to achieve?

I’ve provisioned a datasource without specifiying uid. So I can’t share provisioned dashboards between all instances.

So I just want the datasource to have same and fixed uid over all instances.

How are you trying to achieve it?

  1. I tried to just update the YAML file
  2. I tried to remove from Web UI
  3. I removed it from YAML file
  4. I added deleteDatasources in YAML file
  5. I tried to trigger a datasource reload from API with Admin service account token
  6. I tried to remove datasource from API by id with Admin service account token
  7. I tried to remove datasource from API by uid with Admin service account token

What happened?

  1. Nothing
  2. Can’t. Delete button is disabled
  3. Nothing
  4. Nothing
  5. I get 403 Forbidden while service acount is Admin
{
  "accessErrorId": "ACE4020887645",
  "message": "You'll need additional permissions to perform this action. Permissions needed: provisioning:reload",
  "title": "Access denied"
}
  1. I get 403 Forbidden while service acount is Admin (no detail)
  2. I get 403 Forbidden while service acount is Admin (no detail)

What did you expect to happen?

Be able to update uid or just remove datasource the provisioned a new one.

Can you copy/paste the configuration(s) that you are having problems with?

Initial one:

# datasources.yaml
apiVersion: 1
datasources:
- name: "Loki"
  type: "loki"
  access: "proxy"
  url: "http://loki:3100"

Update with uid:

# datasources.yaml
apiVersion: 1
datasources:
- name: "Loki"`
  uid: "loki"
  type: "loki"
  access: "proxy"
  url: "http://loki:3100"

Remove:

# datasources.yaml
apiVersion: 1
datasources: []

Delete:

# datasources.yaml
apiVersion: 1
deleteDatasources:
- name: "Loki"
  orgId: 1
datasources: []

Did you receive any errors in the Grafana UI or in related logs? If so, please tell us

logger=context userId=15 orgId=1 uname=sa-temporary-debugger t=2025-04-10T06:32:34.146612002Z level=info msg="Access denied" userID=15 accessErrorID=ACE4020887645 permissions="action:provisioning:reload scopes:provisioners:datasources"
logger=context userId=15 orgId=1 uname=sa-temporary-debugger t=2025-04-10T06:32:34.148099058Z level=info msg="Request Completed" method=POST path=/api/admin/provisioning/datasources/reload status=403 remote_addr=[::1] time_ms=35 duration=35.434207ms size=169 referer= handler=/api/admin/provisioning/datasources/reload

logger=context userId=15 orgId=1 uname=sa-temporary-debugger t=2025-04-10T06:42:38.283540167Z level=info msg="Request Completed" method=DELETE path=/api/datasources/3 status=403 remote_addr=[::1] time_ms=22 duration=22.754428ms size=49 referer= handler=/api/datasources/:id

logger=context userId=15 orgId=1 uname=sa-temporary-debugger t=2025-04-10T06:43:39.126622718Z level=info msg="Request Completed" method=DELETE path=/api/datasources/uid/P8E80F9AEF21F6940 status=403 remote_addr=[::1] time_ms=27 duration=27.613311ms size=49 referer= handler=/api/datasources/uid/:uid

Did you follow any online instructions? If so, what is the URL?

Already provided above

so as not to assume anything

did you restart grafana?

also what kind of install it is? dockerized or otherwise?

You’re right! :sweat_smile: It’s high chance I missed something(sssssss)

Oups forgot to mention I did it after any YAML update.

It is deployed on Kubernetes using Prometheus stack Helm chart: helm-charts/charts/kube-prometheus-stack at kube-prometheus-stack-52.1.0 · prometheus-community/helm-charts · GitHub

sorry meant to say how is grafana deployed

And that’s what I answered :smiley:

1 Like

Update your datasources.yaml to include both deleteDatasources and the new datasource config with your desired uid:

apiVersion: 1
deleteDatasources:
- name: "Loki"
  orgId: 1
datasources:
- name: "Loki"
  uid: "loki"
  type: "loki"
  access: "proxy"
  url: "http://loki:3100"
  1. Restart your Grafana instance (simple service restart)
  2. If using API to reload configs instead, ensure your service account has the specific provisioning:reload permission (being Admin isn’t enough)

Provisioned datasources can’t be deleted from UI or modified via API - they must be managed through the provisioning files.

1 Like

It does the job to remove datasource.

However, when I removed deleteDatasources, it didn’t provision the datasource again…

Looked at logs I found several:

logger=context userId=0 orgId=0 uname= t=2025-04-14T11:00:44.639124887Z level=info msg= error="[identity.disabled] identity is disabled" remote_addr=[::1] traceID=
logger=context userId=0 orgId=0 uname= t=2025-04-14T11:00:44.639239648Z level=info msg="Request Completed" method=POST path=/api/admin/provisioning/dashboards/reload status=401 remote_addr=[::1] time_ms=20 duration=20.764481ms size=102 referer= handler=/api/admin/provisioning/dashboards/reload

It was before Grafana Pod was available, so not sure it is related…

Ok, I updated the config map and I get the same error log again… I’m using Helm chart, I will take a look if there’s a known issue…

Forgot to answer about this point. When I edit service account, I can’t set such permissions:

All things I can do:

  • Set a role: Viewer, Editor or Admin
  • Add permission:
    • I must select a kind: User or Team
    • Then select a user or a team
    • Select a permission: Edit or Admin

@thiagorodrigues