7.2.10.1.2. Configuration / fichiers utiles

7.2.10.1.2.1. Fichier de configuration

prometheus.yml

# my global config
global:
  scrape_interval:     {{ prometheus.server.scrape_interval | default(15) }}s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: {{ prometheus.server.evaluation_interval | default(15) }}s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    # - alertmanager:9093
{% for host in groups['hosts_alertmanager'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.alertmanager.api_port | default(9093) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - rule.yml
{% for item in rules_files.files %}
  - {{ item.path }}
{% endfor %}

scrape_configs:
{% if prometheus.node_exporter.enabled | default(true) | bool == true %}
  - job_name: vitam-node-exporter
    metrics_path: {{ prometheus.node_exporter.metrics_path | default('/metrics') }}
    static_configs:
{% for host in groups['vitam'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.node_exporter.port | default(9101) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% if host in groups['hosts_elasticsearch_data'] %}
        elastic_cluster_name: "{{ elasticsearch.data.cluster_name }}"
{% elif host in groups['hosts_elasticsearch_log'] %}
        elastic_cluster_name: "{{ elasticsearch.log.cluster_name }}"
{% endif %}
{% endfor %}

{% if (groups['hosts_vitamui'] | default([]) | length > 0) %}
  - job_name: vitamui-node-exporter
    metrics_path: {{ prometheus.node_exporter.metrics_path | default('/metrics') }}
    static_configs:
{% for host in groups['hosts_vitamui'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.node_exporter.port | default(9101) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}
{% endif %}

{% if prometheus.consul_exporter.enabled | default(true) | bool == true %}
  - job_name: vitam-consul-exporter
    metrics_path: {{ prometheus.consul_exporter.metrics_path | default('/metrics') }}
    static_configs:
{% for host in groups['vitam'] | union(groups['hosts_vitamui'] | default([])) %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.consul_exporter.port | default(9107) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if prometheus.elasticsearch_exporter.enabled | default(true) | bool == true %}
  - job_name: vitam-elasticsearch-exporter
    metrics_path: {{ prometheus.elasticsearch_exporter.metrics_path | default('/metrics') }}
    static_configs:
{% for host in groups['elasticsearch'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.elasticsearch_exporter.port | default(9114) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_access_internal']|length >0) %}
  - job_name: vitam-access-internal
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_access_internal'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.accessinternal.port_admin | default(28101) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_access_external']|length >0) %}
  - job_name: vitam-access-external
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_access_external'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.accessexternal.port_admin | default(28102) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_ingest_internal']|length >0) %}
  - job_name: vitam-ingest-internal
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_ingest_internal'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.ingestinternal.port_admin | default(28100) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_ingest_external']|length >0) %}
  - job_name: vitam-ingest-external
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_ingest_external'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.ingestexternal.port_admin | default(28001) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_metadata']|length >0) %}
  - job_name: vitam-metadata
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_metadata'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.metadata.port_admin | default(28200) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_ihm_demo']|length >0) %}
  - job_name: vitam-ihm-demo
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_ihm_demo'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.ihm_demo.port_admin | default(28002) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_ihm_recette']|length >0) %}
  - job_name: vitam-ihm-recette
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_ihm_recette'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.ihm_recette.port_admin | default(28204) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_logbook']|length >0) %}
  - job_name: vitam-logbook
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_logbook'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.logbook.port_admin | default(29002) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_workspace']|length >0) %}
  - job_name: vitam-workspace
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_workspace'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.workspace.port_admin | default(28201) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_processing']|length >0) %}
  - job_name: vitam-processing
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_processing'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.processing.port_admin | default(28203) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_worker']|length >0) %}
  - job_name: vitam-worker
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_worker'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.worker.port_admin | default(29104) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_storage_engine']|length >0) %}
  - job_name: vitam-storage-engine
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_storage_engine'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.storageengine.port_admin | default(29102) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_storage_offer_default']|length >0) %}
{% set offerInstances = [] %}
{% for host in groups['hosts_storage_offer_default'] %}
{{ offerInstances.append({"offerId": hostvars[host]['offer_conf'], "host": host }) }}
{% endfor %}
  - job_name: vitam-storage-offer-default
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for offerId, hosts in offerInstances | groupby('offerId') %}
{% for host in hosts %}
    - targets:
      - {{ hostvars[host.host]['ip_admin'] }}:{{ vitam.storageofferdefault.port_admin | default(29900) }}
      labels:
        offerId: {{ offerId }}
        hostname: "{{ host.host }}"
{% endfor %}
{% endfor %}
{% endif %}

