Page 1 of 1

Set default dashboard view globally

Posted: Wed Jan 29, 2020 1:41 pm
by rferebee
Hello,

I was wondering if there is a way that I can set the dashboard view for all users to default to the last hour instead of the last day of logs?

We collect a lot and I think it would benefit overall system performance if we could limit the amount of data being loaded whenever someone launches the dashboard.

Thank you.

Re: Set default dashboard view globally

Posted: Wed Jan 29, 2020 4:41 pm
by cdienger
I will file a feature request for this, but in the meantime it could be done via the command line.

First, make a dashboard and then save it as a global dashboard. When you load the dashboard you'll see that the URL in the address bar of the browser changes to something like:

Code: Select all

https://nls///nagioslogserver/dashboard#/dashboard/elasticsearch/AW_srrCFUTbg9WYHPURN
Take note of the last part of the URL - the AW_srrCFUTbg9WYHPURN in my case.

Then run this on the command line:

Code: Select all

curl -XGET 'http://localhost:9200/nagioslogserver/user/_search?pretty'
This will return a result like:

Code: Select all

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "nagioslogserver",
      "_type" : "user",
      "_id" : "1",
      "_score" : 1.0,
      "_source":{"username":"nagiosadmin","username_lower":"nagiosadmin","name":"Nagios Administrator","password":"280d44ab1e9f79b5cce2dd4f58f5fe91f0fbacdac9f7447dffc318ceb79f2d02","auth_type":"admin","email":"root@localhost","language":"default","apiaccess":"1","apikey":"59ae99cc398e62680cb82fd631ffaf1f412f6dbf","created":"2020-01-28 09:04:19","created_by":0,"default_dashboard":"/dashboard/elasticsearch/AW_srrKeUTbg9WYHPURS"}
    } ]
  }
}
I got the above from a test machine with only one user to make it easier to read, but your system will likely return multiple users. You'll want to note the _id and copy the _source contents for each user that you want to push the dashboard to. Also see that each user has a default_dashboard field. This is what we'll be changing.

To update the user we'll copy the entire _source field and change the default_dashboard. In my example I would run:

Code: Select all

curl -XPUT 'http://localhost:9200/nagioslogserver/user/1' -d '{"username":"nagiosadmin","username_lower":"nagiosadmin","name":"Nagios Administrator","password":"280d44ab1e9f79b5cce2dd4f58f5fe91f0fbacdac9f7447dffc318ceb79f2d02","auth_type":"admin","email":"root@localhost","language":"default","apiaccess":"1","apikey":"59ae99cc398e62680cb82fd631ffaf1f412f6dbf","created":"2020-01-28 09:04:19","created_by":0,"default_dashboard":"/dashboard/elasticsearch/AW_srrCFUTbg9WYHPURN"}'
Be cautious with this method and make a system backup before making any changes. You can easily break NLS when you start modifying the database directly and having a back will make it easy to revert if needed. See https://assets.nagios.com/downloads/nag ... Server.pdf for steps to create a system backup and restore it before making any changes.

Re: Set default dashboard view globally

Posted: Wed Jan 29, 2020 6:22 pm
by rferebee
I appreciate the instructions, but I think I'll wait for the feature. This is more of a want than a need.

I don't want to modify the DB directly.

Re: Set default dashboard view globally

Posted: Thu Jan 30, 2020 10:09 am
by cdienger
Fair enough :)