Improve Eventgrid performance by limititing query time range, and only querying for hosts or services as requested in the form.

This commit is contained in:
Marc DeTrano 2018-01-04 09:09:35 -06:00 committed by Marc DeTrano
parent b69c9491ae
commit e7d117e1b6
5 changed files with 50 additions and 1 deletions

View File

@ -361,13 +361,16 @@ class ListController extends Controller
);
$orientationBox->applyRequest($this->getRequest());
*/
$objectType = $this->getParam('objecttype', 'services');
$from = date('c', $this->getParam('from', strtotime('midnight 3 months ago')));
$query = $this->backend->select()->from(
'eventgrid',
'eventgrid' . $objectType,
array('day', $form->getValue('state'))
);
$this->params->remove(array('objecttype', 'from', 'to', 'state', 'btn_submit'));
$this->view->filter = Filter::fromQuerystring((string) $this->params);
$query->applyFilter($this->view->filter);
$query->applyFilter(Filter::fromQuerystring('timestamp >= ' . $from));
$this->applyRestriction('monitoring/filter/objects', $query);
$this->view->summary = $query;
$this->view->column = $form->getValue('state');

View File

@ -0,0 +1,16 @@
<?php
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
class EventgridhostsQuery extends EventgridQuery
{
/**
* Join history related columns and tables, hosts only
*/
protected function joinHistory()
{
$this->fetchHistoryColumns = true;
$this->requireVirtualTable('hosts');
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
class EventgridservicesQuery extends EventgridQuery
{
/**
* Join history related columns and tables, services only
*/
protected function joinHistory()
{
$this->fetchHistoryColumns = true;
$this->requireVirtualTable('services');
}
}

View File

@ -0,0 +1,7 @@
<?php
namespace Icinga\Module\Monitoring\DataView;
class Eventgridhosts extends Eventgrid
{
}

View File

@ -0,0 +1,7 @@
<?php
namespace Icinga\Module\Monitoring\DataView;
class Eventgridservices extends Eventgrid
{
}