---
project_name: "prometheus"

prometheus_services:
  prometheus-server:
    container_name: prometheus_server
    group: prometheus
    enabled: "{{ enable_prometheus_server | bool }}"
    image: "{{ prometheus_server_image_full }}"
    volumes: "{{ prometheus_server_default_volumes + prometheus_server_extra_volumes }}"
    dimensions: "{{ prometheus_server_dimensions }}"
    haproxy:
      prometheus_server:
        enabled: "{{ enable_prometheus_server | bool }}"
        mode: "http"
        external: false
        port: "{{ prometheus_port }}"
  prometheus-node-exporter:
    container_name: prometheus_node_exporter
    group: prometheus-node-exporter
    enabled: "{{ enable_prometheus_node_exporter | bool }}"
    image: "{{ prometheus_node_exporter_image_full }}"
    pid_mode: "host"
    volumes: "{{ prometheus_node_exporter_default_volumes + prometheus_node_exporter_extra_volumes }}"
    dimensions: "{{ prometheus_node_exporter_dimensions }}"
  prometheus-mysqld-exporter:
    container_name: prometheus_mysqld_exporter
    group: prometheus-mysqld-exporter
    enabled: "{{ enable_prometheus_mysqld_exporter | bool }}"
    image: "{{ prometheus_mysqld_exporter_image_full }}"
    volumes: "{{ prometheus_mysqld_exporter_default_volumes + prometheus_mysqld_exporter_extra_volumes }}"
    dimensions: "{{ prometheus_mysqld_exporter_dimensions }}"
  prometheus-haproxy-exporter:
    container_name: prometheus_haproxy_exporter
    group: prometheus-haproxy-exporter
    enabled: "{{ enable_prometheus_haproxy_exporter | bool }}"
    image: "{{ prometheus_haproxy_exporter_image_full }}"
    volumes: "{{ prometheus_haproxy_exporter_default_volumes + prometheus_haproxy_exporter_extra_volumes }}"
    dimensions: "{{ prometheus_haproxy_exporter_dimensions }}"
  prometheus-memcached-exporter:
    container_name: prometheus_memcached_exporter
    group: prometheus-memcached-exporter
    enabled: "{{ enable_prometheus_memcached_exporter | bool }}"
    image: "{{ prometheus_memcached_exporter_image_full }}"
    volumes: "{{ prometheus_memcached_exporter_default_volumes + prometheus_memcached_exporter_extra_volumes }}"
    dimensions: "{{ prometheus_memcached_exporter_dimensions }}"
  prometheus-cadvisor:
    container_name: "prometheus_cadvisor"
    group: "prometheus-cadvisor"
    enabled: "{{ enable_prometheus_cadvisor | bool }}"
    image: "{{ prometheus_cadvisor_image_full }}"
    volumes: "{{ prometheus_cadvisor_default_volumes + prometheus_cadvisor_extra_volumes }}"
    dimensions: "{{ prometheus_cadvisor_dimensions }}"
  prometheus-alertmanager:
    container_name: "prometheus_alertmanager"
    group: "prometheus-alertmanager"
    enabled: "{{ enable_prometheus_alertmanager | bool }}"
    image: "{{ prometheus_alertmanager_image_full }}"
    volumes: "{{ prometheus_alertmanager_default_volumes + prometheus_alertmanager_extra_volumes }}"
    dimensions: "{{ prometheus_alertmanager_dimensions }}"
    haproxy:
      prometheus_alertmanager:
        enabled: "{{ enable_prometheus_alertmanager | bool }}"
        mode: "http"
        external: false
        port: "{{ prometheus_alertmanager_port }}"
        auth_user: "{{ prometheus_alertmanager_user }}"
        auth_pass: "{{ prometheus_alertmanager_password }}"
      prometheus_alertmanager_external:
        enabled: "{{ enable_prometheus_alertmanager | bool }}"
        mode: "http"
        external: true
        port: "{{ prometheus_alertmanager_port }}"
        auth_user: "{{ prometheus_alertmanager_user }}"
        auth_pass: "{{ prometheus_alertmanager_password }}"
  prometheus-openstack-exporter:
    container_name: "prometheus_openstack_exporter"
    group: "prometheus-openstack-exporter"
    enabled: "{{ enable_prometheus_openstack_exporter | bool }}"
    image: "{{ prometheus_openstack_exporter_image_full }}"
    volumes: "{{ prometheus_openstack_exporter_default_volumes + prometheus_openstack_exporter_extra_volumes }}"
    dimensions: "{{ prometheus_openstack_exporter_dimensions }}"
  prometheus-elasticsearch-exporter:
    container_name: prometheus_elasticsearch_exporter
    group: prometheus-elasticsearch-exporter
    enabled: "{{ enable_prometheus_elasticsearch_exporter | bool }}"
    image: "{{ prometheus_elasticsearch_exporter_image_full }}"
    volumes: "{{ prometheus_elasticsearch_exporter_default_volumes + prometheus_elasticsearch_exporter_extra_volumes }}"
    dimensions: "{{ prometheus_elasticsearch_exporter_dimensions }}"
  prometheus-blackbox-exporter:
    container_name: "prometheus_blackbox_exporter"
    group: "prometheus-blackbox-exporter"
    enabled: "{{ enable_prometheus_blackbox_exporter | bool }}"
    image: "{{ prometheus_blackbox_exporter_image_full }}"
    volumes: "{{ prometheus_blackbox_exporter_default_volumes + prometheus_blackbox_exporter_extra_volumes }}"
    dimensions: "{{ prometheus_blackbox_exporter_dimensions }}"

