Mikesch-mp / icingaweb2-module-grafana

Grafana module for Icinga Web 2 (supports InfluxDB & Graphite)
https://icinga.com/community/
GNU General Public License v2.0
240 stars 93 forks source link

"Disable Graph" feature seems broken #111

Closed GalipoliX closed 6 years ago

GalipoliX commented 6 years ago

Expected Behavior

Setting a variable "grafana_graph_disable" to any value (in this case true) should disable the graph rendering for the matching service.

Current Behavior

Graph still shown without data (No data points).

Context

This is an example config:

apply Service "NRPE" {
import "check_nrpe_alive"

assign where host.vars.os == "windows"
vars.grafana_graph_disable = true
import DirectorOverrideTemplate

Environment

Mikesch-mp commented 6 years ago

Just tested it and it works like it should be. "grafana_graph_disable" only works if you didnt set another variable in the module config. Can you please provide your config.ini of the module.

Regards, Carsten

GalipoliX commented 6 years ago

Sure. Here it is:

[grafana] host = "graph.:3000" protocol = "http" defaultdashboard = "icinga2-default" defaultorgid = "1" shadows = "1" defaultdashboardstore = "db" theme = "dark" datasource = "influxdb" accessmode = "proxy" debug = "1" height = "280" width = "1024" enableLink = "yes" authanon = "no" username = "admin" password = "secret" usepublic = "no" timerange = "12h"

No custom variable defined.

Mikesch-mp commented 6 years ago

Hmm really strange. Will do another test tomorrow.

GalipoliX commented 6 years ago

I guess that something went wrong with the vars deployed by icinga director. I will do further research tomorow.

GalipoliX commented 6 years ago

I tried a few things but i cant get this to work again. If i inspect the service in the gui the var is there:

type: "Service", vars: { grafana_graph_disable: "yes", param1: "$host.vars.blub$", param2: "param2", param3: "param3" },

but the graph is still beeing shown :(

Any ideas ?

ghost commented 6 years ago

Works for me like a charm too. Can you try to define vars.grafana_graph_disable as an boolean in your director configuration?

Here my working configuration:

Service Example

apply Service "Interface Status - " for (config in host.vars.interfaces) {
    import DirectorOverrideTemplate
    ...
    vars.grafana_graph_disable = true
    assign where host.vars.interfaces
}

grafana/config.ini

[grafana]
host = "localhost:3000"
protocol = "http"
defaultorgid = "1"
shadows = "0"
defaultdashboardstore = "db"
theme = "light"
datasource = "graphite"
accessmode = "proxy"
height = "300"
width = "660"
enableLink = "yes"
debug = "1"
defaultdashboard = "graphite-icinga2-default"
usepublic = "yes"
publichost = "myhostname/grafana"
publicprotocol = "https"
authanon = "yes"

Environment Icinga Web 2 Grafana version: 1.1.10 Icinga Web 2 version: 2.5.0 Icinga2 version: r2.8.1-1 Operating System and version: CentOS Linux release 7.4.1708 (Core) Enabled features: api checker command graphite ido-mysql livestatus mainlog notification Config validation: All valid

Best regards, Marcel

GalipoliX commented 6 years ago

I reinstalled the complete grafana module and started with a clean /etc/icingaweb2/modules/grafana directory. I also deleted the disable_grafana_graph var in director.

Then i recreated it with type boolean an added it to one of my service templates. After this i set the var to true in my ServiceSet.

The graph is still there :( If i inspect the service in icingaweb2 the var is visible:

type: "Service",
vars: {
  grafana_graph_disable: true,
  nrpe_arguments: [
    "advertising",
    "verbose"
  ],

Any chance of debugging this on my side ?

Mikesch-mp commented 6 years ago

Give me some more days. Iam rewriting some debugging features.

GalipoliX commented 6 years ago

Yeah sure! Thanks for your help!!!!

Mikesch-mp commented 6 years ago

Hi @GalipoliX ,

please clone the 1.2.0 branch, there i added the 'brand new' :) debug feature.

Best regards, Carsten

GalipoliX commented 6 years ago

Hey, the debug feature tells me:

Disable graph custom variable | grafana_graph_disable-- | --

But the graph is still there.

:(

Mikesch-mp commented 6 years ago

@GalipoliX

iam getting out of ideas. If you want we can do a teamviewer/skype session so i can directly see the output and whats going maybe wrong.

GalipoliX commented 6 years ago

@Mikesch-mp sorry for not replying. Had been some busy weeks. Today i got time to analyze the troblem. It seems that the Grapher.php is unable to read the custom vars. The Debugging feature shows none. I added "var_dump($customVars);" to line 486 in Grapher.php and the result is: array(0) { }

So it cant trigger. Is there anything that blocks the access to the vars?

Any Idea with this new information? Sure we can do a teamviewer/skype session. You can contact me when you have time (michael@geschwinder.net)

Thanky for your help!

Mikesch-mp commented 6 years ago

I found the problem, boolean in customvars are not real boolean. Have to trick convert them first ...

Mikesch-mp commented 6 years ago

@killepitisch and @GalipoliX can you please test the latest master and report if it is working now for you or not

killepitisch commented 6 years ago

@Mikesch-mp Release 1.2.5 works fine for me, thx!

GalipoliX commented 6 years ago

I think you can close this Ticket. My Icingaweb2 Installation themes broken in some kind. Have some strange behaviour. I installed Icingaweb2 and the Grafana Module on a different Server and pointed it to the same IDO Database. The result is that everything works as expected.

Thanks for your help!

GalipoliX commented 6 years ago

Sry to correct me here but i tracked ist down further more. This issue only occurs if i access the icingaweb2 page via apache2 vhost. I have some other issuses with this, for example in the left sidebar the number off host and service issues is allways purple and shows one issue.

I used the vhost Configuration described in the icingaweb2 documentation.

Can you confirm that there is an issue ?

Edit: It also happens if i access the site with an DNS entry (no vhost). Only IP address seems to work as expected.

GalipoliX commented 6 years ago

I finally found the issue! It was this: https://monitoring-portal.org/t/host-problems-flag-showing-despite-no-actual-host-problems/2638/10

An error in the roles.ini caused all of my problems.

Thanks!