Rename a datasource which was provisioned using a file

Hi Grafana Team!
I have a datasource which is provisioned using a file.
The file looks like below,

apiVersion: 1

datasources:
  - name: Druid
    version: 1
    type: grafadruid-druid-datasource
    access: proxy
    orgId: 1
    uid: _Pvp4QWYS
    isDefault: true
    jsonData:
      connection.basicAuth : true
      connection.url: mu_url
      connection.basicAuthUser: my_user
    secureJsonData:
      connection.basicAuthPassword: my_password
    editable: false
    enabled: true

Everything is working fine.
Now, I want to rename this datasource to Druid - Events, so I made the following changes,

...
datasources:
  - name: Druid - Events
    version: 2
...

However, now when I restart Grafana with the updated file, I get this error,

logger=provisioning.datasources t=2023-01-30T12:42:56.376372465Z level=info msg="inserting datasource from configuration " name="Druid - Events" uid=_Pvp4QWYS
logger=provisioning t=2023-01-30T12:42:56.398055752Z level=error msg="Failed to provision data sources" error="Datasource provisioning error: data source with the same uid already exists"

I looks like Grafana is trying to insert a new Datasource rather than updating the existing one.
Can someone help me out here please? How do I make Grafana update the same datasource rather than make it create another one?


  • What Grafana version and what operating system are you using?
    I am on Grafana v9.3.6

  • What are you trying to achieve?
    Trying to update the name of a datasource which was provisioned using a file.

  • How are you trying to achieve it?
    By updating the provisioning file

  • What happened?
    Grafana fails to start with the following error,

logger=provisioning.datasources t=2023-01-30T12:42:56.376372465Z level=info msg="inserting datasource from configuration " name="Druid - Events" uid=_Pvp4QWYS
logger=provisioning t=2023-01-30T12:42:56.398055752Z level=error msg="Failed to provision data sources" error="Datasource provisioning error: data source with the same uid already exists"
  • What did you expect to happen?
    Grafana should rename the datasource

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

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    See above

  • Did you follow any online instructions? If so, what is the URL?
    Followed instructions from here: Provision Grafana | Grafana documentation

5 Likes