####################
# Database
####################
prometheus_mysql_exporter_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}prometheus{% endif %}"

####################
# Blackbox
####################

# A list of endpoints to monitor. Each target is in the format:
# 'service_name:blackbox_exporter_module:endpoint' for example:
#
# prometheus_blackbox_exporter_targets:
#   - 'glance:os_endpoint:{{ external_protocol }}://{{ kolla_external_fqdn | put_address_in_context('url') }}:{{ glance_api_port}}'
#
# For a list of modules see the alertmanager config.
prometheus_blackbox_exporter_endpoints: []

####################
# Compatibility
####################

# Whether to keep using Prometheus server v1 (due to no data-preserving migration path to v2)
# NOTE(piotrp): Deprecated in Wallaby and will be removed in Xena
prometheus_use_v1: no

####################
# Docker
####################
prometheus_install_type: "{{ kolla_install_type }}"
prometheus_tag: "{{ openstack_tag }}"

prometheus_server_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ prometheus_install_type }}-{% if not prometheus_use_v1 | bool %}prometheus-v2-server{% else %}prometheus-server{% endif %}"
prometheus_server_tag: "{{ prometheus_tag }}"
prometheus_server_image_full: "{{ prometheus_server_image }}:{{ prometheus_server_tag }}"

prometheus_haproxy_exporter_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ prometheus_install_type }}-prometheus-haproxy-exporter"
prometheus_haproxy_exporter_tag: "{{ prometheus_tag }}"
prometheus_haproxy_exporter_image_full: "{{ prometheus_haproxy_exporter_image }}:{{ prometheus_haproxy_exporter_tag }}"

prometheus_mysqld_exporter_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ prometheus_install_type }}-prometheus-mysqld-exporter"
prometheus_mysqld_exporter_tag: "{{ prometheus_tag }}"
prometheus_mysqld_exporter_image_full: "{{ prometheus_mysqld_exporter_image }}:{{ prometheus_mysqld_exporter_tag }}"

prometheus_node_exporter_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ prometheus_install_type }}-prometheus-node-exporter"
prometheus_node_exporter_tag: "{{ prometheus_tag }}"
prometheus_node_exporter_image_full: "{{ prometheus_node_exporter_image }}:{{ prometheus_node_exporter_tag }}"

prometheus_memcached_exporter_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ prometheus_install_type }}-prometheus-memcached-exporter"
prometheus_memcached_exporter_tag: "{{ prometheus_tag }}"
prometheus_memcached_exporter_image_full: "{{ prometheus_memcached_exporter_image }}:{{ prometheus_memcached_exporter_tag }}"

prometheus_cadvisor_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ prometheus_install_type }}-prometheus-cadvisor"
prometheus_cadvisor_tag: "{{ prometheus_tag }}"
prometheus_cadvisor_image_full: "{{ prometheus_cadvisor_image }}:{{ prometheus_cadvisor_tag }}"

prometheus_alertmanager_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ prometheus_install_type }}-prometheus-alertmanager"
prometheus_alertmanager_tag: "{{ prometheus_tag }}"
prometheus_alertmanager_image_full: "{{ prometheus_alertmanager_image }}:{{ prometheus_alertmanager_tag }}"

# Prometheus openstack_exporter
prometheus_openstack_exporter_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ prometheus_install_type }}-prometheus-openstack-exporter"
prometheus_openstack_exporter_tag: "{{ prometheus_tag }}"
prometheus_openstack_exporter_image_full: "{{ prometheus_openstack_exporter_image }}:{{ prometheus_openstack_exporter_tag }}"

