Can you update dashboard panels through HTTP requests?

Create (if it doesn’t exist) a directory /etc/grafana/provisioning/dashboards

Create a file there called dashboard.yaml

In the file put something along the lines of:

Create (if it doesn’t exist) a directory
/etc/grafana/provisioning/dashboards

Create a file there called dashboard.yaml

In the file put something along the lines of:

Er, the forum / list software appears to have eaten the remainder of my
posting, so here is it again. I’ve changed the row of dashes I used to indate
start and end of the file contents to something else, so hopefully you’ll see
what I wrote this time:

---------- Forwarded Message Starts ----------

through HTTP requests?

Create (if it doesn’t exist) a directory
/etc/grafana/provisioning/dashboards

Create a file there called dashboard.yaml

In the file put something along the lines of:
Er, the forum / list software appears to have eaten the remainder of my
posting, so here is it again. I’ve changed the row of dashes I used to
indate start and end of the file contents to something else, so hopefully
you’ll see what I wrote this time:

---------- Forwarded Message Starts ----------

through HTTP requests?

I have no idea what this forum / list is doing to my postings (nor even where
that last phrase above came from).

Here it is again without any symbols I think it might choose to interpret as
me wanting it to delete what I wrote…

You could post a picture of it if that’s easier?

I’m trying one final time.

That could work. I’ve read through that page and don’t really understand
how updates work with provisioning.

Create (if it doesn’t exist) a directory /etc/grafana/provisioning/dashboards

Create a file there called dashboard.yaml

In the file put something along the lines of:

apiVersion: 1

providers:

  • name: ‘My dashboard name’
    orgId: 1
    folder: ‘’
    folderUid: ‘My dashboard folder name’
    type: file
    updateIntervalSeconds: 3600
    options:
    path: /var/lib/grafana/dashboards

Then in /var/lib/grafana/dashboards (the path you just specified) put one or
more JSON files of the dashboards you want to be available.

So do I need to have a file with the
entire dashboard html + json (or just json?) code

Just JSON. Exactly what you get from “Share Dashboard -> Export -> Save to
File”.

and make changes to that file and then set grafana up to access that file
periodically

Yes, that’s where the updateIntervalSeconds comes in.

to reload the dashboard with the updated json code?

Exactly. Works (for me) a treat.

You can do the same thing for data sources if you want to - just put a .yaml
file into /etc/grafana/provisioning/datasources.

Antony.

Thank you very much for this!! I need to request access permission to the server system files to update these but I will attempt this.

One more question: Does provisioning create versions of a dashboard? For example setting the update interval seconds to 3600 means that theoretically the dashboard could change every 3600 seconds. Will a new version be saved for the dashboard being updated that could be reverted to later or does it only update the current version of the dashboard?

On my system (Debian 9 Stretch, Grafana 6.2.2) it does create multiple
versions every time a new release is detected.

However, unless I’ve got something wrong with my setup (please speak up,
anyone who knows what this might be), the old version are useless, because if
you try to restore to one from the “Dashboard Settings - Versions” screen, you
get the message “Cannot save provisioned dashboard”.

So, yes, the old versions are preserved, but no, you can’t restore to any of
them…

Antony.

Oh. Well that is a bummer. Maybe I can make an external version table to save the version prior to updating unless this is supposed to work? On the provisioning page it does mention that you can’t save to a provisioned dashboard. I wonder if since the provisioning source is different than the mysql grafana db if it stops saving the old versions to the grafana_version table. Especially if dashboards are being updated every couple of minutes/seconds.

Quick question: So I have the dashboard.yaml in the provisioning/dashboard folder, then I put the json files from the dashboard export in the same dashboard file or a separate dashboard file? I don’t have a grafana/dashboard file so I can create one and change the path to that or can I keep it in the provisioning/dashboard file? How do I make it start ‘running’ and updating based on the newer json?

Quick question: So I have the dashboard.yaml in the provisioning/dashboard
folder

Yes - and that contains a line “path: /var/lib/grafana/dashboards”

then I put the json files from the dashboard export in the same dashboard file
or a separate dashboard file?

You put them into any file you like in /var/lib/grafana/dashboards

