Page 1 of 1

Possible to migrate users between instances?

Posted: Mon Jul 11, 2016 5:03 pm
by vAJ
I've built a very large set of users in my test instance. Given our very large AD tree, it's been quite an effort to get these users added over time.

Now those users all needed to be added to our Prod cluster. Any chance of being about to bulk-load users from one instance to another? Anyway to script it?

Re: Possible to migrate users between instances?

Posted: Tue Jul 12, 2016 11:58 am
by rkennedy
There isn't exactly a clean way to do this yet, but I've filed a feature request for it. ID #9051.

There is a way to do this though. On the machine that you have all of the accounts created, run the following command -

Code: Select all

curl -XGET 'http://localhost:9200/nagioslogserver/_search?type=user&pretty' | grep _source | sed -e 's/"_source"://' -e '/nagiosadmin/ d'
This will produce a list of users, similar to below -

Code: Select all

{"name":"frank","username":"frank","email":"[email protected]","password":"fcba8051ec9c89dfa788d2e093b54765629bc153237a2a4d26c0ae959500b4c5","apiaccess":"0","apikey":"","auth_type":"user","language":"default","auth_settings":[],"created":"2016-07-12 11:27:12","created_by":"1","default_dashboard":"\/dashboard\/elasticsearch\/AVXf7wsIHR1LuUxatCko"}
Now, take the information that is pulled from that command, and we can create a CURL request to use on the newly created machine, to add frank in. One thing to note, is the default_dashboard must be changed to /dashboard/elasticsearch/default. You'll also need to change the number 2 to an increasing value, in the CURL -- so if user id '2' already exists, use '3'. Everything else should be good to copy / paste -

Code: Select all

curl -XPUT 'http://localhost:9200/nagioslogserver/user/2' -d '{"name":"frank","username":"frank","email":"[email protected]","password":"fcba8051ec9c89dfa788d2e093b54765629bc153237a2a4d26c0ae959500b4c5","apiaccess":"0","apikey":"","auth_type":"user","language":"default","auth_settings":[],"created":"2016-07-12 11:27:12","created_by":"1","default_dashboard":"/dashboard/elasticsearch/default"}'

Re: Possible to migrate users between instances?

Posted: Tue Jul 12, 2016 1:05 pm
by vAJ
I'll give this a try and see if it meets my needs.

While we're adding feature requests, it would be great to have ability to pull up an AD group in the add user wizard and already grey out which users are already added.

Otherwise we can close this up. I'll PM you later if we need to open it back up or I have other issues with this backend fix.

Thanks,
Andrew

Re: Possible to migrate users between instances?

Posted: Tue Jul 12, 2016 1:31 pm
by rkennedy
Sounds good. I added a feature request to gray out AD users after they've been added, so they are unselectable once again. The ID is #9053.

One thing I almost over looked, you'll also need to modify the # in the link you POST to to increment as you add users -

Code: Select all

'http://localhost:9200/nagioslogserver/user/2'
I'll edit my original thread, and close this up.