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"?> <?xml version="1.0" encoding="utf-8"?>
<creole> <creole>
<files> <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>prometheus</service>
<service_access service='prometheus'> <service_access service='prometheus'>
<port service_accesslist="saLemon">80</port> <port service_accesslist="saLemon">80</port>
<port service_accesslist="saLemon">443</port> <port service_accesslist="saLemon">443</port>
<port>9090</port>
</service_access> </service_access>
</files> </files>
<variables> <variables>
<family name='prometheus'> <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'> <variable name='prometheusScrapeInterval' type='string' description='Intervalle de récupération des données sur les différents noeuds'>
<value>15s</value> <value>15s</value>
</variable> </variable>
@ -19,9 +24,35 @@
<variable name='prometheusScrapeTimeout' type='string' description="Temps d'attente avant que la récupération de données échoue"> <variable name='prometheusScrapeTimeout' type='string' description="Temps d'attente avant que la récupération de données échoue">
<value>10s</value> <value>10s</value>
</variable> </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> </family>
</variables> </variables>
<constraints> <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> </constraints>
<help> <help>
</help> </help>

View File

@ -8,14 +8,29 @@ rule_files:
- "/etc/prometheus/rules.d/*.yml" - "/etc/prometheus/rules.d/*.yml"
scrape_configs: scrape_configs:
- job_name: eole - job_name: %%prometheusJobName
honor_labels: true honor_labels: true
alerting:
alertmanagers:
- scheme: https
static_configs: static_configs:
- targets: - targets: ['%%nom_domaine_machine:9090']
- "1.2.3.4:9093" %if %%getVar('ajout_client_prometheus','non') == 'oui'
- "1.2.3.5:9093" %if not %%is_empty(%%url_nouveau_client_prometheus)
- "1.2.3.6:9093" %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"