From https://grafana.com/docs/administration/provisioning/ “When Grafana
starts, it will update/insert all dashboards available in the configured path.
Then later on poll that path every updateIntervalSeconds and look for updated
json files and update/insert those into the database.”

I don’t have a grafana/dashboard file

I’m not sure whether you meant to say “I don’t have a
/etc/grafana/provisiong/hasboards directory” or “I don’t have a file to put
into /var/lib/grafana/dashboards”.

so I can create one and change the path to that or can I keep it in the
provisioning/dashboard file?

No, sorry, you lost me. Please try to be more precise with your references to
filenames and directory names.

How do I make it start ‘running’ and updating based on the newer json?

Restart Grafana.

/etc/init.d/grafana-server restart (on Debian Stretch, at least)

Once you’ve done that, it will automatically pick up and implement any new
dashboard every updateIntervalSeconds.

Antony.

So is the full path name
/provisioning/dashboard/var/lib/grafana/dashboards ?

Hi, I’m assisting damienclark with this in our office. on the server, the path to the *.yaml is C:\Grafana\conf\provisioning\dashboards. we have a dashboard.yaml in that folder as well as a *.json file. After these files were updated, we went to cmd.exe and ran C:\Grafana\bin>grafana-server restart. However, we are still not seeing the dashboard appear. The code in the *.yaml is:

config file version

apiVersion: 1

providers:

  • name: ‘ND_TOBACCO_GARDEN’
    orgId: 12
    folder: ‘dashboards’

    type: file
    updateIntervalSeconds: 60
    options:
    path: /grafana/conf/provisioning

Is this correct? Thanks, NOelle

Hi, I’m assisting damienclark with this in our office. on the server, the
path to the *.yaml is C:\Grafana\conf\provisioning\dashboards.

Ah. That tells me you’re running this on Windows, and I have no experience of
how the Windows paths work. All I can say is that it does look plausible.

we have a dashboard.yaml in that folder as well as a *.json file.

What’s in the *.json file??

After these files were updated, we went to cmd.exe and ran
C:\Grafana\bin>grafana-server restart.

I can only assume that’s the normal Windows method of restarting Grafana.

However, we are still not seeing the dashboard appear.

Any clues in the log file (on Linux it’s in /var/log/grafana/grafana/log )?

The code in the *.yaml is:

config file version

apiVersion: 1

providers:

  • name: ‘ND_TOBACCO_GARDEN’
    orgId: 12
    folder: ‘dashboards’

    type: file
    updateIntervalSeconds: 60
    options:
    path: /grafana/conf/provisioning

I’m certain you’d need to change the path in the last line to point at
something plausible on your Windows machine.

From https://grafana.com/docs/administration/provisioning/ “When Grafana
starts, it will update/insert all dashboards available in the configured
path. Then later on poll that path every updateIntervalSeconds and look
for updated json files and update/insert those into the database.”
[/quote]

So is the full path name
/provisioning/dashboard/var/lib/grafana/dashboards ?

No.

The .yaml file in (under Linux) /etc/grafana/provisioning/dashboards contains a
path (in my example /var/lib/grafana/dashboards but you can set it to anything
that suits you), and that is where the JSON file/s for the dashboard/s go.

Regards,

Antony.

It is the dashboard json file from exporting via the share button on the dashboard page.

