Page MenuHomeDevCentral

D3370.diff
No OneTemporary

D3370.diff

diff --git a/_modules/prometheus.py b/_modules/prometheus.py
new file mode 100644
--- /dev/null
+++ b/_modules/prometheus.py
@@ -0,0 +1,68 @@
+# -------------------------------------------------------------
+# Salt — Prometheus execution module
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Description: Functions related to Prometheus configuration
+# License: BSD-2-Clause
+# -------------------------------------------------------------
+
+
+SCRAPE_CONFIG_OPTIONS_RENAME = {
+ "name": "job_name",
+}
+
+SCRAPE_CONFIG_OPTIONS_PASSTHROUGH = [
+ "scheme",
+ "metrics_path",
+]
+
+
+def get_scrape_configs():
+ configs = __pillar__.get("prometheus_scrape_jobs", {}).values()
+ return [_build_scrape_config(config) for config in configs]
+
+
+def _build_scrape_config(config):
+ scrape_config = {}
+
+ for key in SCRAPE_CONFIG_OPTIONS_PASSTHROUGH:
+ if key in config:
+ scrape_config[key] = config[key]
+
+ for pillar_key, scrape_config_key in SCRAPE_CONFIG_OPTIONS_RENAME.items():
+ if pillar_key in config:
+ scrape_config[scrape_config_key] = config[pillar_key]
+
+ scrape_targets = []
+
+ for target in config.get("services_targets", []):
+ address = _resolve_service(target)
+ scrape_targets.append(address)
+
+ for targets in config.get("services_targets_list", []):
+ addresses = _resolve_service_list(targets)
+ scrape_targets.extend(addresses)
+
+ scrape_config["static_configs"] = [{"targets": scrape_targets}]
+
+ return scrape_config
+
+
+def _resolve_service(config):
+ if "service" not in config or "port" not in config:
+ raise ValueError("service and port keys are both required to define a service")
+
+ key = "nasqueron_services:" + config["service"]
+ address = __salt__["pillar.get"](key)
+
+ return address + ":" + str(config["port"])
+
+
+def _resolve_service_list(config):
+ if "service" not in config or "port" not in config:
+ raise ValueError("service and port keys are both required to define a service")
+
+ key = "nasqueron_services:" + config["service"]
+ addresses = __salt__["pillar.get"](key)
+
+ return [address + ":" + str(config["port"]) for address in addresses]
diff --git a/_tests/data/prometheus.yaml b/_tests/data/prometheus.yaml
new file mode 100644
--- /dev/null
+++ b/_tests/data/prometheus.yaml
@@ -0,0 +1,21 @@
+nasqueron_services:
+ green: emerald
+
+ blue:
+ all:
+ - cyan
+ - turquoise
+ - ultramarine
+
+prometheus_scrape_jobs:
+ green_nodes:
+ name: green
+ services_targets:
+ - service: green
+ port: 9090
+
+ blue_nodes:
+ name: blue
+ services_targets_list:
+ - service: "blue:all"
+ port: 9100
diff --git a/_tests/data/prometheus_scrape_configs.yml b/_tests/data/prometheus_scrape_configs.yml
new file mode 100644
--- /dev/null
+++ b/_tests/data/prometheus_scrape_configs.yml
@@ -0,0 +1,10 @@
+- job_name: green
+ static_configs:
+ - targets:
+ - emerald:9090
+- job_name: blue
+ static_configs:
+ - targets:
+ - cyan:9100
+ - turquoise:9100
+ - ultramarine:9100
diff --git a/_tests/modules/test_prometheus.py b/_tests/modules/test_prometheus.py
new file mode 100755
--- /dev/null
+++ b/_tests/modules/test_prometheus.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python3
+
+from importlib.machinery import SourceFileLoader
+import unittest
+
+salt_test_case = SourceFileLoader("salt_test_case", "salt_test_case.py").load_module()
+prometheus = SourceFileLoader("prometheus", "../_modules/prometheus.py").load_module()
+
+
+class Testinstance(unittest.TestCase, salt_test_case.SaltTestCase):
+ def setUp(self):
+ self.initialize_mocks()
+ self.instance = prometheus
+
+ self.mock_pillar("data/prometheus.yaml")
+
+ self.mock_salt()
+ self.mock_salt_pillar_get()
+
+ def test_resolve_service(self):
+ service = {
+ "service": "green",
+ "port": "9090",
+ }
+
+ self.assertEquals("emerald:9090", prometheus._resolve_service(service))
+
+ def test_resolve_service_list(self):
+ service = {
+ "service": "blue:all",
+ "port": "9090",
+ }
+
+ expected = [
+ "cyan:9090",
+ "turquoise:9090",
+ "ultramarine:9090",
+ ]
+
+ self.assertEquals(expected, prometheus._resolve_service_list(service))
+
+ def test_get_scrape_configs(self):
+ expected = self.import_data_from_yaml("data/prometheus_scrape_configs.yml")
+ actual = prometheus.get_scrape_configs()
+
+ self.assertEquals(expected, actual)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/_tests/salt_test_case.py b/_tests/salt_test_case.py
--- a/_tests/salt_test_case.py
+++ b/_tests/salt_test_case.py
@@ -34,3 +34,21 @@
target = self.instance
target.__salt__ = self.salt
+
+ def mock_salt_pillar_get(self, target=None):
+ if not target:
+ target = self.instance
+
+ target.__salt__["pillar.get"] = lambda key: pillar_get(target.__pillar__, key)
+
+
+def pillar_get(pillar, key, default=""):
+ if ":" not in key:
+ return pillar.get(key, default)
+
+ keys = key.split(":")
+
+ data = pillar[keys[0]]
+ remaining_key = ":".join(keys[1:])
+
+ return pillar_get(data, remaining_key, default)
diff --git a/pillar/observability/prometheus.sls b/pillar/observability/prometheus.sls
new file mode 100644
--- /dev/null
+++ b/pillar/observability/prometheus.sls
@@ -0,0 +1,50 @@
+# -------------------------------------------------------------
+# Salt configuration for Nasqueron servers
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Description: Prometheus configuraiton
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# Scrape jobs
+#
+# Options supported from Prometheus scrape_config syntax:
+# - name
+# - scheme
+# - metrics_path
+#
+# Options mapped with pillar/services/table.sls for services:
+# - services_targets: list of services dictionaries
+# - service: name in nasqueron_services pillar
+# - port
+#
+# - services_targets_list will have the same behavior
+# but will read a list of services in nasqueron_services
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+prometheus_scrape_jobs:
+ prometheus_itself:
+ name: prometheus
+ services_targets:
+ - service: prometheus
+ port: 9090
+
+ node_exporter:
+ name: node
+ services_targets_list:
+ - service: "all"
+ port: 9100
+
+ netbox:
+ name: netbox
+ scheme: https
+ services_targets:
+ - service: netbox_domain
+ port: 443
+
+ paas_docker:
+ name: docker
+ services_targets_list:
+ - service: "docker:all"
+ port: 9323
diff --git a/pillar/services/table.sls b/pillar/services/table.sls
--- a/pillar/services/table.sls
+++ b/pillar/services/table.sls
@@ -19,7 +19,27 @@
api: 172.27.27.5
cd: 172.27.27.5
notifications: 172.27.27.5
+ all:
+ - 172.27.27.4
+ - 172.27.27.5
# Databases
db-A: 172.27.27.8
db-B: 172.27.27.9
+
+ # NetBox
+ netbox_domain: netbox.nasqueron.org
+
+ # Observability
+ prometheus: 172.27.27.35
+
+ all:
+ - 172.27.27.1 # router-001
+ - 172.27.27.3 # hervil
+ - 172.27.27.4 # dwellers
+ - 172.27.27.5 # docker-002
+ - 172.27.27.7 # complector
+ - 172.27.27.8 # db-A-001
+ - 172.27.27.9 # db-B-001
+ - 172.27.27.10 # web-001
+ - 172.27.27.35 # windriver
diff --git a/pillar/top.sls b/pillar/top.sls
--- a/pillar/top.sls
+++ b/pillar/top.sls
@@ -69,5 +69,6 @@
- devserver.datacubes
- devserver.ports
- devserver.repos
+ - observability.prometheus
- webserver.labs
- webserver.wwwroot51
diff --git a/roles/prometheus/init.sls b/roles/prometheus/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/prometheus/init.sls
@@ -0,0 +1,10 @@
+# -------------------------------------------------------------
+# Salt — Provision Prometheus
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+include:
+ - .prometheus
+ - .monitoring
diff --git a/roles/prometheus/monitoring/files/check-prometheus.sh b/roles/prometheus/monitoring/files/check-prometheus.sh
new file mode 100755
--- /dev/null
+++ b/roles/prometheus/monitoring/files/check-prometheus.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Monitoring :: NRPE check :: Prometheus
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/prometheus/monitoring/files/check-prometheus.sh
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+set -e
+
+EXIT_UNKNOWN=3
+
+CHECK_COMMAND="{{ dirs.bin }}/promtool"
+CONFIG_FILE="{{ dirs.etc }}/prometheus.yml"
+
+if ! command -v "$CHECK_COMMAND" >/dev/null 2>&1; then
+ echo "promtool isn't available, can't run check" >&2
+ exit $EXIT_UNKNOWN
+fi
+
+# As far as tested, promtool exits with 0 or 1.
+# Parsing and success messages are sent to stdout.
+# Parsing and validation errors are sent to stderr.
+"$CHECK_COMMAND" check config "$CONFIG_FILE" > /dev/null
diff --git a/roles/prometheus/monitoring/init.sls b/roles/prometheus/monitoring/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/prometheus/monitoring/init.sls
@@ -0,0 +1,17 @@
+# -------------------------------------------------------------
+# Salt :: Monitoring :: Prometheus
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+{% from "map.jinja" import dirs with context %}
+
+{{ dirs.share }}/monitoring/checks/nrpe/check-prometheus:
+ file.managed:
+ - source: salt://roles/prometheus/monitoring/files/check-prometheus.sh
+ - mode: 755
+ - template: jinja
+ - makedirs: True
+ - context:
+ dirs: {{ dirs }}
diff --git a/roles/prometheus/prometheus/config.sls b/roles/prometheus/prometheus/config.sls
new file mode 100644
--- /dev/null
+++ b/roles/prometheus/prometheus/config.sls
@@ -0,0 +1,46 @@
+# -------------------------------------------------------------
+# Salt — Provision Prometheus
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+{% from "map.jinja" import dirs with context %}
+
+# -------------------------------------------------------------
+# Prometheus configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{{ dirs.etc }}/prometheus.yml:
+ file.managed:
+ - source: salt://roles/prometheus/prometheus/files/prometheus.yml
+ - template: jinja
+
+# -------------------------------------------------------------
+# Syslog configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{% if grains["os"] == "FreeBSD" %}
+
+{{ dirs.etc }}/newsyslog.conf.d/prometheus.conf:
+ file.managed:
+ - source: salt://roles/prometheus/prometheus/files/syslog/newsyslog.conf
+ - makedirs: True
+
+{{ dirs.etc }}/syslog.d/prometheus.conf:
+ file.managed:
+ - source: salt://roles/prometheus/prometheus/files/syslog/prometheus.conf
+ - makedirs: True
+
+prometheus_newsyslog_run:
+ cmd.run:
+ - name: newsyslog -C
+ - creates: /var/log/prometheus.log
+
+prometheus_syslog_reload:
+ cmd.run:
+ - name: /etc/rc.d/syslogd reload
+ - onchanges:
+ - file: {{ dirs.etc }}/syslog.d/prometheus.conf
+
+{% endif %}
diff --git a/roles/prometheus/prometheus/files/prometheus.yml b/roles/prometheus/prometheus/files/prometheus.yml
new file mode 100644
--- /dev/null
+++ b/roles/prometheus/prometheus/files/prometheus.yml
@@ -0,0 +1,49 @@
+# -------------------------------------------------------------
+# Prometheus configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/prometheus/prometheus/files/prometheus.yml
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+# -------------------------------------------------------------
+# Global configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+global:
+ scrape_interval: 15s
+ evaluation_interval: 15s
+ scrape_timeout: 10s
+
+# -------------------------------------------------------------
+# Alertmanager
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+alerting:
+ alertmanagers:
+ - static_configs:
+ - targets:
+ # - alertmanager:9093
+
+# -------------------------------------------------------------
+# Rules
+#
+# Load rules once and periodically evaluate them.
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+rule_files: []
+
+# -------------------------------------------------------------
+# Scrape
+#
+# Auto-generated from pillar/observability/prometheus.sls
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+scrape_configs: {{ salt["prometheus.get_scrape_configs"]() }}
diff --git a/roles/prometheus/prometheus/files/rc/prometheus b/roles/prometheus/prometheus/files/rc/prometheus
new file mode 100755
--- /dev/null
+++ b/roles/prometheus/prometheus/files/rc/prometheus
@@ -0,0 +1,177 @@
+#!/bin/sh
+
+# PROVIDE: prometheus
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+# -------------------------------------------------------------
+# Prometheus service
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/prometheus/prometheus/files/rc/prometheus
+# Description: Custom servie allowing to set address and port
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# prometheus_enable (bool)
+# Set it to YES to enable prometheus
+# Set to NO by default
+# prometheus_user (string)
+# Set user that prometheus will run under
+# Default is "prometheus"
+# prometheus_group (string)
+# Set group that own prometheus files
+# Default is "prometheus"
+# prometheus_config (string)
+# Set full path to config file
+# Default is "/usr/local/etc/prometheus.yml"
+# prometheus_pidfile (string)
+# Set full path to pid file
+# Default is "/var/run/prometheus.pid"
+# prometheus_syslog_output_enable (bool)
+# Set it to NO to disable syslog output
+# Set to YES by default
+# prometheus_syslog_output_tag (str)
+# Set syslog tag if syslog enabled
+# Default is "prometheus"
+# prometheus_syslog_output_priority (string)
+# Set syslog priority if syslog enabled
+# Default is "info"
+# prometheus_syslog_output_facility (string)
+# Set syslog facility if syslog enabled
+# Default is "daemon"
+# prometheus_agent_mode (bool)
+# Set to "YES" to enable Prometheus Agent Mode
+# Default is "NO"
+# prometheus_address (string)
+# Set address to listen
+# Default is "127.0.0.1"
+# prometheus_port (string)
+# Set port to listen
+# Default is "9090"
+# prometheus_consoles (string)
+# Set dir that contains Prometheus consoles
+# Default is "/usr/local/share/prometheus/consoles"
+# prometheus_console_libraries (string)
+# Set dir containing Prometheus console libraries
+# Default is "/usr/local/share/prometheus/console_libraries"
+# prometheus_data_dir (string)
+# Set dir to run prometheus in
+# Default is "/var/db/prometheus"
+# prometheus_loglevel (string)
+# Set one of [debug, info, warn, error]
+# Default is "info"
+# prometheus_logformat (string)
+# Set one of [logfmt, json]
+# Default is "logfmt"
+# prometheus_env (string)
+# Set environment variables used with prometheus
+# Default is ""
+# prometheus_args (string)
+# Set additional command line arguments
+# Default is ""
+
+. /etc/rc.subr
+
+name=prometheus
+rcvar=prometheus_enable
+
+load_rc_config $name
+
+: ${prometheus_enable:="NO"}
+: ${prometheus_user:="prometheus"}
+: ${prometheus_group:="prometheus"}
+: ${prometheus_config:="/usr/local/etc/prometheus.yml"}
+: ${prometheus_pidfile:="/var/run/prometheus.pid"}
+: ${prometheus_syslog_output_enable:="YES"}
+: ${prometheus_agent_mode:="NO"}
+: ${prometheus_address:="127.0.0.1"}
+: ${prometheus_port:="9090"}
+: ${prometheus_consoles_dir:="/usr/local/share/prometheus/consoles"}
+: ${prometheus_console_libraries_dir:="/usr/local/share/prometheus/console_libraries"}
+: ${prometheus_data_dir:="/var/db/prometheus"}
+: ${prometheus_loglevel:="info"}
+: ${prometheus_logformat:="logfmt"}
+
+if checkyesno prometheus_syslog_output_enable; then
+ if [ -n "${prometheus_syslog_output_tag}" ]; then
+ prometheus_syslog_output_flags="-T ${prometheus_syslog_output_tag}"
+ else
+ prometheus_syslog_output_flags="-T ${name}"
+ fi
+ if [ -n "${prometheus_syslog_output_priority}" ]; then
+ prometheus_syslog_output_flags="${prometheus_syslog_output_flags} -s ${prometheus_syslog_output_priority}"
+ fi
+ if [ -n "${prometheus_syslog_output_facility}" ]; then
+ prometheus_syslog_output_flags="${prometheus_syslog_output_flags} -l ${prometheus_syslog_output_facility}"
+ fi
+fi
+
+if checkyesno prometheus_agent_mode; then
+ prometheus_storage_flags="--enable-feature=agent --storage.agent.path=${prometheus_data_dir}"
+else
+ prometheus_storage_flags="--storage.tsdb.path=${prometheus_data_dir}"
+fi
+
+pidfile="${prometheus_pidfile}"
+required_files="${prometheus_config}"
+
+procname="/usr/local/bin/prometheus"
+command="/usr/sbin/daemon"
+command_args="-f ${prometheus_syslog_output_flags} -p ${pidfile} -t ${name} \
+ /usr/bin/env ${prometheus_env} ${procname} \
+ --config.file=${prometheus_config} \
+ --web.listen-address=${prometheus_address}:${prometheus_port} \
+ --web.console.templates=${prometheus_consoles_dir} \
+ --web.console.libraries=${prometheus_console_libraries_dir} \
+ --log.level=${prometheus_loglevel} \
+ --log.format=${prometheus_logformat} \
+ ${prometheus_storage_flags} \
+ ${prometheus_args}"
+
+start_precmd="prometheus_start_precmd"
+extra_commands="reload"
+
+# This checks for the existence of a prometheus 1.x data at the
+# $prometheus_data_dir location. If one is found, Prometheus will not start.
+prometheus_check_data_version()
+{
+ local _version
+ local _version_file="${prometheus_data_dir}/VERSION"
+
+ if [ -f "${_version_file}" ]; then
+ read _version < "${_version_file}"
+
+ if [ "${_version}" = "1" ]; then
+ return 1
+ fi
+ fi
+}
+
+prometheus_start_precmd()
+{
+ if [ ! -e "${pidfile}" ]; then
+ install -m 0600 -o "${prometheus_user}" -g "${prometheus_group}" /dev/null "${pidfile}"
+ fi
+ if [ ! -d "${prometheus_data_dir}" ]; then
+ install -d -m 750 -o "${prometheus_user}" -g "${prometheus_group}" "${prometheus_data_dir}"
+ else
+ # Ensure it's not a prometheus 1.x data
+ if [ ! prometheus_check_data_version ]; then
+ err 1 "Found \"net-mgmt/prometheus1\" data, refusing to start."
+ fi
+ fi
+}
+
+run_rc_command "$1"
diff --git a/roles/prometheus/prometheus/files/rc/prometheus.conf b/roles/prometheus/prometheus/files/rc/prometheus.conf
new file mode 100644
--- /dev/null
+++ b/roles/prometheus/prometheus/files/rc/prometheus.conf
@@ -0,0 +1,18 @@
+# -------------------------------------------------------------
+# prometheus — rc configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/prometheus/prometheus/files/prometheus.rc
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+prometheus_enable="YES"
+prometheus_address="{{ ip }}"
+prometheus_loglevel="notice"
diff --git a/roles/prometheus/prometheus/files/syslog/newsyslog.conf b/roles/prometheus/prometheus/files/syslog/newsyslog.conf
new file mode 100644
--- /dev/null
+++ b/roles/prometheus/prometheus/files/syslog/newsyslog.conf
@@ -0,0 +1,16 @@
+# -------------------------------------------------------------
+# Prometheus :: newsyslog configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/prometheus/prometheus/files/syslog/newsyslog.conf
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+/var/log/prometheus.log 644 5 1000 * JC
diff --git a/roles/prometheus/prometheus/files/syslog/prometheus.conf b/roles/prometheus/prometheus/files/syslog/prometheus.conf
new file mode 100644
--- /dev/null
+++ b/roles/prometheus/prometheus/files/syslog/prometheus.conf
@@ -0,0 +1,17 @@
+# -------------------------------------------------------------
+# Prometheus :: syslog configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/prometheus/prometheus/files/syslog/prometheus.conf
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+!prometheus,node_exporter
+*.info /var/log/prometheus.log
diff --git a/roles/prometheus/prometheus/init.sls b/roles/prometheus/prometheus/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/prometheus/prometheus/init.sls
@@ -0,0 +1,11 @@
+# -------------------------------------------------------------
+# Salt — Provision Prometheus
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+include:
+ - .software
+ - .config
+ - .service
diff --git a/roles/prometheus/prometheus/service.sls b/roles/prometheus/prometheus/service.sls
new file mode 100644
--- /dev/null
+++ b/roles/prometheus/prometheus/service.sls
@@ -0,0 +1,31 @@
+# -------------------------------------------------------------
+# Salt — Provision Prometheus
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# Prometheus service
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{% if grains['os'] == 'FreeBSD' %}
+
+/usr/local/etc/rc.d/prometheus:
+ file.managed:
+ - source: salt://roles/prometheus/prometheus/files/rc/prometheus
+ - mode: 755
+
+/etc/rc.conf.d/prometheus:
+ file.managed:
+ - source: salt://roles/prometheus/prometheus/files/rc/prometheus.conf
+ - template: jinja
+ - context:
+ ip: {{ pillar["nasqueron_services"]["prometheus"] }}
+
+{% endif %}
+
+prometheus_running:
+ service.running:
+ - name: prometheus
+
diff --git a/roles/prometheus/prometheus/software.sls b/roles/prometheus/prometheus/software.sls
new file mode 100644
--- /dev/null
+++ b/roles/prometheus/prometheus/software.sls
@@ -0,0 +1,11 @@
+# -------------------------------------------------------------
+# Salt — Provision Prometheus
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+prometheus_software:
+ pkg.installed:
+ - pkgs:
+ - prometheus
diff --git a/top.sls b/top.sls
--- a/top.sls
+++ b/top.sls
@@ -26,6 +26,7 @@
- roles/dbserver-pgsql
- roles/devserver
- roles/grafana
+ - roles/prometheus
- roles/redis
- roles/saas-nextcloud
- roles/webserver-alkane

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 22, 08:35 (7 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2310472
Default Alt Text
D3370.diff (25 KB)

Event Timeline