Griesbacher / histou

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

are wildcards supported in rule:perfLabel array? #10

Closed MrMontesa closed 7 years ago

MrMontesa commented 7 years ago

Hey, I'm in the middle of testing the Histou implementation and started to play with templates. I'm wondering if wildcards and other regex'es are supported in perdLabel when creating a rule?

I have tons of perfdata Labels like _cpu and _memory which I'd like to rule for. As soon as I set

$rule = new \histou\template\Rule(
    $host = '*',
    $service = '.*myservice$',
    $command = '*',
    $perfLabel = array('.*_cpu', '.*_memory')
);

I receive an error 500 in Grafana webfrontend. If I name the Labels explicitly, it works, but the list is quite long and changes frequently due to the nature of the processes monitored where CPU & memory is graphed. Thanks for your help and keep up the work with this amazing implementation.

Edit: It certainly does since check_nwc_health-interface.php contains regexp. I still cant get is running even though I'm using the syntax of the nwc_health example like this:

$perfLabel = array('^.*?_(cpu|memory)$') Btw, my perfdata in Nagios for one service check looks like this:

env1_process1_cpu=0%;80;90;; 
env1_process1_memory=157MB;4000;5000;0;128963 
env1_process2_cpu=0%;80;90;; 
env1_process2_memory=19MB;4000;5000;0;128963 
env1_process3_cpu=0%;80;90;;
env1_process3_memory=9MB;4000;5000;0;128963 
....
env2_process1_cpu=0%;80;90;; 
env2_process1_memory=157MB;4000;5000;0;128963
env2_process2_cpu=0%;80;90;; 
env2_process2_memory=19MB;4000;5000;0;128963 
env2_process3_cpu=0%;80;90;; 
env2_process3_memory=9MB;4000;5000;0;128963 
....
Griesbacher commented 7 years ago

Hi, I'm not sure if I got it correctly, if you change your rule to the following it is working:

$rule = new \histou\template\Rule(
    $host = '.*',
    $service = '.*myservice$',
    $command = '.*',
    $perfLabel = array('env1_process1_cpu', 'env1_process1_memory')
);

(I think you meant .* at the host and command field) But otherwise you get an 500?

Normally the rule does not change the behaviour of a template, it just decides which template should be used for the current service. There are typically two sources for errors

Greetings, Philip

Griesbacher commented 7 years ago

Closed due to inactivity.