t=2019-06-18T08:41:43-0600 lvl=info msg="Config loaded from" logger=settings file=C:\\Grafana/conf/defaults.ini
t=2019-06-18T08:41:43-0600 lvl=info msg="Config loaded from" logger=settings file=C:\\Grafana\\conf\\custom.ini
t=2019-06-18T08:41:43-0600 lvl=info msg="Path Home" logger=settings path=C:\\Grafana
t=2019-06-18T08:41:43-0600 lvl=info msg="Path Data" logger=settings path=C:\\Grafana\\data
t=2019-06-18T08:41:43-0600 lvl=info msg="Path Logs" logger=settings path=C:\\Grafana\\data\\log
t=2019-06-18T08:41:43-0600 lvl=info msg="Path Plugins" logger=settings path=C:\\Grafana\\data\\plugins
t=2019-06-18T08:41:43-0600 lvl=info msg="Path Provisioning" logger=settings path=C:\\Grafana\\conf\\provisioning
t=2019-06-18T08:41:43-0600 lvl=info msg="App mode production" logger=settings
t=2019-06-18T08:41:43-0600 lvl=info msg="Ldap enabled, reading config file" logger=ldap file=C:\\Grafana\\conf\\ldap.toml
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing HTTPServer" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing SqlStore" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Connecting to DB" logger=sqlstore dbtype=mysql
t=2019-06-18T08:41:43-0600 lvl=info msg="Starting DB migration" logger=migrator
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing SearchService" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing RenderingService" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing AlertingService" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing DatasourceCacheService" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing HooksService" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing InternalMetricsService" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing CleanUpService" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing NotificationService" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing ProvisioningService" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing PluginManager" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Starting plugin search" logger=plugins
t=2019-06-18T08:41:43-0600 lvl=eror msg="Plugins: Failed to load plugin json file: C:\\Grafana\\public\\app\\plugins\\datasource\\testdata\\plugin.json,  err: Plugin with same id already exists"
t=2019-06-18T08:41:43-0600 lvl=info msg="Registering plugin" logger=plugins name="Datatable Panel"
t=2019-06-18T08:41:43-0600 lvl=info msg="Registering plugin" logger=plugins name="D3 Gauge"
t=2019-06-18T08:41:43-0600 lvl=info msg="Registering plugin" logger=plugins name="Azure Data Explorer Datasource"
t=2019-06-18T08:41:43-0600 lvl=info msg="Registering plugin" logger=plugins name=Drill
t=2019-06-18T08:41:43-0600 lvl=info msg="Registering plugin" logger=plugins name=SimpleSql
t=2019-06-18T08:41:43-0600 lvl=info msg="Registering plugin" logger=plugins name=Diagram
t=2019-06-18T08:41:43-0600 lvl=info msg="Registering plugin" logger=plugins name=Discrete
t=2019-06-18T08:41:43-0600 lvl=info msg="Registering plugin" logger=plugins name=Plotly
t=2019-06-18T08:41:43-0600 lvl=info msg="Registering plugin" logger=plugins name=Heatmap
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing TracingService" logger=server
t=2019-06-18T08:41:43-0600 lvl=info msg="Initializing Stream Manager"
t=2019-06-18T08:41:43-0600 lvl=info msg="HTTP Server Listen" logger=http.server address=0.0.0.0:80 protocol=http subUrl= socket=
t=2019-06-18T08:41:43-0600 lvl=eror msg="Stopped HTTPServer" logger=server reason="listen tcp 0.0.0.0:80: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."
t=2019-06-18T08:41:43-0600 lvl=info msg="Stopped Stream Manager"
t=2019-06-18T08:41:43-0600 lvl=info msg="Stopped ProvisioningService" logger=server reason="context canceled"
t=2019-06-18T08:41:43-0600 lvl=info msg="Stopped InternalMetricsService" logger=server reason="context canceled"
t=2019-06-18T08:41:43-0600 lvl=info msg="Stopped NotificationService" logger=server reason="context canceled"
t=2019-06-18T08:41:43-0600 lvl=info msg="Stopped CleanUpService" logger=server reason="context canceled"
t=2019-06-18T08:41:43-0600 lvl=info msg="Stopped RenderingService" logger=server reason=nil
t=2019-06-18T08:41:43-0600 lvl=info msg="Stopped TracingService" logger=server reason=nil
t=2019-06-18T08:41:43-0600 lvl=info msg="Stopped AlertingService" logger=server reason="context canceled"
t=2019-06-18T08:41:43-0600 lvl=info msg="Stopped PluginManager" logger=server reason="context canceled"
t=2019-06-18T08:41:43-0600 lvl=eror msg="Server shutdown" logger=server reason="listen tcp 0.0.0.0:80: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.

These are the logs after restarting grafana.

config file version

apiVersion: 1

