Add Prometheus role
This commit is contained in:
6
roles/prometheus/defaults/main.yml
Normal file
6
roles/prometheus/defaults/main.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
prometheus_scrape_interval: 5s
|
||||||
|
prometheus_evaluation_interval: 15s
|
||||||
|
prometheus_install_grafana: false
|
||||||
|
prometheus_hcloud_relabel_configs: []
|
||||||
73
roles/prometheus/meta/argument_specs.yml
Normal file
73
roles/prometheus/meta/argument_specs.yml
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
argument_specs:
|
||||||
|
main:
|
||||||
|
short_description: Prometheus docker container
|
||||||
|
options:
|
||||||
|
prometheus_scrape_interval:
|
||||||
|
description: Interval how often prometheus will scrape the monitoring targets
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
default: 5s
|
||||||
|
prometheus_evaluation_interval:
|
||||||
|
description: Interval how often prometheus will evaluate the scraped metrics against defined conditions
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
default: 15s
|
||||||
|
prometheus_hcloud_token:
|
||||||
|
description: Access token for hetzner cloud service discovery. It will be enabled if this variable is defined
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
prometheus_hcloud_relabel_configs:
|
||||||
|
description: Relabel configs for hcloud
|
||||||
|
type: list
|
||||||
|
required: false
|
||||||
|
default: []
|
||||||
|
elements: dict
|
||||||
|
options:
|
||||||
|
source_labels:
|
||||||
|
type: list
|
||||||
|
required: true
|
||||||
|
elements: str
|
||||||
|
target_label:
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
replacement:
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
prometheus_install_grafana:
|
||||||
|
description: If true, installs grafana in the same docker network as prometheus and configures it with prometheus as data source
|
||||||
|
type: bool
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
|
||||||
|
# All options after this will be passed directly to the container role
|
||||||
|
docker_service_suffix:
|
||||||
|
description: "Passed to container role"
|
||||||
|
required: false
|
||||||
|
docker_host_user:
|
||||||
|
description: "Passed to container role"
|
||||||
|
required: false
|
||||||
|
|
||||||
|
database_passwords:
|
||||||
|
description: "Passed to container role"
|
||||||
|
required: false
|
||||||
|
docker_additional_services:
|
||||||
|
description: "Passed to container role"
|
||||||
|
required: false
|
||||||
|
|
||||||
|
docker_volume_type:
|
||||||
|
description: "Passed to container role"
|
||||||
|
required: false
|
||||||
|
reverse_proxy_type:
|
||||||
|
description: "Passed to container role"
|
||||||
|
required: false
|
||||||
|
ports:
|
||||||
|
description: "Passed to container role"
|
||||||
|
required: false
|
||||||
|
docker_vhost_domains:
|
||||||
|
description: "Passed to container role"
|
||||||
|
required: false
|
||||||
|
docker_entrypoint:
|
||||||
|
description: "Passed to container role"
|
||||||
|
required: false
|
||||||
22
roles/prometheus/tasks/main.yml
Normal file
22
roles/prometheus/tasks/main.yml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Prometheus container
|
||||||
|
import_role:
|
||||||
|
name: container
|
||||||
|
vars:
|
||||||
|
docker_service: prometheus
|
||||||
|
docker_image: prom/prometheus
|
||||||
|
reverse_proxy_type: none
|
||||||
|
docker_volumes:
|
||||||
|
- name: data
|
||||||
|
path: /prometheus
|
||||||
|
- template: prometheus.yml
|
||||||
|
path: /etc/prometheus/prometheus.yml
|
||||||
|
|
||||||
|
- name: Grafana container for prometheus
|
||||||
|
include_role:
|
||||||
|
name: grafana
|
||||||
|
vars:
|
||||||
|
docker_networks:
|
||||||
|
- name: prometheus
|
||||||
|
when: prometheus_install_grafana
|
||||||
34
roles/prometheus/templates/prometheus.yml.j2
Normal file
34
roles/prometheus/templates/prometheus.yml.j2
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
# my global config
|
||||||
|
global:
|
||||||
|
scrape_interval: {{ prometheus_scrape_interval }}
|
||||||
|
evaluation_interval: {{ prometheus_evaluation_interval }}
|
||||||
|
|
||||||
|
# Alertmanager configuration
|
||||||
|
alerting:
|
||||||
|
alertmanagers:
|
||||||
|
- static_configs:
|
||||||
|
- targets:
|
||||||
|
# - alertmanager:9093
|
||||||
|
|
||||||
|
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
|
||||||
|
rule_files:
|
||||||
|
# - "first_rules.yml"
|
||||||
|
# - "second_rules.yml"
|
||||||
|
|
||||||
|
# A scrape configuration containing exactly one endpoint to scrape:
|
||||||
|
# Here it's Prometheus itself.
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: "prometheus"
|
||||||
|
static_configs:
|
||||||
|
- targets: ["localhost:9090"]
|
||||||
|
|
||||||
|
{% if prometheus_hcloud_token is defined %}
|
||||||
|
- job_name: hcloud
|
||||||
|
hetzner_sd_configs:
|
||||||
|
- role: hcloud
|
||||||
|
authorization:
|
||||||
|
credentials: {{ prometheus_hcloud_token }}
|
||||||
|
relabel_configs: {{ prometheus_hcloud_relabel_configs }}
|
||||||
|
{% endif %}
|
||||||
Reference in New Issue
Block a user