fix linter errors
This commit is contained in:
@@ -17,9 +17,9 @@ prometheus_version: 3.2.1 # prometheus version
|
|||||||
prometheus_dir: "/etc/prometheus" # where to install prometheus
|
prometheus_dir: "/etc/prometheus" # where to install prometheus
|
||||||
prometheus_user: prometheus # user name
|
prometheus_user: prometheus # user name
|
||||||
prometheus_group: prometheus # groups name
|
prometheus_group: prometheus # groups name
|
||||||
config_dir: "/etc/prometheus/conf" # where to place prometheus config
|
prometheus_config_dir: "/etc/prometheus/conf" # where to place prometheus config
|
||||||
db_dir: "/var/lib/prometheus" # where to store prometheus db
|
prometheus_db_dir: "/var/lib/prometheus" # where to store prometheus db
|
||||||
config_source_dir: prometheus # path to config files on source
|
prometheus_config_source_dir: prometheus # path to config files on source
|
||||||
alertrules_source_dir: prometheus/rules # path to rule files on source
|
alertrules_source_dir: prometheus/rules # path to rule files on source
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ Example Playbook
|
|||||||
```yaml
|
```yaml
|
||||||
roles:
|
roles:
|
||||||
- role: genlab.prometheus
|
- role: genlab.prometheus
|
||||||
config_source_dir: mydir/configs
|
prometheus_config_source_dir: mydir/configs
|
||||||
alertrules_source_dir: mydir/configs/rules
|
alertrules_source_dir: mydir/configs/rules
|
||||||
prometheus_version: 3.2.1
|
prometheus_version: 3.2.1
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ prometheus_version: 3.2.1
|
|||||||
prometheus_dir: "/etc/prometheus"
|
prometheus_dir: "/etc/prometheus"
|
||||||
prometheus_user: prometheus
|
prometheus_user: prometheus
|
||||||
prometheus_group: prometheus
|
prometheus_group: prometheus
|
||||||
config_dir: "/etc/prometheus/conf"
|
prometheus_config_dir: "/etc/prometheus/conf"
|
||||||
db_dir: "/var/lib/prometheus"
|
prometheus_db_dir: "/var/lib/prometheus"
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ galaxy_info:
|
|||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: "Ubuntu"
|
- name: "Ubuntu"
|
||||||
versions: [ "focal", "jammy", "noble" ]
|
versions: ["focal", "jammy", "noble"]
|
||||||
|
|
||||||
galaxy_tags: [ ]
|
galaxy_tags: []
|
||||||
|
|
||||||
dependencies: []
|
dependencies: []
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
hosts: all
|
hosts: all
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: genlab.prometheus
|
- role: genlab.common.prometheus
|
||||||
config_source_dir: prometheus
|
prometheus_config_source_dir: prometheus
|
||||||
alertrules_source_dir: prometheus/rules
|
alertrules_source_dir: prometheus/rules
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
global:
|
global:
|
||||||
scrape_interval: 15s
|
scrape_interval: 15s
|
||||||
evaluation_interval: 15s
|
evaluation_interval: 15s
|
||||||
|
|
||||||
rule_files:
|
rule_files:
|
||||||
@@ -11,4 +11,4 @@ rule_files:
|
|||||||
scrape_configs:
|
scrape_configs:
|
||||||
- job_name: prometheus
|
- job_name: prometheus
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: ['localhost:9090']
|
- targets: ['localhost:9090']
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
groups:
|
groups:
|
||||||
- name: example
|
- name: example
|
||||||
labels:
|
|
||||||
team: myteam
|
|
||||||
rules:
|
|
||||||
- alert: HighRequestLatency
|
|
||||||
expr: job:request_latency_seconds:mean5m{job="myjob"} > 0.5
|
|
||||||
for: 10m
|
|
||||||
keep_firing_for: 5m
|
|
||||||
labels:
|
labels:
|
||||||
severity: page
|
team: myteam
|
||||||
annotations:
|
rules:
|
||||||
summary: High request latency
|
- alert: HighRequestLatency
|
||||||
|
expr: job:request_latency_seconds:mean5m{job="myjob"} > 0.5
|
||||||
|
for: 10m
|
||||||
|
keep_firing_for: 5m
|
||||||
|
labels:
|
||||||
|
severity: page
|
||||||
|
annotations:
|
||||||
|
summary: High request latency
|
||||||
|
|||||||
@@ -9,16 +9,16 @@
|
|||||||
- name: "Include default vars"
|
- name: "Include default vars"
|
||||||
ansible.builtin.include_vars:
|
ansible.builtin.include_vars:
|
||||||
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/"
|
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/"
|
||||||
extensions: [ 'yml' ]
|
extensions: ['yml']
|
||||||
|
|
||||||
- name: "Check if Prometheus is installed"
|
- name: "Check if Prometheus is installed"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
ansible.builtin.command: "prometheus --version"
|
ansible.builtin.command: "prometheus --version"
|
||||||
register: prom_installed_version
|
register: prometheus_installed_version
|
||||||
|
|
||||||
- name: "Check Prometheus version"
|
- name: "Check Prometheus version"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "prom_installed_version.stdout is regex('{{ prometheus_version }}')"
|
that: "prometheus_installed_version.stdout is regex('{{ prometheus_version }}')"
|
||||||
success_msg: "Prometheus version {{ prometheus_version }} is installed and working"
|
success_msg: "Prometheus version {{ prometheus_version }} is installed and working"
|
||||||
fail_msg: "Prometheus version {{ prometheus_version }} is not installed or not working correctly"
|
fail_msg: "Prometheus version {{ prometheus_version }} is not installed or not working correctly"
|
||||||
|
|
||||||
@@ -30,11 +30,11 @@
|
|||||||
status_code: 200
|
status_code: 200
|
||||||
method: GET
|
method: GET
|
||||||
body_format: json
|
body_format: json
|
||||||
register: prom_health
|
register: prometheus_health
|
||||||
|
|
||||||
- name: "Debug Prometheus health status"
|
- name: "Debug Prometheus health status"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "prom_health.content | trim == 'Prometheus Server is Healthy.'"
|
that: "prometheus_health.content | trim == 'Prometheus Server is Healthy.'"
|
||||||
success_msg: "Prometheus is healthy"
|
success_msg: "Prometheus is healthy"
|
||||||
fail_msg: "Prometheus is not healthy"
|
fail_msg: "Prometheus is not healthy"
|
||||||
|
|
||||||
@@ -46,10 +46,10 @@
|
|||||||
status_code: 200
|
status_code: 200
|
||||||
method: GET
|
method: GET
|
||||||
body_format: json
|
body_format: json
|
||||||
register: prom_ready
|
register: prometheus_ready
|
||||||
|
|
||||||
- name: "Debug Prometheus readiness status"
|
- name: "Debug Prometheus readiness status"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "prom_ready.content | trim == 'Prometheus Server is Ready.'"
|
that: "prometheus_ready.content | trim == 'Prometheus Server is Ready.'"
|
||||||
success_msg: "Prometheus is ready"
|
success_msg: "Prometheus is ready"
|
||||||
fail_msg: "Prometheus is not ready"
|
fail_msg: "Prometheus is not ready"
|
||||||
|
|||||||
@@ -3,19 +3,19 @@
|
|||||||
notify: "(Re)start Prometheus service"
|
notify: "(Re)start Prometheus service"
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: "{{ config_dir }}/{{ item | basename }}"
|
dest: "{{ prometheus_config_dir }}/{{ item | basename }}"
|
||||||
owner: "{{ prometheus_user }}"
|
owner: "{{ prometheus_user }}"
|
||||||
group: "{{ prometheus_group }}"
|
group: "{{ prometheus_group }}"
|
||||||
mode: "0660"
|
mode: "0660"
|
||||||
with_fileglob:
|
with_fileglob:
|
||||||
- "{{ config_source_dir }}/*.yml"
|
- "{{ prometheus_config_source_dir }}/*.yml"
|
||||||
|
|
||||||
- name: "Copy alert rules"
|
- name: "Copy alert rules"
|
||||||
notify: "(Re)start Prometheus service"
|
notify: "(Re)start Prometheus service"
|
||||||
when: alertrules_source_dir is defined
|
when: alertrules_source_dir is defined
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: "{{ config_dir }}/{{ item | basename }}"
|
dest: "{{ prometheus_config_dir }}/{{ item | basename }}"
|
||||||
owner: "{{ prometheus_user }}"
|
owner: "{{ prometheus_user }}"
|
||||||
group: "{{ prometheus_group }}"
|
group: "{{ prometheus_group }}"
|
||||||
mode: "0660"
|
mode: "0660"
|
||||||
|
|||||||
@@ -37,9 +37,9 @@
|
|||||||
group: "{{ prometheus_group }}"
|
group: "{{ prometheus_group }}"
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ config_dir }}"
|
- "{{ prometheus_config_dir }}"
|
||||||
- "{{ prometheus_dir }}"
|
- "{{ prometheus_dir }}"
|
||||||
- "{{ db_dir }}"
|
- "{{ prometheus_db_dir }}"
|
||||||
|
|
||||||
- name: "Download Prometheus binary"
|
- name: "Download Prometheus binary"
|
||||||
ansible.builtin.get_url:
|
ansible.builtin.get_url:
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ User=prometheus
|
|||||||
Group=prometheus
|
Group=prometheus
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/usr/local/bin/prometheus \
|
ExecStart=/usr/local/bin/prometheus \
|
||||||
--config.file {{ config_dir }}/prometheus.yml \
|
--config.file {{ prometheus_config_dir }}/prometheus.yml \
|
||||||
--storage.tsdb.path {{ db_dir }} \
|
--storage.tsdb.path {{ prometheus_db_dir }} \
|
||||||
--storage.tsdb.retention.time=30d
|
--storage.tsdb.retention.time=30d
|
||||||
|
|
||||||
# Security hardening
|
# Security hardening
|
||||||
ReadWritePaths={{ db_dir }}
|
ReadWritePaths={{ prometheus_db_dir }}
|
||||||
ProtectSystem=strict
|
ProtectSystem=strict
|
||||||
NoNewPrivileges=true
|
NoNewPrivileges=true
|
||||||
PrivateTmp=true
|
PrivateTmp=true
|
||||||
|
|||||||
Reference in New Issue
Block a user