Unable to create the new dashboard : 404 messageDashboard not found

I am trying to import a Grafana dashboard(JSON) to Grafana. Following is the ansible playbook

---
- name: task to parameterise grafana template
  hosts: localhost
  become: true
  user: root
  tasks:
    - name: Import Grafana dashboard
      grafana_dashboard:
        grafana_url: http://<host-ip>:3000
        state: present
        message: Updated by ansible
        uid: edO3sTlipu
        overwrite: yes
        path: "/home/centos/Kubernetes_cluster_monitoring.json"
And i am getting error below.

fatal: [localhost]: FAILED! => {"changed": false, "msg": "error : Unable to create the new dashboard None : 404 - {'status': 404, 'body': '{\"message\":\"Dashboard not found\",\"status\":\"not-found\"}', 'content-length': '54', 'url': 'http://<IP>:3000/api/dashboards/db', 'expires': '-1', 'msg': 'HTTP Error 404: Not Found', 'connection': 'close', 'pragma': 'no-cache', 'cache-control': 'no-cache', 'date': 'Wed, 08 Jan 2020 12:19:31 GMT', 'x-frame-options': 'deny', 'content-type': 'application/json'}."}

can you help please


I have found that leaving out the uid and letting it default to null has worked. The documentation doesn’t say explicitely but suggests it not be used for ‘state: present’

  • uid
    uid of the dashboard to export when state' is export’ or `absent’.
    [Default: (null)]
    version_added: 2.7

Yeah correct ,so i tried to run the playbook with uid as null ,but getting same error.

If you purposely redacted the IP from the output (http://:3000) then I am out of idea. Otherwise, that would be your issue

When your JSON file contain a id field, Grafana API will search for a dashboard with this id, and if it does not exists it return a 404. Hence delete this from your JSON file and run your playbook.