From 9aab7e675dd327febbd4a5e21e9de92fc2cd0aa1 Mon Sep 17 00:00:00 2001 From: Denys Holius Date: Wed, 18 Dec 2024 15:31:10 +0200 Subject: [PATCH] adds VictoriaMetrics, cost-effective and scalable monitoring solution and time series database see also https://docs.victoriametrics.com/ --- ct/victoriametrics.sh | 65 +++++++++++++++++++++ install/victoriametrics-install.sh | 93 ++++++++++++++++++++++++++++++ json/victoriametrics.json | 34 +++++++++++ 3 files changed, 192 insertions(+) create mode 100644 ct/victoriametrics.sh create mode 100644 install/victoriametrics-install.sh create mode 100644 json/victoriametrics.json diff --git a/ct/victoriametrics.sh b/ct/victoriametrics.sh new file mode 100644 index 00000000..88a648bc --- /dev/null +++ b/ct/victoriametrics.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://prometheus.io/ + +# App Default Values +APP="VictoriaMetrics" +var_tags="monitoring" +var_cpu="1" +var_ram="2048" +var_disk="4" +var_os="debian" +var_version="12" +var_unprivileged="1" + +# App Output & Base Settings +header_info "$APP" +base_settings + +# Core +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -f /etc/systemd/system/victoriametrics.service ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -s https://api.github.com/repos/VictoriaMetrics/VictoriaMetrics/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Stopping ${APP}" + systemctl stop victoriametrics + msg_ok "Stopped ${APP}" + msg_info "Updating ${APP} to ${RELEASE}" + wget -q https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v${RELEASE}/victoria-metrics-linux-amd64-${RELEASE}.tar.gz + tar -xf victoria-metrics-linux-amd64-${RELEASE}.tar.gz + cp -rf victoria-metrics-prod /usr/local/bin/ + rm -rf victoria-metrics-linux-amd64-${RELEASE}.tar.gz + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to ${RELEASE}" + + msg_info "Starting ${APP}" + systemctl start victoriametrics + msg_ok "Started ${APP}" + msg_ok "Updated Successfully" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8429${CL}" \ No newline at end of file diff --git a/install/victoriametrics-install.sh b/install/victoriametrics-install.sh new file mode 100644 index 00000000..ae74e93f --- /dev/null +++ b/install/victoriametrics-install.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing VictoriaMetrics" +RELEASE=$(curl -s https://api.github.com/repos/VictoriaMetrics/VictoriaMetrics/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +mkdir -p /etc/victoriametrics +mkdir -p /var/lib/victoriametrics +groupadd -r victoriametrics +useradd -g victoriametrics -d /var/lib/victoriametrics -s /sbin/nologin --system victoriametrics +chown -R victoriametrics:victoriametrics /var/lib/victoria-metrics +wget -q https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v${RELEASE}/victoria-metrics-linux-amd64-${RELEASE}.tar.gz +tar -xf victoria-metrics-linux-amd64-${RELEASE}.tar.gz +chmod +x /usr/bin/victoria-metrics-prod +chown root:root /usr/bin/victoria-metrics-prod + +cat </etc/victoriametrics/scrape.yml +# Scrape config example +# +scrape_configs: + - job_name: self_scrape + scrape_interval: 10s + static_configs: + - targets: ['127.0.0.1:8428'] +END + +mv victoria-metrics-prod /usr/local/bin/ +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed VictoriaMetrics" + +msg_info "Creating Service" +service_path="/etc/systemd/system/victoriametrics.service" +echo "[Unit] +Description=VictoriaMetrics is a fast, cost-effective and scalable monitoring solution and time series database. +# https://docs.victoriametrics.com +# See https://docs.victoriametrics.com/#list-of-command-line-flags to get more information about supported command-line flags +Description=VictoriaMetrics +Wants=network-online.target +After=network-online.target + +[Service] +ExecStop=/bin/kill -s SIGTERM \$MAINPID +ExecReload=/bin/kill -HUP \$MAINPID +User=root +Restart=always +Type=simple +ExecStart=/usr/local/bin/victoria-metrics-prod \ + -promscrape.config=/etc/victoriametrics/scrape.yml \ + -storageDataPath=/var/lib/victoriametrics \ + -retentionPeriod=12 \ + -httpListenAddr=:8428 \ + -graphiteListenAddr=:2003 \ + -opentsdbListenAddr=:4242 \ + -influxListenAddr=:8089 \ + -enableTCP6 + +LimitNOFILE=1048576 +LimitNPROC=1048576 +LimitCORE=infinity +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=victoriametrics + +[Install] +WantedBy=multi-user.target" >$service_path +systemctl enable -q --now victoriametrics +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +rm -rf victoria-metrics-linux-amd64-${RELEASE}.tar.gz +msg_ok "Cleaned" diff --git a/json/victoriametrics.json b/json/victoriametrics.json new file mode 100644 index 00000000..9bd30c99 --- /dev/null +++ b/json/victoriametrics.json @@ -0,0 +1,34 @@ +{ + "name": "VictoriaMetrics", + "slug": "victoriametrics", + "categories": [ + 7 + ], + "date_created": "2024-12-18", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 8428, + "documentation": null, + "website": "https://victoriametrics.com/", + "logo": "https://raw.githubusercontent.com/loganmarchione/homelab-svg-assets/main/assets/victoriametrics-black.svg", + "description": "VictoriaMetrics is a fast, cost-effective and scalable monitoring solution and time series database.", + "install_methods": [ + { + "type": "default", + "script": "ct/victoriametrics.sh", + "resources": { + "cpu": 1, + "ram": 2048, + "hdd": 4, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} \ No newline at end of file