{% if (groups['hosts_functional_administration']|length >0) %}
  - job_name: vitam-functional-administration
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_functional_administration'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.functional_administration.port_admin | default(18004) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_metadata_collect']|length >0) %}
  - job_name: vitam-metadata-collect
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_metadata_collect'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.metadata_collect.port_admin | default(28290) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_workspace_collect']|length >0) %}
  - job_name: vitam-workspace-collect
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_workspace_collect'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.workspace_collect.port_admin | default(28291) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_collect_internal']|length >0) %}
  - job_name: vitam-collect-internal
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_collect_internal'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.collect_internal.port_admin | default(28038) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_collect_external']|length >0) %}
  - job_name: vitam-collect-external
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_collect_external'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.collect_external.port_admin | default(28030) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_scheduler']|length >0) %}
  - job_name: vitam-scheduler
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_scheduler'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.scheduler.port_admin | default(28799) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if prometheus.blackbox_exporter.enabled | bool %}
  - job_name: vitam-blackbox
    metrics_path: /probe
    params:
      module:
      - http_2xx
    relabel_configs:
    - source_labels:
      - __address__
      regex: ([^,]*),(.*)
      replacement: $1
      target_label: __param_target
    - source_labels:
      - __address__
      target_label: instance
    - source_labels:
      - __address__
      regex: ([^,]*),(.*)
      replacement: $2
      target_label: instance
    - source_labels:
      - __address__
      regex: ([^,]*),(.*)
      replacement: $1
      target_label: addresse
    - target_label: __address__
      replacement: localhost:9115
    static_configs:
    - targets:
{% for target in prometheus.blackbox_exporter.targets %}
      - {{ target }}
{% endfor %}
{% endif %}

