Improve configuration flexibility to match prometheus way of doing

things
This commit is contained in:
Philippe Caseiro 2018-06-06 16:00:36 +02:00
parent e3a6295709
commit ab479fd33a
2 changed files with 133 additions and 96 deletions

View File

@ -48,25 +48,43 @@
<value>/etc/prometheus/nodes</value>
</variable>
</family>
<family name='Clients prometheus'>
<variable name='ajout_client_prometheus' type='oui/non' description="Ajouter un nouveau client à Prometheus">
<family name='Jobs prometheus'>
<variable name='promJobs' type='string' description="Nom du job prometheus"/>
<variable name='honorLabels' type='oui/non' description='Garder les labels en cas de conflit' mode='expert'>
<value>oui</value>
</variable>
<variable name='scrpInterval' type='number' description="Interval d'intérogation de la sonde (en secondes)">
<value>15</value>
</variable>
<variable name='scrpTimeout' type='number' description="Délais d'attente maximum lors de l'interrogation d'une sonde">
<value>10</value>
</variable>
<variable name='scrpScheme' type='string' description="Protocole à utiliser pour l'interrogation de la sonde">
<value>http</value>
</variable>
<variable name='addTargetPrometheus' type='oui/non' description="Ajouter des cibles statiques à Prometheus">
<value>non</value>
</variable>
<!-- Client standard -->
<variable name='prCli' type='string' description='Nom du client prometheus' multi='True'/>
<variable name='prCliIP' type='ip' description="Adresse IP du client prometheus"/>
<variable name='prCliSonde' type='string' description="Sonde a utiliser pour ce client">
<!-- Job standard -->
<variable name='prTarg' type='string' description='Nom de la cible prometheus' multi='True'/>
<variable name='prTargJob' type='string' description='Nom du job de rattachement de la cible'/>
<variable name='prTargIP' type='ip' description="Adresse IP de la cible prometheus"/>
<variable name='prTargSonde' type='string' description="Sonde a utiliser pour ce client">
<value>Node Exporter</value>
</variable>
<variable name='addPrOpenCli' type='oui/non' description="Ajouter un client personnalisé">
<variable name='addPrOpenTarg' type='oui/non' description="Ajouter un client personnalisé">
<value>non</value>
</variable>
<!-- Client libre -->
<variable name='prOpenCli' type='string' description='Nom du client personnalisé prometheus' multi='True'/>
<variable name='prOpenCliIP' type='ip' description="Adresse IP"/>
<variable name='prOpenCliPort' type='number' description="Port d'écoute de la sonde"/>
<!-- Job libre -->
<variable name='prOpenTarg' type='string' description='Nom de la cible personnalisé prometheus' multi='True'/>
<variable name='prOpenTargJob' type='string' description='Nom du job de rattachement de la cible'/>
<variable name='prOpenTargIP' type='ip' description="Adresse IP de la cible"/>
<variable name='prOpenTargPort' type='number' description="Port d'écoute de la sonde"/>
</family>
<family name="grafana">
<variable name='grafana_domain' type='string' description="Nom de Domaine ou IP pour accèder à l'interface Grafana" mandatory='True'>
<value>localhost</value>
@ -155,20 +173,26 @@
<slave>alSubRouteMatchReceiver</slave>
</group>
<group master='prCli'>
<slave>prCliIP</slave>
<slave>prCliSonde</slave>
<group master='prTarg'>
<slave>prTargIP</slave>
<slave>prTargJob</slave>
<slave>prTargSonde</slave>
</group>
<group master='prOpenCli'>
<slave>prOpenCliIP</slave>
<slave>prOpenCliPort</slave>
<group master='prOpenTarg'>
<slave>prOpenTargIP</slave>
<slave>prOpenTargPort</slave>
<slave>prOpenTargJob</slave>
</group>
<check name='valid_enum' target='prCliSonde'>
<check name='valid_enum' target='prTargSonde'>
<param>['Node Exporter','Port']</param>
</check>
<check name='valid_enum' target='scrpScheme'>
<param>['http','https']</param>
</check>
<check name='valid_enum' target='alRouteMatchSource'>
<param>['','service','severity']</param>
</check>
@ -208,17 +232,17 @@
<target type='service_accesslist'>alertmanager</target>
</condition>
<condition name='disabled_if_in' source='ajout_client_prometheus'>
<condition name='disabled_if_in' source='addTargetPrometheus'>
<param>non</param>
<target type='variable'>prCli</target>
<target type='variable'>prCliIP</target>
<target type='variable'>prCliSonde</target>
<target type='variable'>prTarg</target>
<target type='variable'>prTargIP</target>
<target type='variable'>prTargSonde</target>
</condition>
<condition name='disabled_if_in' source='addPrOpenCli'>
<condition name='disabled_if_in' source='addPrOpenTarg'>
<param>non</param>
<target type='variable'>prOpenCli</target>
<target type='variable'>prOpenCliIP</target>
<target type='variable'>prOpenCliPort</target>
<target type='variable'>prOpenTarg</target>
<target type='variable'>prOpenTargIP</target>
<target type='variable'>prOpenTargPort</target>
</condition>
</constraints>
<help>

View File

@ -18,12 +18,12 @@ scrape_configs:
%end if
]
- job_name: '%%job_name_node'
file_sd_configs:
- files: [ "%%job_file_config/*.yml" ]
%if %%is_empty('ajout_client_prometheus') or %%is_empty('addPrOpenCli')
# Nothing to configure
%else
%if %%getVar('addTargetPrometheus','non') == 'oui'
static_configs:
- targets: [ "%%adresse_ip_eth0:9100"%slurp
%if %%getVar('ajout_client_prometheus','non') == 'oui'
@ -33,14 +33,27 @@ scrape_configs:
%end if
%end for
%end if
%if %%getVar('addPrOpenCli','non') == 'oui'
%for %%cliOpen in %%getVar('prOpenCli',[])
, '%%cliOpen.prOpenCliIP:%%cliOpen.prOpenCliPort'%slurp
%end for
%end if
]
%end if
%for %%job in %%getVar['promJobs',[]]
- job_name: '%%job'
%if %%job.honorLabels == 'oui'
honor_labels: true
%else
honor_labels; false
%end if
scrape_interval: %%job.scrpInterval
scrape_timeout: %%job.scrpTimeout
scheme: %%job.scrpScheme
%for %%target in %%getVar('prOpenTarg',[])
static_configs:
%if %%target.prOpenTargJob == %%job
- targets: [ "%%target.prOpenTargIP:%%target.prOpenTargPort" ]
%end if
%end for
%end for
%if %%getVar('activerAlertmanager','non') == 'oui'
alerting:
alertmanagers: