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

grafana_dashboard recource is not idempotent #47

Open
karolisc opened this issue Jun 22, 2017 · 4 comments
Open

grafana_dashboard recource is not idempotent #47

karolisc opened this issue Jun 22, 2017 · 4 comments
Labels
bug Something isn't working

Comments

@karolisc
Copy link

How to reproduce (e.g Puppet code you use)

grafana_dashboard { 'example_dashboard':
  grafana_url       => 'https://127.0.0.1:3000',
  grafana_user      => 'admin',
  grafana_password  => '5ecretPassw0rd',
  content           => template('path/to/exported/file.json'),
}
run  multiple times:
puppet agent -t

What are you seeing

...... content: content changed '{"annotation...' to '{"annotation...'

Karolis

@ov7a
Copy link

ov7a commented Aug 15, 2017

Also, one can get

Error: Could not set 'present' on ensure: Fail to save dashboard example_dashboard (HTTP response: 412/{"message":"A dashboard with the same name already exists","status":"name-exists"} 

@wyardley wyardley added the bug Something isn't working label Sep 20, 2017
@ofbeaton
Copy link

I fixed this in grafana 5.x by switching to dashboard provisioning instead of the puppet type that uses the API.

http://docs.grafana.org/administration/provisioning/

In fact I had to switch from dashboard types to provisioning as I had all kinds of problems using the API including this one (dashboards titles not being found despite them being installed, resulting in errors, dashboards being continuously deployed as they are not idempotent ...). Switching to provisioning solved all my problems.

May we should update the documentation for this alternative?

@aptituz
Copy link

aptituz commented Sep 27, 2018

I wonder how viable the solution to use the file provisioning is, because it makes it almost impossible to implement additional resources, e.g. resources for granting dashboard permissions to users and teams without requiring multiple puppet runs.

Couldn't the provider be fixed to properly compare is/should?

@joernott
Copy link

This should be resolved. When exporting a JSON file, you need to delete the "id", "uid" and "version" elements from that. The sanitized template should work.
From grafana 9 on, the datasources are no longer referenced by name but by uuid, so you need to set it when creating a datasource and then reference its id in your dashboard (happens automagically, when your dashboard uses a datasource created by puppet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants