icingaweb2-module-grafana
icingaweb2-module-grafana copied to clipboard
Add icingadb support for grafana module
@Mikesch-mp Hi, it would be nice to have support for IcingaDB in this module. Could you take a look at this and merge it if it is ok? :-) Thank you very much
$ sudo icingacli module enable grafana Enabling module "grafana" although it has unmet dependencies
Same here
@KornesWerkman thank you for reporting this. I have already fixed this dependency issue here. You could try testing the module with the updated code.
When I try to work with your branch feature/icingadb-support
, I get some ipl related errors on service or host detail page:
Uncaught Error: Object of class ipl\Orm\Query could not be converted to string in /usr/share/icingaweb2/library/Icinga/Application/Config.php:294 Stack trace: #0 /data/modules/grafana/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php(219): Icinga\Application\Config->hasSection() #1 /data/modules/grafana/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php(383): Icinga\Module\Grafana\ProvidedHook\Icingadb\ServiceDetailExtension->getGraphConf() #2 /data/modules/grafana/library/Grafana/ProvidedHook/Icingadb/ServiceDetailExtension.php(24): Icinga\Module\Grafana\ProvidedHook\Icingadb\ServiceDetailExtension->getPreviewHtml() #3 /data/modules/icingadb/library/Icingadb/Hook/ExtensionHook/ObjectDetailExtensionHook.php(98): Icinga\Module\Grafana\ProvidedHook\Icingadb\ServiceDetailExtension->getHtmlForObject() #4 /data/modules/icingadb/library/Icingadb/Widget/Detail/ObjectDetail.php(429): Icinga\Module\Icingadb\Hook\ExtensionHook\ObjectDetailExtensionHook::loadExtensions() #5 /data/modules/icingadb/library/
#0 [internal function]: Icinga\Application\Web->Icinga\Application{closure}() #1 {main}
With this installation:
Loaded Libraries icinga/icinga-php-thirdparty 0.11.0 icinga/icinga-php-library 0.9.1
Loaded Modules director master grafana 1.4.2 icingadb 1.0.0 incubator 0.17.0
@verboEse I have updated the code with a fix for this. Thank you for bringing it to my attention. You could try using the updated code.
@raviks789 The error is gone, but for me, it shows "No data" now everywhere. My best guess so far is, that the generated URL is wrong. Maybe the reason is, that (at least at one point in library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php:312
) the servicename is used for the command parameter.
looks better
Question on the side: Any special reason you are force pushing every time and not adding single commits? Would have been nice to see what changed in between.
@RincewindsHat : No special reason. I thought that these changes should be in the same commit.
I have made the following changes in the class Icinga\Module\Grafana\ProvidedHook\Icingadb\IcingaDbGrapher
-
$object->checkcommand
to$object->checkcommand_name
everywhere it is used. - On line 312
rawurlencode($serviceName)
torawurlencode($this->object->checkcommand_name)
Hm. I still don't get an inline image, but this error (when trying to open the IMG in a new tab):
Uncaught Error: Class 'Icinga\Module\Graphite\ProvidedHook\Icingadb\IcingadbSupport' not found in /data/modules/grafana/library/Grafana/Web/Controller/IcingadbGrafanaController.php:23 Stack trace: #0 /usr/share/icingaweb2/library/Icinga/Web/Controller/ModuleActionController.php(28): Icinga\Module\Grafana\Web\Controller\IcingadbGrafanaController->moduleInit() #1 /usr/share/icinga-php/ipl/vendor/ipl/web/src/Compat/CompatController.php(44): Icinga\Web\Controller\ModuleActionController->prepareInit() #2 /usr/share/icingaweb2/library/Icinga/Web/Controller/ActionController.php(169): ipl\Web\Compat\CompatController->prepareInit() #3 /usr/share/icingaweb2/library/Icinga/Web/Controller/Dispatcher.php(59): Icinga\Web\Controller\ActionController->__construct() #4 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch() #5 /usr/share/icingaweb2/library/Icinga/Application/Web.php(290): Zend_Controller_Front->dispatch() #6 /usr/share/icingaweb2/library/Icinga/Applica
#0 [internal function]: Icinga\Application\Web->Icinga\Application{closure}() #1 {main}
... a problem with my config?
@verboEse No, your config is correct. Instead of using class Icinga\Module\Grafana\ProvidedHook\Icingadb\IcingadbSupport
, I was using Icinga\Module\Graphite\ProvidedHook\Icingadb\IcingadbSupport
in IcingadbGrafanaController
. Thank you for reporting this. I have fixed this issue now.
next problems:
- the image for a service gets this error:
Undefined property: ipl\Orm\Query::$name
#0 /data/modules/grafana/application/controllers/IcingadbimgController.php(167): Icinga\Application\ApplicationBootstrap->Icinga\Application{closure}() #1 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action.php(507): Icinga\Module\Grafana\Controllers\IcingadbimgController->indexAction() #2 /usr/share/icingaweb2/library/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch() #3 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch() #4 /usr/share/icingaweb2/library/Icinga/Application/Web.php(290): Zend_Controller_Front->dispatch() #5 /usr/share/icingaweb2/library/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch() #6 /usr/share/icingaweb2/public/index.php(4): require_once(String) #7 {main}
- the image for a host has this error:
strtok() expects parameter 1 to be string, object given
#0 [internal function]: Icinga\Application\ApplicationBootstrap->Icinga\Application{closure}() #1 /data/modules/grafana/application/controllers/IcingadbimgController.php(289): strtok() #2 /data/modules/grafana/application/controllers/IcingadbimgController.php(184): Icinga\Module\Grafana\Controllers\IcingadbimgController->setGraphConf() #3 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action.php(507): Icinga\Module\Grafana\Controllers\IcingadbimgController->indexAction() #4 /usr/share/icingaweb2/library/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch() #5 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch() #6 /usr/share/icingaweb2/library/Icinga/Application/Web.php(290): Zend_Controller_Front->dispatch() #7 /usr/share/icingaweb2/library/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch() #8 /usr/share/icingaweb2/public/index.php(4): require_once(String) #9 {main}
@verboEse I have fixed the issue. Could you try testing it again? Let me know if you face other issues. Thank you.
Hi @Mikesch-mp , what's about this PR? We switched to Icingadb and have several problems right now, e.g. grafana_graph_disable not working anymore and all the other already reported issues with icingadb
Hello all,
fist i want to thank @raviks789 so far for his work. But all of this only works if you upgraded (aka have a "Monitoring" module backend configuration) from Montoring module to IcingaDB. If you use fresh and clean IcingaDB only install, the Grafana module will not work.
I will do a rewrite of the module so it will work only with icingadb, but there are so many new things that it will tkae some time.
Hi all, just FYI ... I had similar issue with displaying the performance data with grafana module. It was just not displayed at all when "monitoring" module was disabled. After deep-dive I found there is a diff in code for "icingadb" installed from repo and "icingadb" cloned from git. When installed from repo no issue with displaying grafana charts.
If I'm right the reason/main diff related to displaying grafana module is in icingadb/library/Icingadb/Widget/Detail/ObjectDetail.php
file.
There I found (in the cloned version) these lines (around line #450):
if (! Module::exists('monitoring')) {
return $extensions;
}
when commented out, the grafana module appeared on the page ...
Not sure if correct modification, but have not found any issue so far.
Just tried to add a graph to a new dashboard and got this stacktrace:
Required parameter 'host' missing
#0 /usr/share/icingaweb2/modules/grafana/application/controllers/IcingadbdashboardController.php(37): Icinga\Web\UrlParams->getRequired()
#1 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action.php(507): Icinga\Module\Grafana\Controllers\IcingadbdashboardController->indexAction()
#2 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch()
#3 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch()
#4 /usr/share/php/Icinga/Application/Web.php(290): Zend_Controller_Front->dispatch()
#5 /usr/share/php/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch()
#6 /usr/share/icingaweb2/public/index.php(4): require_once(String)
#7 {main}
hi @raviks789, hi @Mikesch-mp , there seems to be another error in raviks789 fork; is it ok to post this here? Hope so :)
Services with space in name are wrongly urlencoded (wrongly means twice).
/grafana/icingadbimg?host=abc.de&service=cluster%2520zone
instead of
/grafana/icingadbimg?host=abc.de&service=cluster%20zone
I changed line 266 in /library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php and set 'service' => $serviceName
, instead of 'service' => rawurlencode($serviceName)
, which seems to work though unsure if that is the correct location to "fix" this.
@raviks789 Sorry to be annoying, but are there any updates on this? I am switching new setups to IcingaDB and this is kinda needed for that
I've setup a brand new Icinga installation with IcingaDB (never had monitoring installed) and are having issues displaying graphs as well.
When trying to browse the graph URL as printed when debugging is turned on (i.e. https://icinga.domain.com/grafana/img?host=myhost&service=Ping&panelid=1&timerange=now-6h&timerangeto=now&cachetime=4.3310000896454), I get error "No backend has been configured" from the /usr/share/icingaweb2/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php file (line 178).
Reading all the comments in this thread, it seems like IcingaDB is not supported (even though it seems like the master branch has had some updates to address that).
Edit: @raviks789 fork did the trick! :)
@raviks789 @Mikesch-mp could you please implement macro expanding here? See: https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/281#issuecomment-1432889652
So the curstom variable resolution problem can be fixed with v2.0 :)