icingaweb2-module-graphite/application/forms/Config/BackendForm.php
Adam James 5e0d57cce0 Add Graphite Web HTTP request timeout option
If the Graphite Web server is unreachable, all requests for frontend
pages containing graphs hang until the backend HTTP request times out,
resulting in a very poor UX.

The Guzzle documentation states that the default behaviour is to wait
indefinitely, however in our testing the cURL handler has an internal
default of 30 seconds:

https://docs.guzzlephp.org/en/stable/request-options.html#timeout

This commit makes the HTTP request timeout configurable and sets a
reasonable default of 10 seconds.
2024-02-20 15:43:34 +01:00

69 lines
2.3 KiB
PHP

<?php
namespace Icinga\Module\Graphite\Forms\Config;
use Icinga\Forms\ConfigForm;
use Icinga\Module\Graphite\Web\Form\Validator\HttpUserValidator;
class BackendForm extends ConfigForm
{
public function init()
{
$this->setName('form_config_graphite_backend');
$this->setSubmitLabel($this->translate('Save Changes'));
}
public function createElements(array $formData)
{
$this->addElements([
[
'text',
'graphite_url',
[
'required' => true,
'label' => $this->translate('Graphite Web URL'),
'description' => $this->translate('URL to your Graphite Web'),
'validators' => ['UrlValidator']
]
],
[
'text',
'graphite_user',
[
'label' => $this->translate('Graphite Web user'),
'description' => $this->translate(
'A user with access to your Graphite Web via HTTP basic authentication'
),
'validators' => [new HttpUserValidator()]
]
],
[
'password',
'graphite_password',
[
'renderPassword' => true,
'label' => $this->translate('Graphite Web password'),
'description' => $this->translate('The above user\'s password')
]
],
[
'checkbox',
'graphite_insecure',
[
'label' => $this->translate('Connect insecurely'),
'description' => $this->translate('Check this to not verify the remote\'s TLS certificate')
]
],
[
'number',
'graphite_timeout',
[
'label' => $this->translate('Request timeout'),
'description' => $this->translate('The timeout for HTTP requests to Graphite Web'),
'min' => 0,
'placeholder' => 10
]
]
]);
}
}