Ansible role to install and configure Prometheus.
Building and improving this Ansible role have been sponsored by my current and previous employers like Cloudpunks GmbH and Proact Deutschland GmbH.
- Requirements
- Default Variables
- prometheus_alertmanagers
- prometheus_cpu_shares
- prometheus_default_folders
- prometheus_default_labels
- prometheus_default_publish
- prometheus_default_rules
- prometheus_default_volumes
- prometheus_domain
- prometheus_download
- prometheus_enable_remote_write_receiver
- prometheus_evaluation_interval
- prometheus_extra_folders
- prometheus_extra_labels
- prometheus_extra_publish
- prometheus_extra_rules
- prometheus_extra_volumes
- prometheus_image
- prometheus_installation
- prometheus_listen_address
- prometheus_memory_limit
- prometheus_memory_soft_limit
- prometheus_memory_swap
- prometheus_network
- prometheus_number_of_cpus
- prometheus_oauth2_access_logging
- prometheus_oauth2_allowed_groups
- prometheus_oauth2_client_id
- prometheus_oauth2_client_secret
- prometheus_oauth2_cookie_secret
- prometheus_oauth2_cpu_shares
- prometheus_oauth2_default_labels
- prometheus_oauth2_default_publish
- prometheus_oauth2_download
- prometheus_oauth2_enabled
- prometheus_oauth2_extra_labels
- prometheus_oauth2_extra_publish
- prometheus_oauth2_image
- prometheus_oauth2_keycloak_url
- prometheus_oauth2_listen_address
- prometheus_oauth2_memory_limit
- prometheus_oauth2_memory_soft_limit
- prometheus_oauth2_memory_swap
- prometheus_oauth2_network
- prometheus_oauth2_number_of_cpus
- prometheus_oauth2_provider
- prometheus_oauth2_pull_image
- prometheus_oauth2_request_logging
- prometheus_oauth2_static_groups
- prometheus_oauth2_static_users
- prometheus_oauth2_upstream
- prometheus_oauth2_version
- prometheus_pull_image
- prometheus_rule_files
- prometheus_scrape_configs
- prometheus_scrape_interval
- prometheus_tsdb_retention_size
- prometheus_tsdb_retention_time
- prometheus_version
- Discovered Tags
- Dependencies
- License
- Author
- Minimum Ansible version:
2.10
List of alertmanager configuration
prometheus_alertmanagers: []
prometheus_alertmanagers:
- scheme: http
static_configs:
- targets:
- loclhost:9093
CPU shares with Docker deployment
prometheus_cpu_shares:
prometheus_cpu_shares: '512'
List of default folders to create
prometheus_default_folders:
- /etc/prometheus
- /etc/prometheus/rules
- /var/lib/prometheus
List of default labels to assign to docker
prometheus_default_labels: []
List of default port publishing for docker
prometheus_default_publish: []
prometheus_default_publish:
- 127.0.0.1:9090:9090
List of default rule file definitions
prometheus_default_rules: []
prometheus_default_rules:
- name: example
content:
groups:
- name: example
rules:
- alert: ...
expr: ...
for: 5m
- name: example-from-url
url: http://example.com/example.yml
- name: example-from-template
src: path/to/template.j2
- name: example-to-remove
state: absent
List of default volumes to mount for docker
prometheus_default_volumes:
- /var/lib/prometheus:/var/lib/prometheus
- /etc/prometheus/rules:/etc/prometheus/rules
Domain for external access
prometheus_domain:
prometheus_domain: https://prometheus.example.com
URL to the archive of the release to install
prometheus_download: https://github.com/prometheus/prometheus/releases/download/v{{
prometheus_version }}/prometheus-{{ prometheus_version }}.linux-amd64.tar.gz
Enable remote-write receiver in Prometheus
prometheus_enable_remote_write_receiver: false
Global default evaluation interval
prometheus_evaluation_interval: 15s
List of extra folders to create
prometheus_extra_folders: []
prometheus_extra_folders:
- /path/to/host/folder1
- /path/to/host/folder2
- /path/to/host/folder3
List of extra labels to assign to docker
prometheus_extra_labels: []
List of extra port publishing for docker
prometheus_extra_publish: []
prometheus_extra_publish:
- 127.0.0.1:9000:9000
List of extra rule file definitions
prometheus_extra_rules: []
prometheus_extra_rules:
- name: example
content:
groups:
- name: example
rules:
- alert: ...
expr: ...
for: 5m
- name: example-from-url
url: http://example.com/example.yml
- name: example-from-template
src: path/to/template.j2
- name: example-to-remove
state: absent
List of extra volumes to mount for docker
prometheus_extra_volumes: []
prometheus_extra_volumes:
- /path/to/host/folder1:/path/within/container1
- /path/to/host/folder2:/path/within/container2
- /path/to/host/folder3:/path/within/container3
Docker image to use for deployment on OAuth2 Proxy
prometheus_image: quay.io/prometheus/prometheus:v{{ prometheus_version }}
Select installation method, could be native or docker
prometheus_installation: native
Listen address for the prometheus
prometheus_listen_address: 0.0.0.0:9090
Memory limit with Docker deployment
prometheus_memory_limit:
prometheus_memory_limit: 1024m
Soft memory limit with Docker deployment
prometheus_memory_soft_limit:
prometheus_memory_soft_limit: 512m
Swap usage with Docker deployment
prometheus_memory_swap:
prometheus_memory_swap: 2048m
Optional docker network to attach on OAuth2 Proxy
prometheus_network:
Number of CPUs with Docker deployment
prometheus_number_of_cpus:
prometheus_number_of_cpus: '1.0'
Enable access logging for OAuth2 proxy
prometheus_oauth2_access_logging: false
List of groups to allow access
prometheus_oauth2_allowed_groups: []
prometheus_oauth2_allowed_groups:
- /Group1
- /Group2
- /Group3
Client ID for OAuth2 authentication
prometheus_oauth2_client_id:
Client secret for OAuth2 authentication
prometheus_oauth2_client_secret:
Cookie secret used by OAuth2 proxy
prometheus_oauth2_cookie_secret:
CPU shares with Docker deployment
prometheus_oauth2_cpu_shares:
prometheus_oauth2_cpu_shares: '512'
List of default labels to assign to docker on OAuth2 Proxy
prometheus_oauth2_default_labels: []
List of default port publishing for docker on OAuth2 Proxy
prometheus_oauth2_default_publish: []
prometheus_oauth2_default_publish:
- 127.0.0.1:9089:9089
prometheus_oauth2_download: https://github.com/oauth2-proxy/oauth2-proxy/releases/download/v{{
prometheus_oauth2_version }}/oauth2-proxy-v{{ prometheus_oauth2_version }}.linux-amd64.tar.gz
URL of the OAuth2 Proxy to download
prometheus_oauth2_enabled: false
List of extra labels to assign to docker on OAuth2 Proxy
prometheus_oauth2_extra_labels: []
List of extra port publishing for docker on OAuth2 Proxy
prometheus_oauth2_extra_publish: []
prometheus_oauth2_extra_publish:
- 127.0.0.1:9089:9089
prometheus_oauth2_image: quay.io/oauth2-proxy/oauth2-proxy:v{{ prometheus_oauth2_version
}}
URL of the Keycloak realm
prometheus_oauth2_keycloak_url:
Listem address for the OAuth2 proxy
prometheus_oauth2_listen_address: 0.0.0.0:9089
Memory limit with Docker deployment
prometheus_oauth2_memory_limit:
prometheus_oauth2_memory_limit: 1024m
Soft memory limit with Docker deployment
prometheus_oauth2_memory_soft_limit:
prometheus_oauth2_memory_soft_limit: 512m
Swap usage with Docker deployment
prometheus_oauth2_memory_swap:
prometheus_oauth2_memory_swap: 2048m
prometheus_oauth2_network: '{{ prometheus_network }}'
Number of CPUs with Docker deployment
prometheus_oauth2_number_of_cpus:
prometheus_oauth2_number_of_cpus: '1.5'
Provider for OAuth2 authentication
prometheus_oauth2_provider: keycloak
prometheus_oauth2_pull_image: true
Enable request logging for OAuth2 proxy
prometheus_oauth2_request_logging: false
List of groups assigned to static users
prometheus_oauth2_static_groups: []
List of users to allow access
prometheus_oauth2_static_users: []
prometheus_oauth2_static_users:
- username: username1
password: p455w0rd
- username: username2
password: p455w0rd
- username: username3
password: p455w0rd
Upstream target for the OAuth2 proxy
prometheus_oauth2_upstream: http://{{ prometheus_listen_address if prometheus_installation
== 'native' else 'prometheus:9090' }}
Version of the OAuth2 Proxy to download
prometheus_oauth2_version: 7.7.1
Pull image as part of the tasks
prometheus_pull_image: true
List of paths to read rule files from
prometheus_rule_files:
- /etc/prometheus/rules/*.yml
List of scrape configuration
prometheus_scrape_configs: []
prometheus_scrape_configs:
- job_name: prometheus
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- localhost:9090
Global default scrape interval
prometheus_scrape_interval: 15s
Retention size to define the maximum size of the data
prometheus_tsdb_retention_size:
Retention time to define the maximum age of the data
prometheus_tsdb_retention_time: 30d
Version of the release to install
prometheus_version: 3.1.0
oauth2
prometheus
Apache-2.0