providers:

  • name: ‘ND_TOBACCO_GARDEN-1560804286932’
    orgId: 12
    folder: ‘dashboards’

    type: file
    updateIntervalSeconds: 60
    options:
    path: ‘C:\Grafana\conf\provisioning’

This is what I’ve changed it to.

Still not seeing updates to the dashboard though.

EDIT: Do you need to change the UID in the .json file to allow for provisioning?

It is the dashboard json file from exporting via the share button on the
dashboard page.

I would recommend removing it from that directory, because it is not needed
there and can only serve to confuse someone later on.

t=2019-06-18T08:41:43-0600 lvl=eror msg=“Plugins: Failed to load plugin json
file: C:\Grafana\public\app\plugins\datasource\testdata\plugin.json,
err: Plugin with same id already exists”

That’s not so serious, but you should still deal with it.

t=2019-06-18T08:41:43-0600 lvl=info msg=“HTTP Server Listen”
logger=http.server address=0.0.0.0:80 protocol=http subUrl= socket=

t=2019-06-18T08:41:43-0600 lvl=eror msg=“Stopped HTTPServer” logger=server
reason=“listen tcp 0.0.0.0:80: bind: Only one usage of each socket address
(protocol/network address/port) is normally permitted.”

That one is serious, and needs dealing with, otherwise Grafana will never
start.

It tells me you have some other process already listening on port 80 on this
machine (Grafana normally listens on port 3000, so you must have changed this
in a config file), therefore Grafana can’t use port 80 as well.

t=2019-06-18T08:41:43-0600 lvl=eror msg=“Server shutdown” logger=server
reason="listen tcp 0.0.0.0:80: bind: Only one usage of each socket address
(protocol/network address/port) is normally permitted.

path: 'C:\Grafana\conf\provisioning'

This is what I’ve changed it to.

I suppose that’s alright, although it strikes as being just a little bit
recursive…

If it works after you’ve fixed the network port problem, though, then it’s
obviously fine.

Antony.

Hi,
I updated the config file to point to 3000 and restarted the service on the server. Still no dice with the dashboard…
Thanks, Noelle

What do the last few lines of your Grafana log file tell you now?

Does the service appear to be actually starting?

Are you able to get a login prompt when you point a browser at
http://gra.fana.ser.ver:3000 ?

Do you have any manually configured dashboards on the server - do they display
okay in a browser, before adding the complexity of an auto-provisoned one?

Antony.

This is what we’re seeing from the log file.

image

It seems the provisioning isn’t working properly because it can’t find the dashboard folder but we can’t figure out why. I’m attaching images of the paths portions of our default.ini and custom.ini.

Default:
image

Custom:
image

I’m also attaching a screenshot of the grafana folders. We added the dashboard json file to the var/lib/grafana/dasboards path but I don’t know if that is properly set up?

image
image

We have our dashboard.yaml file in the provisioning/dashboards folder but since the provisioning is ending prior to reaching this folder it isn’t being referenced. I’m not sure it is set up correctly either.

image
image

Any insight?

My guess is that the problem is a combination of:

a) some paths being specified using / as the separator and some using \

b) some paths being absolute (starting with \ or /) and some being relative
(not starting with \ or /)

c) the fact that you’re on a Windows system and most of the documentation
assumes Linux.

So, as a starting point, try making all the paths consistent - use / as the
separator throughout, with no instances of , and also make them all relative
(ie: remove any / at the start of the path name).

If that doesn’t work, try making all paths absolute (ie: starting with
C:/Grafana/…) and see if that gets you any further.

Regards,

Antony.

