feat(textfile_collectors): added support for textfile collectors
This commit is contained in:
parent
a0d8ad4c35
commit
930552d7ee
@ -123,3 +123,9 @@ This state will uninstall the prometheus linux alternatives for archives only.
|
|||||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
This state will uninstall the prometheus upstream package repository only.
|
This state will uninstall the prometheus upstream package repository only.
|
||||||
|
|
||||||
|
``prometheus.config.node_exporter.textfile_collectors``
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
This state will manage the node exporter's textfile collectors
|
||||||
|
according to Pillar ``prometheus:exporters:node_exporter:textfile_collectors``.
|
||||||
|
@ -35,6 +35,7 @@ prometheus:
|
|||||||
node_exporter:
|
node_exporter:
|
||||||
args:
|
args:
|
||||||
web.listen-address: ":9110"
|
web.listen-address: ":9110"
|
||||||
|
# collector.textfile.directory: /var/tmp/node_exporter
|
||||||
|
|
||||||
tofs:
|
tofs:
|
||||||
# The files_switch key serves as a selector for alternative
|
# The files_switch key serves as a selector for alternative
|
||||||
@ -164,3 +165,7 @@ prometheus:
|
|||||||
# 'Alternatives system' priority: zero disables (default)
|
# 'Alternatives system' priority: zero disables (default)
|
||||||
# yamllint disable-line rule:braces
|
# yamllint disable-line rule:braces
|
||||||
altpriority: {{ range(1, 9100000) | random }}
|
altpriority: {{ range(1, 9100000) | random }}
|
||||||
|
|
||||||
|
exporters:
|
||||||
|
node_exporter:
|
||||||
|
textfile_collectors: {}
|
||||||
|
@ -5,3 +5,4 @@ include:
|
|||||||
- .file.clean
|
- .file.clean
|
||||||
- .args.clean
|
- .args.clean
|
||||||
- .users.clean
|
- .users.clean
|
||||||
|
- .node_exporter.textfile_collectors.clean
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: ft=sls
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- .users
|
- .users
|
||||||
- .args
|
- .args
|
||||||
- .file
|
- .file
|
||||||
|
{%- if 'node_exporter' in prometheus.wanted %}
|
||||||
|
- .node_exporter.textfile_collectors
|
||||||
|
{%- endif %}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
|
||||||
|
|
||||||
|
prometheus-node_exporter-textfile_collectors-dir:
|
||||||
|
file.absent:
|
||||||
|
- name: {{ prometheus.dir.textfile_collectors }}
|
||||||
|
|
||||||
|
prometheus-node_exporter-textfile-dir:
|
||||||
|
file.absent:
|
||||||
|
- name: {{ prometheus.service.node_exporter.args.get('collector.textfile.directory') }}
|
||||||
|
|
||||||
|
{%- for collector, config in prometheus.get('exporters', {}).get('node_exporter', {}).get('textfile_collectors', {}).items() %}
|
||||||
|
include:
|
||||||
|
- .{{ collector }}.clean
|
||||||
|
{%- endfor %}
|
||||||
|
|
50
prometheus/config/node_exporter/textfile_collectors/init.sls
Normal file
50
prometheus/config/node_exporter/textfile_collectors/init.sls
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
|
||||||
|
|
||||||
|
prometheus-node_exporter-textfile_collectors-dir:
|
||||||
|
file.directory:
|
||||||
|
- name: {{ prometheus.dir.textfile_collectors }}
|
||||||
|
- mode: 755
|
||||||
|
- user: node_exporter
|
||||||
|
- group: node_exporter
|
||||||
|
- makedirs: True
|
||||||
|
|
||||||
|
prometheus-node_exporter-textfile-dir:
|
||||||
|
file.directory:
|
||||||
|
- name: {{ prometheus.service.node_exporter.args.get('collector.textfile.directory') }}
|
||||||
|
- mode: 755
|
||||||
|
- user: node_exporter
|
||||||
|
- group: node_exporter
|
||||||
|
- makedirs: True
|
||||||
|
|
||||||
|
{%- set states = [] %}
|
||||||
|
{%- for collector, config in prometheus.get('exporters', {}).get('node_exporter', {}).get('textfile_collectors', {}).items() %}
|
||||||
|
{%- if config.get('enable', False) %}
|
||||||
|
{%- if config.get('remove', False) %}
|
||||||
|
{%- set state = ".{}.clean".format(collector) %}
|
||||||
|
{%- else %}
|
||||||
|
{%- set state = ".{}".format(collector) %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- do states.append(state) %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
{%- if states|length > 0 %}
|
||||||
|
prometheus-node_exporter-textfile-dependencies:
|
||||||
|
pkg.installed:
|
||||||
|
- pkgs: {{ prometheus.exporters.node_exporter.textfile_collectors_dependencies }}
|
||||||
|
- require_in:
|
||||||
|
{%- for state in states %}
|
||||||
|
- sls: prometheus.config.node_exporter.textfile_collectors{{ state }}
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
|
include:
|
||||||
|
{%- for state in states %}
|
||||||
|
- {{ state }}
|
||||||
|
{% endfor %}
|
||||||
|
{%- endif %}
|
@ -21,16 +21,21 @@ prometheus:
|
|||||||
var: /var/lib/prometheus
|
var: /var/lib/prometheus
|
||||||
args: /etc/default
|
args: /etc/default
|
||||||
service: /usr/lib/systemd/system
|
service: /usr/lib/systemd/system
|
||||||
|
textfile_collectors: /opt/prometheus/textfile_collectors
|
||||||
|
|
||||||
service:
|
service:
|
||||||
prometheus:
|
prometheus:
|
||||||
args:
|
args:
|
||||||
web.listen-address: 0.0.0.0:9090
|
web.listen-address: 0.0.0.0:9090
|
||||||
alertmanager: {}
|
alertmanager: {}
|
||||||
|
node_exporter:
|
||||||
|
args:
|
||||||
|
collector.textfile.directory: /var/tmp/node_exporter
|
||||||
|
|
||||||
config:
|
config:
|
||||||
prometheus: {}
|
prometheus: {}
|
||||||
alertmanager: {}
|
alertmanager: {}
|
||||||
|
node_exporter: {}
|
||||||
|
|
||||||
pkg:
|
pkg:
|
||||||
prometheus:
|
prometheus:
|
||||||
@ -113,3 +118,8 @@ prometheus:
|
|||||||
|
|
||||||
linux:
|
linux:
|
||||||
altpriority: 0 ## 'Alternatives system' priority: zero disables (default)
|
altpriority: 0 ## 'Alternatives system' priority: zero disables (default)
|
||||||
|
|
||||||
|
exporters:
|
||||||
|
node_exporter:
|
||||||
|
textfile_collectors_dependencies: []
|
||||||
|
textfile_collectors: {}
|
||||||
|
@ -18,6 +18,10 @@ Debian:
|
|||||||
service:
|
service:
|
||||||
node_exporter:
|
node_exporter:
|
||||||
name: prometheus-node-exporter
|
name: prometheus-node-exporter
|
||||||
|
exporters:
|
||||||
|
node_exporter:
|
||||||
|
textfile_collectors_dependencies:
|
||||||
|
- cron
|
||||||
|
|
||||||
RedHat:
|
RedHat:
|
||||||
pkg:
|
pkg:
|
||||||
|
Loading…
Reference in New Issue
Block a user