docker-grafana-graphite
docker-grafana-graphite copied to clipboard
Provision dashboards?
I'm using Ansible to start up this container, and I'm trying to provision it with a few pre-built dashboards.
Mounting these JSON files under /src/dashboards
doesn't seem to work - I only see the default ones. Is there anything else I need to do to have these dashboards automatically be available every time this container is launched?
Hello @sgunturi, there should not be any additional requirement. Can you take a look at the dashboard_loader.log
file at /var/log/supervisor
in the container? just to know if it is actually picking up the dashboards.
is it possible that you would need to extend our image as described here?
I am having the same problem. After looking at this thread, I checked the log, and saw this:
Adding/updating the [Docker] dashboard. When adding/updating the [Docker] dashboard, I got a 404: {"message":"Dashboard not found","status":"not-found"} over and over again, and it was never even trying to add in my new dashboard.
So I removed the docker.json file from that directory, and now I'm getting that same error, but with my dashboard. Here's a sample from the log file:
Pinging grafana login page... Got status code 200 from login page Logged in Adding/updating the [Engdb Dashboard] dashboard. Adding/updating the [System Metrics] dashboard. Adding/updating the [Kamon Dashboard] dashboard. When adding/updating the [Engdb Dashboard] dashboard, I got a 404: {"message":"Dashboard not found","status":"not-found"} Added the [Kamon Dashboard] dashboard. Checking existence of dashboard with slug kamon-dashboard Added the [System Metrics] dashboard. Checking existence of dashboard with slug system-metrics The dashboard with slug kamon-dashboard exists Dashboard file welcome.json has been loaded with slug kamon-dashboard The dashboard with slug system-metrics exists Dashboard file system-metrics.json has been loaded with slug system-metrics Adding/updating the [Engdb Dashboard] dashboard. When adding/updating the [Engdb Dashboard] dashboard, I got a 404: {"message":"Dashboard not found","status":"not-found"}
I'm really not sure what's going on here... it's like it's seeing the dashboard file, but not?
Any ideas? Thanks!
I have posted to a bit different issue question which would be better presented here. https://github.com/grafana/grafana/issues/273#issuecomment-232336390
On grafana installation from rpm, there is no dashboard_loader.log file. I have just checked /var/log/grafana/grafana.log file and nothing suspicious there.
I have found solution to provision dashboard by utilizing rest api of grafana (actually version 3.1, but versions 2.* should also work). Documentation for rest api is here: http://docs.grafana.org/reference/http_api/#create-update-dashboard
Sample curl command to send new dashboard (or update it): curl -X POST -d @prometheus-stats_rev2.json.request http://localhost:3000/api/dashboards/db --header "Content-Type: application/json" --header "Authorization: Bearer eyJrIjoiaWd___THIS_IS_AN_API_KEY_TO_GRAFANA_____aWQiOjF9" -sw 'STATUSCODE=%{http_code}' | grep 200 {"slug":"prometheus-stats","status":"success","version":1}STATUSCODE=200
File prometheus-stats_rev2.json.request should contain json with dashboard and overwrite attribute. For example something like this:
{
"dashboard": {
"id": null,
"title": "Production Overview",
"tags": [ "templated" ],
"timezone": "browser",
"rows": [{}],
"schemaVersion": 6,
"version": 0
},
"overwrite": true
}
To provision things like this, you can use these saltstack states (one will create file from template and second one will curl it to grafana. My example already contains some templating and actually states are included in three cycles (looping through applications, environments and instances).
File with salt state:
{% set grafana_token = salt['pillar.get']('grafana')['grafana_token'] %}
{% set grafana_url = salt['pillar.get']('grafana')['grafana_url'] %}
json.dashboard.request-{{ appName }}-{{ environment }}-{{ instance }}:
file.managed:
- name: /usr/share/grafana/public/dashboards/{{ appName }}.json.dashboard.request
- source: salt://grafana/dashboards/static/{{ appName }}.json.dashboard.request
- template: jinja
- context:
serviceName: {{ appName }}
environment: {{ environment }}
instance: {{ instance }}
dashboard.update-{{ appName }}-{{ environment }}-{{ instance }}:
cmd.run:
- name: "curl -X POST -d @/usr/share/grafana/public/dashboards/{{ appName }}.json.dashboard.request '{{ grafana_url }}/api/dashboards/db' --header 'Content-Type: application/json' --header 'Authorization: Bearer {{ grafana_token }}' -sw 'STATUSCODE=%{http_code}' | grep 'STATUSCODE=200'"
- require:
- file: json.dashboard.request-{{ appName }}-{{ environment }}-{{ instance }}
Pillar configuration for environment (containing api key and url):
grafana:
grafana_token: eyJrIjoiaWJlb3d1Rk1jTTFKMVA5VzBnU1dQU3dudmx2am1wMnkiLCJuIjoiZGFzaGJvYXJkTWFuYWdlbWVudEZyb21TYWx0IiwiaWQiOjF9
grafana_url: 'http://localhost:3000'
PS: Actually if you have recent saltstack, provisioning can be done also by internal salt module. More info: https://docs.saltstack.com/en/latest/ref/states/all/salt.states.grafana.html
I have the same problem with the same error message in the /var/log/supervisor/dashboard-loader.log
, i.e.
Adding/updating the [My Dashboard] dashboard.
When adding/updating the [My Dashboard] dashboard, I got a 404: {"message":"Dashboard not found","status":"not-found"}