Browse Source

Add basic config to set up prometheus servers

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Maximilian Wilhelm 1 year ago
parent
commit
10e0a0465e
4 changed files with 74 additions and 0 deletions
  1. 32 0
      prometheus-server/init.sls
  2. 2 0
      prometheus-server/prometheus.default
  3. 35 0
      prometheus-server/prometheus.yml
  4. 5 0
      top.sls

+ 32 - 0
prometheus-server/init.sls

@@ -0,0 +1,32 @@
+#
+# Set up prometheus server
+#
+
+prometheus:
+  pkg.installed:
+    - name: prometheus
+  service.running:
+    - enable: true
+    - restart: true
+
+/srv/prometheus/metrics2:
+  file.directory:
+    - makedirs: true
+    - user: prometheus
+    - group: prometheus
+
+/etc/default/prometheus:
+  file.managed:
+    - source: salt://prometheus-server/prometheus.default
+    - watch_in:
+      - service: prometheus
+
+/etc/prometheus/prometheus.yml:
+  file.managed:
+    - source: salt://prometheus-server/prometheus.yml
+    - template: jinja
+    - require:
+      - pkg: prometheus
+      - file: /srv/prometheus/metrics2
+    - watch_in:
+      - service: prometheus

+ 2 - 0
prometheus-server/prometheus.default

@@ -0,0 +1,2 @@
+# Set the command-line arguments to pass to the server.
+ARGS="--storage.tsdb.path=/srv/prometheus/metrics2/ --storage.tsdb.retention.time=30d"

+ 35 - 0
prometheus-server/prometheus.yml

@@ -0,0 +1,35 @@
+#
+# /etc/prometheus/prometheus.yaml (Salt managed)
+#
+
+global:
+  scrape_interval:     30s
+  evaluation_interval: 1m
+  # scrape_timeout is set to the global default (10s).
+
+  external_labels:
+      monitor: '{{ grains['id'] }}'
+
+#alerting:
+#  alertmanagers:
+#  - static_configs:
+#    - targets: ['localhost:9093']
+#
+## Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
+#rule_files:
+#  # - "first_rules.yml"
+#  # - "second_rules.yml"
+
+scrape_configs:
+  - job_name: 'prometheus'
+    scrape_interval: 5s
+    scrape_timeout: 5s
+    static_configs:
+      - targets: ['localhost:9090']
+
+  - job_name: node
+    static_configs:
+      - targets:
+{%- for node, node_config in salt['pillar.get']('nodes').items()|sort %}
+        - {{ node }}:9100
+{%- endfor %}

+ 5 - 0
top.sls

@@ -138,6 +138,11 @@ base:
     - match: pillar
     - librenms
 
+  # Promtheus
+  nodes:{{ grains['id'] }}:roles:prometheus:
+    - match: pillar
+    - prometheus-server
+
   # Anycasted infrastructure services
   nodes:{{ grains['id'] }}:role:infra-services:
     - match: pillar