t=2019-07-15T08:48:17-0600 lvl=info msg="Config loaded from" logger=settings file=C:\\Grafana/conf/defaults.ini
t=2019-07-15T08:48:17-0600 lvl=info msg="Config loaded from" logger=settings file=C:\\Grafana\\conf\\custom.ini
t=2019-07-15T08:48:17-0600 lvl=info msg="Path Home" logger=settings path=C:\\Grafana
t=2019-07-15T08:48:17-0600 lvl=info msg="Path Data" logger=settings path=C:\\Grafana\\data
t=2019-07-15T08:48:17-0600 lvl=info msg="Path Logs" logger=settings path=C:\\Grafana\\data\\log
t=2019-07-15T08:48:17-0600 lvl=info msg="Path Plugins" logger=settings path=C:\\Grafana\\data\\plugins
t=2019-07-15T08:48:17-0600 lvl=info msg="Path Provisioning" logger=settings path=C:\\Grafana\\conf\\provisioning
t=2019-07-15T08:48:17-0600 lvl=info msg="App mode development" logger=settings
t=2019-07-15T08:48:17-0600 lvl=info msg="Ldap enabled, reading config file" logger=ldap file=C:\\Grafana\\conf\\ldap.toml
t=2019-07-15T08:48:17-0600 lvl=info msg="Initializing HTTPServer" logger=server
t=2019-07-15T08:48:17-0600 lvl=info msg="Initializing SqlStore" logger=server
t=2019-07-15T08:48:17-0600 lvl=info msg="Connecting to DB" logger=sqlstore dbtype=mysql
t=2019-07-15T08:48:17-0600 lvl=info msg="Starting DB migration" logger=migrator
t=2019-07-15T08:48:17-0600 lvl=info msg="Initializing SearchService" logger=server
t=2019-07-15T08:48:17-0600 lvl=info msg="Initializing RenderingService" logger=server
t=2019-07-15T08:48:17-0600 lvl=info msg="Initializing AlertingService" logger=server
t=2019-07-15T08:48:17-0600 lvl=info msg="Initializing DatasourceCacheService" logger=server
t=2019-07-15T08:48:17-0600 lvl=info msg="Initializing HooksService" logger=server
t=2019-07-15T08:48:17-0600 lvl=info msg="Initializing InternalMetricsService" logger=server
t=2019-07-15T08:48:17-0600 lvl=info msg="Initializing CleanUpService" logger=server
t=2019-07-15T08:48:17-0600 lvl=info msg="Initializing NotificationService" logger=server
t=2019-07-15T08:48:17-0600 lvl=info msg="Initializing ProvisioningService" logger=server
t=2019-07-15T08:48:17-0600 lvl=info msg="Initializing PluginManager" logger=server
t=2019-07-15T08:48:17-0600 lvl=info msg="Starting plugin search" logger=plugins
t=2019-07-15T08:48:17-0600 lvl=info msg="Registering plugin" logger=plugins name="Datatable Panel"
t=2019-07-15T08:48:17-0600 lvl=info msg="Registering plugin" logger=plugins name="D3 Gauge"
t=2019-07-15T08:48:17-0600 lvl=info msg="Registering plugin" logger=plugins name="Azure Data Explorer Datasource"
t=2019-07-15T08:48:17-0600 lvl=info msg="Registering plugin" logger=plugins name=Drill
t=2019-07-15T08:48:18-0600 lvl=info msg="Registering plugin" logger=plugins name=SimpleSql
t=2019-07-15T08:48:18-0600 lvl=info msg="Registering plugin" logger=plugins name=Diagram
t=2019-07-15T08:48:18-0600 lvl=info msg="Registering plugin" logger=plugins name=Discrete
t=2019-07-15T08:48:18-0600 lvl=info msg="Registering plugin" logger=plugins name=Plotly
t=2019-07-15T08:48:18-0600 lvl=info msg="Registering plugin" logger=plugins name=Heatmap
t=2019-07-15T08:48:18-0600 lvl=info msg="Initializing TracingService" logger=server
t=2019-07-15T08:48:18-0600 lvl=eror msg="can't read dashboard provisioning files from directory" logger=provisioning.dashboard path=C:\\Grafana\\conf\\provisioning/dashboards
t=2019-07-15T08:48:18-0600 lvl=info msg="Initializing Stream Manager"
t=2019-07-15T08:48:18-0600 lvl=info msg="HTTP Server Listen" logger=http.server address=0.0.0.0:80 protocol=http subUrl= socket=

We’re having trouble locating where the

logger=provisioning.dashboard path=C:\Grafana\conf\provisioning/dashboards

portion of this message is coming from. We don’t have the provisioning/dashboards pathway set anywhere in either of our custom or default ini files. We can’t find where it is trying to access that pathway since it isn’t specified in either of those files but we believe that is the issue.