Chronograf dashboard import/export

Hello,
I have some dashboards configured on a test environment.
Database names are the same than on staging and production environment.
Is there any way to export a dashboard from one chronograf setup and import it in another one ?
Thanks
Fabrice

Yes, it is! It will require a bit of scripting though.

You can download all dashboards from the source host using the API provided by the Chronograf backend at http://<source-host-ip>:<source-host-port>/chronograf/v1/dashboards You’ll need to iterate through the dashboards key and POST each item in that array to http://<dest-host-ip>:<dest-host-port>/chronograf/v1/dashboards

Doing this in Ruby would look something like:

require 'net/http'
require 'json'

src_uri = URI('http://localhost:8888/chronograf/v1/dashboards')
dest_uri = URI('http://localhost:9999/chronograf/v1/dashboards')

dashboards = JSON.parse(Net::HTTP.get(src_uri))
client = Net::HTTP.new(dest_uri.host, dest_uri.port)

errs = []

dashboards["dashboards"].each do |dashboard|
  req = Net::HTTP::Post.new(dest_uri.path, 'Content-Type' => 'application/json')
  req.body = dashboard.to_json
  res = client.request(req)
  if res.code != "201"
    puts "Error creating dashboard ID: #{dashboard["id"]}"
    errs << req if res.code != "201"
  else
    puts "Dashboard ID: #{dashboard["id"]} added successfully!"
  end
end

I haven’t actually run this script, so I can’t guarantee it’ll work, but it illustrates the idea :slight_smile:

2 Likes

Hi @tim
I have a similar use case but with one noticeable difference - I want to migrate my chronograf dashboards from a test instance to an InfluxCloud instance.

The problem is as you can imagine, InfluxCloud APIs are authenticated but I don’t see any mention of how to use authentication to access data. I am able to get the dashboard data out of my test instance easily but there is no way to POST that data to chronograf on InfluxCloud since the APIs won’t work without an auth token.

Two questions then:

  1. How do I use auth with dashboard APIs in InfluxCloud?
  2. Any other quick way to export chronograf dashboards from test instance to InfluxCloud instance?

Thanks!

Hello,
We finally implement it like tim propose to do with a little python script using the API/
Fabrice

Hello

I have basic TICK stack up & can see out of box dashboard gives me vitals stats. i looked at https://github.com/influxdata/chronograf but it is not clear how can i import any dashboards as what we use for telegraf - grafana which is very easy

thanks