Griesbacher / histou

Adds templates to Grafana in combination with nagflux
GNU General Public License v2.0
35 stars 16 forks source link

Show all data for the same service with many hosts - one grafana dashboard #43

Closed bjornfro closed 3 years ago

bjornfro commented 3 years ago

First of all, thanks for the great effort doing this work!

Not an issue with Histou but a question:

I don't get how I can graph e.g. 100 CPU load graphs. Meaning the same service in Naemon in one Grafana dashboard. What would be the histou URL for that? Do I need to create a specific histou template for it? How is that addressed exactly?

Regards, Bjorn

Griesbacher commented 3 years ago

Hi Bjorn, I'm not actively developing on histou any more. If you are using OMD with Thruk then there should be a link for each service in the UI, which creates dynamic dashboards. If you are not using this setup, you have to configure everything on your own which is tricky ;) So I would recommend to use OMD with Thruk. Best regards, Philip

bjornfro commented 3 years ago

Sure, not demanding any support here, for sure ;-) Also, I have the setup working, just like I assume it's done in OMD. That is not the issue. This was just a question around how you use the histou templates. To for example create a dashboard for all hosts having a specific service, like CPU.

Tried to find some docs for it. Maybe I can figure it out, with some time.

Regards, Bjorn

sni commented 3 years ago

You can do this with grafana alone. Create dashboard variables and iterate over them, see https://grafana.com/docs/grafana/latest/variables/variable-examples/ Purpose of histou is to provide standard volatile dashboards.

dan-m-joh commented 3 years ago

We have done something like what you want (if I understand you correctly).

First we "select" all Hosts/Services that we want to have on the Graph using the RESTapi of Thruk into an array (host_services). GET https://<nagioshost>/thruk/r/hosts?columns=name,services&name[regex]=^abcdef host_services is an array of host_service objects with the properties host and service

Then we iterate over results and create a "histou-target" for each entry.

$dashboard = \histou\grafana\dashboard\DashboardFactory::generateDashboard($titel);
$row = new \histou\grafana\Row($titel);
$panel = \histou\grafana\graphpanel\GraphPanelFactory::generatePanel($titel);
foreach ($host_services as $host_service) {
    $target = $panel->genTargetSimple($host_service->host, $host_service->service, 'service', $key, Colors::color($i++), $host_service->host);
    $panel->addTarget($target);
    $panel->fillBelowLine($host_service->host, 5);
    $panel->stack($host_service->host);
}

This is the called using a specially "crafted" url.

Regards, Dan

bjornfro commented 3 years ago

Thanks guys. Now I know it's possible and can spend/waste some time on it!