ajout variable et templétisation de la configuration de prometheus

This commit is contained in:
vincent 2018-04-17 12:32:05 +02:00
parent e919da4d7d
commit 67cdfa79c8
2 changed files with 56 additions and 10 deletions

View File

@ -1,15 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<creole>
<files>
<file filelist='prometheus' name='/repertoire/de/destination/monfichier' mkdir='True' rm='True'/>
<file filelist='prometheus' name='/etc/prometheus/prometheus.yml' source='prometheus.yml' mkdir='True' rm='True'/>
<service>prometheus</service>
<service_access service='prometheus'>
<port service_accesslist="saLemon">80</port>
<port service_accesslist="saLemon">443</port>
<port>9090</port>
</service_access>
</files>
<variables>
<family name='prometheus'>
<variable name='activer_prometheus' type='oui/non' description="Activer le service prometheus sur le serveur">
<variable name='prometheusJobName' type='string' description='Nom du job ajouté au label'>
<value>prometheus</value>
</variable>
<variable name='prometheusScrapeInterval' type='string' description='Intervalle de récupération des données sur les différents noeuds'>
<value>15s</value>
</variable>
@ -19,9 +24,35 @@
<variable name='prometheusScrapeTimeout' type='string' description="Temps d'attente avant que la récupération de données échoue">
<value>10s</value>
</variable>
<variable name='ajout_client_prometheus' type='oui/non' description="Ajouter un nouveau client à Prometheus">
<value>non</value>
</variable>
<variable name='url_nouveau_client_prometheus' type='string' description="url/IP du nouveau client" multi="True" mandatory='True'>
<value>client.prometheus.lan</value>
</variable>
<variable name='job_name_node' type='string' description="Nom du job pour les noeuds" mode='expert'>
<value>node</value>
</variable>
<variable name='job_file_config' type='string' description="Emplacement des fichiers de configuration des noeuds" mode='expert'>
<value>/etc/prometheus/nodes</value>
</variable>
</family>
</variables>
<constraints>
<condition name='disabled_if_in' source='activer_firewall'>
<param>non</param>
<target type='variable'>activer_prometheus</target>
</condition>
<condition name='disabled_if_in' source='activer_prometheus'>
<param>non</param>
<target type='family'>prometheus</target>
<target type='filelist'>prometheus</target>
</condition>
<condition name='disabled_if_in' source='ajout_client_prometheus'>
<param>non</param>
<target type='variable'>url_nouveau_client_prometheus</target>
</condition>
</constraints>
<help>
</help>

View File

@ -8,14 +8,29 @@ rule_files:
- "/etc/prometheus/rules.d/*.yml"
scrape_configs:
- job_name: eole
- job_name: %%prometheusJobName
honor_labels: true
alerting:
alertmanagers:
- scheme: https
static_configs:
- targets:
- "1.2.3.4:9093"
- "1.2.3.5:9093"
- "1.2.3.6:9093"
- targets: ['%%nom_domaine_machine:9090']
%if %%getVar('ajout_client_prometheus','non') == 'oui'
%if not %%is_empty(%%url_nouveau_client_prometheus)
%for %%client_prometheus in %%url_nouveau_client_prometheus
- targets: ['%%client_prometheus.%%url_nouveau_client_prometheus:9090']
%end for
%end if
%end if
- job_name: '%%job_name_node'
file_sd_configs:
- files: [ "%%job_file_config/*.yml" ]
#alerting:
# alertmanagers:
# - scheme: https
# static_configs:
# - targets:
# - "1.2.3.4:9093"
# - "1.2.3.5:9093"
# - "1.2.3.6:9093"