---
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 }}"
        active_passive: "{{ prometheus_active_passive | bool }}"
  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 }}"
        active_passive: "{{ prometheus_alertmanager_active_passive | bool }}"
      prometheus_alertmanager_external:
        enabled: "{{ enable_prometheus_alertmanager_external | bool }}"
        mode: "http"
        external: true
        port: "{{ prometheus_alertmanager_port }}"
        auth_user: "{{ prometheus_alertmanager_user }}"
        auth_pass: "{{ prometheus_alertmanager_password }}"
        active_passive: "{{ prometheus_alertmanager_active_passive | bool }}"
  prometheus-openstack-exporter:
    container_name: "prometheus_openstack_exporter"
    group: "prometheus-openstack-exporter"
    enabled: "{{ enable_prometheus_openstack_exporter | bool }}"
    environment:
      OS_COMPUTE_API_VERSION: "{{ prometheus_openstack_exporter_compute_api_version }}"
    image: "{{ prometheus_openstack_exporter_image_full }}"
    volumes: "{{ prometheus_openstack_exporter_default_volumes + prometheus_openstack_exporter_extra_volumes }}"
    dimensions: "{{ prometheus_openstack_exporter_dimensions }}"
    haproxy:
      prometheus_openstack_exporter:
        enabled: "{{ enable_prometheus_openstack_exporter | bool }}"
        mode: "http"
        external: false
        port: "{{ prometheus_openstack_exporter_port }}"
        backend_http_extra:
          - "timeout server {{ prometheus_openstack_exporter_timeout }}"
      prometheus_openstack_exporter_external:
        enabled: "{{ enable_prometheus_openstack_exporter_external | bool }}"
        mode: "http"
        external: true
        port: "{{ prometheus_openstack_exporter_port }}"
        backend_http_extra:
          - "timeout server {{ prometheus_openstack_exporter_timeout }}"
  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 }}"
  prometheus-libvirt-exporter:
    container_name: "prometheus_libvirt_exporter"
    group: "prometheus-libvirt-exporter"
    enabled: "{{ enable_prometheus_libvirt_exporter | bool }}"
    image: "{{ prometheus_libvirt_exporter_image_full }}"
    volumes: "{{ prometheus_libvirt_exporter_default_volumes + prometheus_libvirt_exporter_extra_volumes }}"
    dimensions: "{{ prometheus_libvirt_exporter_dimensions }}"
  prometheus-msteams:
    container_name: "prometheus_msteams"
    group: "prometheus-msteams"
    enabled: "{{ enable_prometheus_msteams | bool }}"
    environment: "{{ prometheus_msteams_container_proxy }}"
    image: "{{ prometheus_msteams_image_full }}"
    volumes: "{{ prometheus_msteams_default_volumes + prometheus_msteams_extra_volumes }}"
    dimensions: "{{ prometheus_msteams_dimensions }}"

####################
# Prometheus Server
####################
prometheus_external_labels:
#  <labelname>: <labelvalue>

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

####################
# HAProxy
####################
prometheus_active_passive: true
prometheus_alertmanager_active_passive: true

####################
# 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: []

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

prometheus_server_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/prometheus-v2-server"
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 }}/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 }}/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 }}/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 }}/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 }}/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 }}/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 }}/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 }}/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 }}/prometheus-blackbox-exporter"
prometheus_blackbox_exporter_tag: "{{ prometheus_tag }}"
prometheus_blackbox_exporter_image_full: "{{ prometheus_blackbox_exporter_image }}:{{ prometheus_blackbox_exporter_tag }}"

prometheus_libvirt_exporter_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/prometheus-libvirt-exporter"
prometheus_libvirt_exporter_tag: "{{ prometheus_tag }}"
prometheus_libvirt_exporter_image_full: "{{ prometheus_libvirt_exporter_image }}:{{ prometheus_libvirt_exporter_tag }}"

prometheus_msteams_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/prometheus-msteams"
prometheus_msteams_tag: "{{ prometheus_tag }}"
prometheus_msteams_image_full: "{{ prometheus_msteams_image }}:{{ prometheus_msteams_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_libvirt_exporter_dimensions: "{{ default_container_dimensions }}"
prometheus_msteams_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:/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/"
  - "/:/host:ro,rslave"
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_libvirt_exporter_default_volumes:
  - "{{ node_config_directory }}/prometheus-libvirt-exporter/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "/run/libvirt:/run/libvirt:ro"
prometheus_msteams_default_volumes:
  - "{{ node_config_directory }}/prometheus-msteams/:{{ 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_libvirt_exporter_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_msteams_extra_volumes: "{{ prometheus_extra_volumes }}"

prometheus_msteams_container_proxy: "{{ container_proxy }}"

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 }}"

prometheus_blackbox_exporter_cmdline_extras: ""
prometheus_cadvisor_cmdline_extras: "--docker_only --store_container_labels=false --disable_metrics=percpu,referenced_memory,cpu_topology,resctrl,udp,advtcp,sched,hugetlb,memory_numa,tcp,process --housekeeping_interval={{ prometheus_scrape_interval }}"
prometheus_elasticsearch_exporter_cmdline_extras: ""
prometheus_haproxy_exporter_cmdline_extras: ""
prometheus_memcached_exporter_cmdline_extras: ""
prometheus_mysqld_exporter_cmdline_extras: ""
prometheus_node_exporter_cmdline_extras: ""
prometheus_openstack_exporter_cmdline_extras: ""

prometheus_alertmanager_external_url: "{{ internal_protocol }}://{{ kolla_internal_fqdn | put_address_in_context('url') }}:{{ prometheus_alertmanager_port }}"