{% if prometheus.mongodb_exporter.enabled | default(true) | bool %}
{% if (groups['hosts_mongoc_data']|length >0) %}
  - job_name: vitam-mongoc-data
    metrics_path: /metrics
    static_configs:
{% for host in groups['hosts_mongoc_data'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.mongodb_exporter.port_mongoc | default(9216) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
        service_name: vitam-mongoc-data
        cluster: {{ hostvars[host]['mongo_cluster_name'] }}
{% endfor %}
{% endif %}

{% if (groups['hosts_mongod_data']|length >0) %}
  - job_name: vitam-mongod-data
    metrics_path: /metrics
    static_configs:
{% for host in groups['hosts_mongod_data'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.mongodb_exporter.port_mongod | default(9217) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
        service_name: vitam-mongod-data
        cluster: {{ hostvars[host]['mongo_cluster_name'] }}
{% endfor %}
{% endif %}

{% if (groups['hosts_mongoc_offer']|length >0) %}
  - job_name: vitam-mongoc-offer
    metrics_path: /metrics
    static_configs:
{% for host in groups['hosts_mongoc_offer'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.mongodb_exporter.port_mongoc | default(9216) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
        service_name: vitam-mongoc-offer
        cluster: {{ hostvars[host]['mongo_cluster_name'] }}
{% endfor %}
{% endif %}

{% if (groups['hosts_mongod_offer']|length >0) %}
  - job_name: vitam-mongod-offer
    metrics_path: /metrics
    static_configs:
{% for host in groups['hosts_mongod_data'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.mongodb_exporter.port_mongod | default(9217) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
        service_name: vitam-mongod-offer
        cluster: {{ hostvars[host]['mongo_cluster_name'] }}
{% endfor %}
{% endif %}

{% if (groups['hosts_vitamui_mongod'] | default([]) | length > 0) %}
  - job_name: vitamui-mongod
    metrics_path: /metrics
    static_configs:
{% for host in groups['hosts_vitamui_mongod'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.mongodb_exporter.port_mongod | default(9217) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
        service_name: vitamui-mongod
        cluster: {{ hostvars[host]['mongo_cluster_name'] | default('mongo-vitamui') }}
{% endfor %}
{% endif %}
{% endif %}

7.2.10.1.2.2. Génération du fichier de configuration

Dans le cas où un serveur Prometheus est déjà en place, il est possible de générer le fichier de configuration prometheus.yml depuis l’inventaire de l’environnement de la solution VITAM.

Pour se faire, depuis la machine Ansible, se placer dans le répertoire path_to/vitam/deploiement/ et exécuter la ligne de commande suivante :

# Spécifier le répertoire de sortie dans le fichier cots_var.yml {{ prometheus.prometheus_config_file_target_directory: path_dir_output }}
ansible-playbook ansible-vitam-extra/prometheus.yml -i environments/hosts.<environnement> --ask-vault-pass --tags gen_prometheus_config

Le fichier de configuration est alors généré dans le répertoire de sortie avec le nom prometheus.yml. Il suffit de récupérer les parties nécessaires, comme par exemple scrape_configs, et de les intégrer à la configuration du serveur Prometheus déjà existant.

Avertissement

Les flux réseau entre le serveur Prometheus existant et les différents machines hébergeant le solution VITAM doivent être ouverts sur la patte d’administration.

7.2.10.1.2.3. Fichier de variable d’environnement

# my global config
global:
  scrape_interval:     {{ prometheus.server.scrape_interval | default(15) }}s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: {{ prometheus.server.evaluation_interval | default(15) }}s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    # - alertmanager:9093
{% for host in groups['hosts_alertmanager'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.alertmanager.api_port | default(9093) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - rule.yml
{% for item in rules_files.files %}
  - {{ item.path }}
{% endfor %}

scrape_configs:
{% if prometheus.node_exporter.enabled | default(true) | bool == true %}
  - job_name: vitam-node-exporter
    metrics_path: {{ prometheus.node_exporter.metrics_path | default('/metrics') }}
    static_configs:
{% for host in groups['vitam'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.node_exporter.port | default(9101) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% if host in groups['hosts_elasticsearch_data'] %}
        elastic_cluster_name: "{{ elasticsearch.data.cluster_name }}"
{% elif host in groups['hosts_elasticsearch_log'] %}
        elastic_cluster_name: "{{ elasticsearch.log.cluster_name }}"
{% endif %}
{% endfor %}

{% if (groups['hosts_vitamui'] | default([]) | length > 0) %}
  - job_name: vitamui-node-exporter
    metrics_path: {{ prometheus.node_exporter.metrics_path | default('/metrics') }}
    static_configs:
{% for host in groups['hosts_vitamui'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.node_exporter.port | default(9101) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}
{% endif %}

{% if prometheus.consul_exporter.enabled | default(true) | bool == true %}
  - job_name: vitam-consul-exporter
    metrics_path: {{ prometheus.consul_exporter.metrics_path | default('/metrics') }}
    static_configs:
{% for host in groups['vitam'] | union(groups['hosts_vitamui'] | default([])) %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.consul_exporter.port | default(9107) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if prometheus.elasticsearch_exporter.enabled | default(true) | bool == true %}
  - job_name: vitam-elasticsearch-exporter
    metrics_path: {{ prometheus.elasticsearch_exporter.metrics_path | default('/metrics') }}
    static_configs:
{% for host in groups['elasticsearch'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.elasticsearch_exporter.port | default(9114) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_access_internal']|length >0) %}
  - job_name: vitam-access-internal
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_access_internal'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.accessinternal.port_admin | default(28101) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_access_external']|length >0) %}
  - job_name: vitam-access-external
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_access_external'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.accessexternal.port_admin | default(28102) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_ingest_internal']|length >0) %}
  - job_name: vitam-ingest-internal
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_ingest_internal'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.ingestinternal.port_admin | default(28100) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_ingest_external']|length >0) %}
  - job_name: vitam-ingest-external
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_ingest_external'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.ingestexternal.port_admin | default(28001) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_metadata']|length >0) %}
  - job_name: vitam-metadata
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_metadata'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.metadata.port_admin | default(28200) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_ihm_demo']|length >0) %}
  - job_name: vitam-ihm-demo
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_ihm_demo'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.ihm_demo.port_admin | default(28002) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_ihm_recette']|length >0) %}
  - job_name: vitam-ihm-recette
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_ihm_recette'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.ihm_recette.port_admin | default(28204) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_logbook']|length >0) %}
  - job_name: vitam-logbook
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_logbook'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.logbook.port_admin | default(29002) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_workspace']|length >0) %}
  - job_name: vitam-workspace
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_workspace'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.workspace.port_admin | default(28201) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_processing']|length >0) %}
  - job_name: vitam-processing
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_processing'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.processing.port_admin | default(28203) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_worker']|length >0) %}
  - job_name: vitam-worker
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_worker'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.worker.port_admin | default(29104) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_storage_engine']|length >0) %}
  - job_name: vitam-storage-engine
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_storage_engine'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.storageengine.port_admin | default(29102) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_storage_offer_default']|length >0) %}
{% set offerInstances = [] %}
{% for host in groups['hosts_storage_offer_default'] %}
{{ offerInstances.append({"offerId": hostvars[host]['offer_conf'], "host": host }) }}
{% endfor %}
  - job_name: vitam-storage-offer-default
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for offerId, hosts in offerInstances | groupby('offerId') %}
{% for host in hosts %}
    - targets:
      - {{ hostvars[host.host]['ip_admin'] }}:{{ vitam.storageofferdefault.port_admin | default(29900) }}
      labels:
        offerId: {{ offerId }}
        hostname: "{{ host.host }}"
{% endfor %}
{% endfor %}
{% endif %}

