Skip to content

Instantly share code, notes, and snippets.

@Bharat-B
Created February 4, 2022 18:46
Show Gist options
  • Save Bharat-B/d655c244e070b169aadc4a14f1d06735 to your computer and use it in GitHub Desktop.
Save Bharat-B/d655c244e070b169aadc4a14f1d06735 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Grafana Repository and Installation commands
wget -q -O - https://packages.grafana.com/gpg.key | apt-key add -
add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
apt-get update
apt-get install grafana
systemctl enable grafana-server
systemctl start grafana-server
# The following package allows you to run commands like netstat, ifconfig etc.
apt-get install net-tools -y
# The following commands shows what port grafana is listening on
netstat -plunt | grep grafana
# Installing nGINX
apt-get install nginx -y
# Open the following file to overwrite the configuration as described in the Tutorial
nano /etc/nginx/sites-enabled/default
# Setting up SSL via letsencrypt
wget https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh
chmod +x acme.sh
./acme.sh --issue -d domain.tld -w /var/www/html --home /etc/nginx/ssl
# Setup a cron for ACME to auto renew your ssl and nginx to reload 5 minutes later
echo "0 0 * * * root /root/acme.sh --cron --home /etc/nginx/ssl" > /etc/cron.d/acme.cron
echo "05 0 * * * root /sbin/nginx -s reload" > /etc/cron.d/nginx.cron
# Setting up VictoriaMetrics
apt-get install -y jq
export VM_VER=`curl -s https://api.github.com/repos/VictoriaMetrics/VictoriaMetrics/releases/latest | jq -r '.tag_name'`
curl -L https://github.com/VictoriaMetrics/releases/download/${VM_VER}/victoria-metrics-amd64-${VM_VER}.tar.gz --output victoria-metrics-amd64-${VM_VER}.tar.gz
tar -zxvf victoria-metrics-amd64-${VM_VER}.tar.gz
mv victoria-metrics-prod /usr/local/bin
chmod +x /usr/local/bin/victoria-metrics-prod
cat <<EOF > /etc/systemd/system/victoriametrics.service
[Unit]
Description=High-Permance, scalable time series database for prometheus
After=network.target
[Service]
Type=simple
Restart=on-failure
RestartSec=5
ExecStart=/usr/local/bin/victoria-metrics-prod -storageDataPath=/mnt/victoria_metrics -httpListenAddr=127.0.0.1:8429 -retentionPeriod=3
ExecStop=/bin/kill -s SIGTERM $MAINPID
LimitNOFILE=65536
LimitNPROC=32000
[Install]
WantedBy=multi-user.target
EOF
# Installing Telegraf
wget -q -O - https://repos.influxdata.com/influxdb.key | apt-key add -
add-apt-repository "deb https://repos.influxdata.com/ubuntu focal stable"
apt-get update
apt-get install apt-transport-https telegraf -y
@binitta21
Copy link

Install VictoriaMetrics Single

VM_VERSION=curl -sg "https://api.github.com/repos/VictoriaMetrics/VictoriaMetrics/tags" | jq -r '.[0].name'
wget https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/${VM_VERSION}/victoria-metrics-linux-amd64-${VM_VERSION}.tar.gz -O /tmp/victoria-metrics.tar.gz
tar xvf /tmp/victoria-metrics.tar.gz -C /usr/bin
chmod +x /usr/bin/victoria-metrics-prod
chown root:root /usr/bin/victoria-metrics-prod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment