[solved]Datasource provisioning: prometheus

Hello,
I try to provision a grafana instgance with a datasource from prometheus. I use this

apiVersion: 1

datasources:
- name: <%= @source_name %>
  type: Prometheus
  access: direct
  orgId: 1
  url: http://localhost:9090
  isDefault: true
  version: 1
  editable: false

but even if it create the datasource, the information are not saved properly. Did I miss something?

I have the version 5.0.3 of grafana

thanks

Should be a lower-case p: prometheus

Does the name look right in Grafana? Not sure what tool you are using here.

Are you sure you want a direct connection to your Prometheus instance? Most of the time you should be using proxy mode.

I forget to replace the “<%= @source_name %>”, it’s my template of chef :wink: the value in the server is

apiVersion: 1

datasources:
- name: prometheusdata
  type: Prometheus
  access: direct
  orgId: 1
  url: http://localhost:9090
  isDefault: true
  version: 1
  editable: false

thanks for the help, I will try later and give my feedback

Well even by replacing the Prometheus by “prometheus” I have the exact same behaviour

Did you restart Grafana after changing the file? Datasource files are only read on startup.

yes, (it’s builded by chef)

I don’t know - it worked for me. I took your file and the only change I made was to make the type field lowercase.

Just to double check you changed the type field to be lowercase and not any other field?

Can you also check if you have created multiple data sources? Maybe you changed the name and got a new data source?

Sidenote: This blog post is good intro to provisioning: https://medium.com/56kcloud/provisioning-grafana-data-sources-and-dashboards-auto-magically-e27155d20652

Adding a datasource (or edit it) is ok, it’s just the provisioning that doesn’t work properly.

So this is what I did:

  1. Created a new file called prom.yaml in the conf/provisioning/datasources directory.
  2. Pasted the following text into it:
    apiVersion: 1
    
    datasources:
    - name: prometheusdata
      type: prometheus
      access: direct
      orgId: 1
      url: http://localhost:9090
      isDefault: true
      version: 1
      editable: false
    
  3. Restarted Grafana

In my logs, I got this line:

INFO[03-23|15:23:15] inserting datasource from configuration  logger=provisioning.datasources name=prometheusdata

And in data sources:

Are you doing something different (with Chef in your case)?

well finally it works, strange :wink:
thanks for the help