{% if (groups['hosts_functional_administration']|length >0) %}
  - job_name: vitam-functional-administration
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_functional_administration'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.functional_administration.port_admin | default(18004) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_metadata_collect']|length >0) %}
  - job_name: vitam-metadata-collect
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_metadata_collect'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.metadata_collect.port_admin | default(28290) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_workspace_collect']|length >0) %}
  - job_name: vitam-workspace-collect
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_workspace_collect'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.workspace_collect.port_admin | default(28291) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_collect_internal']|length >0) %}
  - job_name: vitam-collect-internal
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_collect_internal'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.collect_internal.port_admin | default(28038) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_collect_external']|length >0) %}
  - job_name: vitam-collect-external
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_collect_external'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.collect_external.port_admin | default(28030) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if (groups['hosts_scheduler']|length >0) %}
  - job_name: vitam-scheduler
    metrics_path: {{ prometheus.metrics_path | default('/admin/v1/metrics') }}
    static_configs:
{% for host in groups['hosts_scheduler'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ vitam.scheduler.port_admin | default(28799) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
{% endfor %}
{% endif %}

{% if prometheus.blackbox_exporter.enabled | bool %}
  - job_name: vitam-blackbox
    metrics_path: /probe
    params:
      module:
      - http_2xx
    relabel_configs:
    - source_labels:
      - __address__
      regex: ([^,]*),(.*)
      replacement: $1
      target_label: __param_target
    - source_labels:
      - __address__
      target_label: instance
    - source_labels:
      - __address__
      regex: ([^,]*),(.*)
      replacement: $2
      target_label: instance
    - source_labels:
      - __address__
      regex: ([^,]*),(.*)
      replacement: $1
      target_label: addresse
    - target_label: __address__
      replacement: localhost:9115
    static_configs:
    - targets:
{% for target in prometheus.blackbox_exporter.targets %}
      - {{ target }}
{% endfor %}
{% endif %}

{% if prometheus.mongodb_exporter.enabled | default(true) | bool %}
{% if (groups['hosts_mongoc_data']|length >0) %}
  - job_name: vitam-mongoc-data
    metrics_path: /metrics
    static_configs:
{% for host in groups['hosts_mongoc_data'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.mongodb_exporter.port_mongoc | default(9216) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
        service_name: vitam-mongoc-data
        cluster: {{ hostvars[host]['mongo_cluster_name'] }}
{% endfor %}
{% endif %}

{% if (groups['hosts_mongod_data']|length >0) %}
  - job_name: vitam-mongod-data
    metrics_path: /metrics
    static_configs:
{% for host in groups['hosts_mongod_data'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.mongodb_exporter.port_mongod | default(9217) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
        service_name: vitam-mongod-data
        cluster: {{ hostvars[host]['mongo_cluster_name'] }}
{% endfor %}
{% endif %}

{% if (groups['hosts_mongoc_offer']|length >0) %}
  - job_name: vitam-mongoc-offer
    metrics_path: /metrics
    static_configs:
{% for host in groups['hosts_mongoc_offer'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.mongodb_exporter.port_mongoc | default(9216) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
        service_name: vitam-mongoc-offer
        cluster: {{ hostvars[host]['mongo_cluster_name'] }}
{% endfor %}
{% endif %}

{% if (groups['hosts_mongod_offer']|length >0) %}
  - job_name: vitam-mongod-offer
    metrics_path: /metrics
    static_configs:
{% for host in groups['hosts_mongod_data'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.mongodb_exporter.port_mongod | default(9217) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
        service_name: vitam-mongod-offer
        cluster: {{ hostvars[host]['mongo_cluster_name'] }}
{% endfor %}
{% endif %}

{% if (groups['hosts_vitamui_mongod'] | default([]) | length > 0) %}
  - job_name: vitamui-mongod
    metrics_path: /metrics
    static_configs:
{% for host in groups['hosts_vitamui_mongod'] %}
    - targets:
      - {{ hostvars[host]['ip_admin'] }}:{{ prometheus.mongodb_exporter.port_mongod | default(9217) }}
      labels:
        hostname: "{{ host.split(".")[0] }}"
        service_name: vitamui-mongod
        cluster: {{ hostvars[host]['mongo_cluster_name'] | default('mongo-vitamui') }}
{% endfor %}
{% endif %}
{% endif %}

7.2.10.1.2.4. Fichiers de données

Ce service utilise des fichiers de données localisés dans le répertoire /vitam/data/prometheus/

7.2.10.1.2.5. Règles livrées avec la solution VITAM

7.2.10.1.2.5.1. Etat de la machine

  • Remonte une alerte critique si une machine n’est pas joignable depuis plus d’une minute

7.2.10.1.2.5.2. Processeur

  • Remonte une alerte d’avertissement si la consommation globale du processeur d’une machine est à plus de 75% depuis 10 minutes
  • Remonte une alerte critique si la consommation globale du processeur d’une machine est à plus de 90% depuis 10 minutes

7.2.10.1.2.5.3. Mémoire

  • Remonte une alerte d’avertissement si la consommation de la mémoire d’une machine est à plus de 75% depuis 10 minutes
  • Remonte une alerte critique si la consommation de la mémoire d’une machine est à plus de 90% depuis 10 minutes

7.2.10.1.2.5.4. Disque

  • Remonte une alerte d’avertissement si la consommation de l’espace disque de la partition root d’une machine est à plus de 75% depuis 10 minutes
  • Remonte une alerte d’avertissement si la consommation de l’espace disque de la partition Vitam d’une machine est à plus de 75% depuis 10 minutes
  • Remonte une alerte critique si la consommation de l’espace disque de la partition root d’une machine est à plus de 90% depuis 10 minutes
  • Remonte une alerte critique si la consommation de l’espace disque de la partition Vitam d’une machine est à plus de 90% depuis 10 minutes

7.2.10.1.2.6. Ajout de nouvelles règles

Afin d’ajouter de nouvelles règles, il suffit de déposer les nouveaux fichiers de règles dans le répértoire suivant : deployment/ansible-vitam-extra/roles/prometheus-server/rules/

Puis d’exécuter la commande suivante :

ansible-playbook ansible-vitam-extra/prometheus.yml -i environments/hosts.<environnement> --ask-vault-pass