+ Working prometheus setup for host metrics

This commit is contained in:
shockrah 2022-04-27 21:24:06 -07:00
parent 99a84d454c
commit e8524e950c
4 changed files with 107 additions and 0 deletions

View File

@ -0,0 +1,17 @@
[Unit]
Description=Node Exporter which exposes host metrics for Prometheus
After=network.target
[Service]
WorkingDirectory=/opt/prom-node-exporter
Type=simple
Restart=simple
Restart=always
Restart=10
ExecStart=/opt/prom-node-exporter/node_exporter
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,63 @@
---
- hosts: leftcoastlab
vars:
PROM_URL: "https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz"
become: yes
tasks:
- name: Include Global Vars
include_vars:
dir: ../vars
# - name: Download prometheus Node Explorer static binary tarball
# get_url:
# url: "{{ PROM_URL }}"
# dest: /tmp/prom-node-exporer.tar.gz
#
# - name: Untar node exporter tarball package
# unarchive:
# src: /tmp/prom-node-exporer.tar.gz
# dest: /opt/prom-node-exporter
# creates: /opt/prom-node-exporter
# remote_src: yes
#
# - name: Copy Unit file for node exporter
# copy:
# src: ../files/services/node_exporter.service
# dest: /etc/systemd/system/node_exporter.service
#
# - name: Install Node Exporter Service and Start
# systemd:
# daemon_reload: yes
# name: node_exporter
# state: restarted
# enabled: yes
- name: Ensure Prom Docker Volume Exists
community.docker.docker_volume:
name: prometheus-volume
- name: Ensure Config directory exists
file:
path: /opt/prometheus
state: directory
- name: Copy Prometheus template to target directory
template:
dest: /opt/prometheus/prometheus.yml
src: ../templates/prometheus.yml.j2
- name: Setup Prometheus (Containerized) Service
community.docker.docker_container:
name: prometheus
image: prom/prometheus
pull: yes
restart_policy: always
recreate: yes
volumes:
- "prometheus-volume:/prometheus"
- "/opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml"
ports:
- "{{PROM_PORT}}:{{PROM_PORT}}"

View File

@ -0,0 +1,26 @@
global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 15s
alerting:
alertmanagers:
- follow_redirects: true
enable_http2: true
scheme: http
timeout: 10s
api_version: v2
static_configs:
- targets: []
scrape_configs:
- job_name: prometheus-scraper
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
follow_redirects: true
enable_http2: true
static_configs:
- targets:
- localhost:9090
- "{{PRIVATE_IP}}":9100

View File

@ -7,3 +7,4 @@ FILEBROWSER_PORT: 8080
LOKI_PORT: 3100
GRAFANA_PORT: 6000
SUBSONIC_PORT: 4040
PROM_PORT: 9090