prometheus_elasticsearch_exporter_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ prometheus_install_type }}-prometheus-elasticsearch-exporter"
prometheus_elasticsearch_exporter_tag: "{{ prometheus_tag }}"
prometheus_elasticsearch_exporter_image_full: "{{ prometheus_elasticsearch_exporter_image }}:{{ prometheus_elasticsearch_exporter_tag }}"

prometheus_blackbox_exporter_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ prometheus_install_type }}-prometheus-blackbox-exporter"
prometheus_blackbox_exporter_tag: "{{ prometheus_tag }}"
prometheus_blackbox_exporter_image_full: "{{ prometheus_blackbox_exporter_image }}:{{ prometheus_blackbox_exporter_tag }}"

prometheus_server_dimensions: "{{ default_container_dimensions }}"
prometheus_haproxy_exporter_dimensions: "{{ default_container_dimensions }}"
prometheus_mysqld_exporter_dimensions: "{{ default_container_dimensions }}"
prometheus_node_exporter_dimensions: "{{ default_container_dimensions }}"
prometheus_memcached_exporter_dimensions: "{{ default_container_dimensions }}"
prometheus_cadvisor_dimensions: "{{ default_container_dimensions }}"
prometheus_alertmanager_dimensions: "{{ default_container_dimensions }}"
prometheus_openstack_exporter_dimensions: "{{ default_container_dimensions }}"
prometheus_elasticsearch_exporter_dimensions: "{{ default_container_dimensions }}"
prometheus_blackbox_exporter_dimensions: "{{ default_container_dimensions }}"

prometheus_server_default_volumes:
  - "{{ node_config_directory }}/prometheus-server/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "{{ 'prometheus_v2' if not prometheus_use_v1 | bool else 'prometheus' }}:/var/lib/prometheus"
  - "kolla_logs:/var/log/kolla/"
prometheus_haproxy_exporter_default_volumes:
  - "{{ node_config_directory }}/prometheus-haproxy-exporter/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "haproxy_socket:/var/lib/kolla/haproxy"
prometheus_mysqld_exporter_default_volumes:
  - "{{ node_config_directory }}/prometheus-mysqld-exporter/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
prometheus_node_exporter_default_volumes:
  - "{{ node_config_directory }}/prometheus-node-exporter/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "/proc:/host/proc:ro"
  - "/sys:/host/sys:ro"
prometheus_memcached_exporter_default_volumes:
  - "{{ node_config_directory }}/prometheus-memcached-exporter/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
prometheus_cadvisor_default_volumes:
  - "{{ node_config_directory }}/prometheus-cadvisor/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "/:/rootfs:ro"
  - "/var/run:/var/run:rw"
  - "/sys:/sys:ro"
  - "/var/lib/docker/:/var/lib/docker:ro"
  - "/dev/disk/:/dev/disk:ro"
prometheus_alertmanager_default_volumes:
  - "{{ node_config_directory }}/prometheus-alertmanager/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "prometheus:/var/lib/prometheus"
prometheus_openstack_exporter_default_volumes:
  - "{{ node_config_directory }}/prometheus-openstack-exporter/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
prometheus_elasticsearch_exporter_default_volumes:
  - "{{ node_config_directory }}/prometheus-elasticsearch-exporter/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
prometheus_blackbox_exporter_default_volumes:
  - "{{ node_config_directory }}/prometheus-blackbox-exporter/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"

prometheus_extra_volumes: "{{ default_extra_volumes }}"
prometheus_server_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_haproxy_exporter_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_mysqld_exporter_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_node_exporter_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_memcached_exporter_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_cadvisor_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_alertmanager_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_openstack_exporter_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_elasticsearch_exporter_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_blackbox_exporter_extra_volumes: "{{ prometheus_extra_volumes }}"

prometheus_openstack_exporter_disabled_volume: "{{ '--disable-service.volume' if not enable_cinder | bool else '' }}"
prometheus_openstack_exporter_disabled_dns: "{{ '--disable-service.dns' if not enable_designate | bool else '' }}"
prometheus_openstack_exporter_disabled_object: "{{ '--disable-service.object-store' if not enable_swift | bool else '' }}"
prometheus_openstack_exporter_disabled_lb: "{{ '--disable-service.load-balancer --disable-metric=neutron-loadbalancers --disable-metric=neutron-loadbalancers_not_active' if not enable_octavia | bool else '' }}"
prometheus_openstack_exporter_disabled_items: "{{ [prometheus_openstack_exporter_disabled_volume, prometheus_openstack_exporter_disabled_dns, prometheus_openstack_exporter_disabled_object, prometheus_openstack_exporter_disabled_lb|trim]|join(' ')|trim }}"
