sudo groupadd -r prometheusGroup
sudo useradd -s /sbin/nologin --system -g prometheusGroup prometheusUser
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
tar -xvf prometheus-2.37.2.linux-amd64.tar.gz
sudo mv prometheus-2.37.2.linux-amd64 /etc/prometheus
sudo chown prometheusUser:prometheusGroup /etc/prometheus
sudo chown prometheusUser:prometheusGroup /var/lib/prometheus
sudo chown -R prometheusUser:prometheusGroup /etc/prometheus/prometheus-2.37.2.linux-amd64/consoles
sudo chown -R prometheusUser:prometheusGroup /etc/prometheus/prometheus-2.37.2.linux-amd64/console_libraries
sudo cp /etc/prometheus/prometheus-2.37.2.linux-amd64/prometheus /usr/local/bin/
sudo cp /etc/prometheus/prometheus-2.37.2.linux-amd64/promtool /usr/local/bin/
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/docs/introduction/overview/
Wants=network-online.target
After=network-online.target
[Service]
User=prometheusUser
Group=prometheusGroup
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file /etc/prometheus/prometheus-2.37.2.linux-amd64/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/prometheus-2.37.2.linux-amd64/consoles \
--web.console.libraries=/etc/prometheus/prometheus-2.37.2.linux-amd64/console_libraries \
--web.enable-remote-write-receiver
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now prometheus
systemctl status prometheus
import getpass
import bcrypt
password = getpass.getpass("password: ")
hashed_password = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt())
print(hashed_password.decode())
python3.9 gen-pass.py
basic_auth_users:
herman: $2b$12$EjRntxCfwF1HVzblEXKk5OdmNnaXJm8FV.QcD3yN1mpuWogWWHVXm
--web.config.file=/etc/prometheus/prometheus-2.37.2.linux-amd64/web.yml
systemctl daemon-reload
systemctl restart prometheus
curl_cli -u herman http://prometheus.srv:9090/metrics
[ req ]
default_bits = 4096
default_md = sha256
req_extensions = v3_req
distinguished_name = dn
prompt = no
[ v3_req ]
subjectAltName = @alt_names
[ dn ]
C = RU
ST = Volgograd
L = Russia
O = TSSolution
OU = Engineers
CN = prometheus.srv
[ alt_names ]
DNS = prometheus.srv
IP = 192.168.10.6
cpopenssl req -x509 -newkey rsa:4096 -nodes -config openssl.conf -keyout mykey.key -out mycert.crt -extensions v3_req
tls_server_config:
cert_file: /etc/prometheus/prometheus-2.37.2.linux-amd64/prometheusTLS.crt
key_file: /etc/prometheus/prometheus-2.37.2.linux-amd64/prometheusPrivate.key
--web.external-url=https://prometheus.srv:9090
systemctl daemon-reload
systemctl restart prometheus
sudo apt-get install -y adduser libfontconfig1
wget https://dl.grafana.com/oss/release/grafana_9.2.3_amd64.deb
sudo dpkg -i grafana_9.2.3_amd64.deb
systemctl daemon-reload
systemctl enable grafana-server
systemctl start grafana-server
{
"enabled": true,
"export-targets": {"add": [
{
"client-auth": {
"basic": {
"username": "herman",
"password": "Chkp2345"
}
},
"enabled": true,
"server-auth": {
"ca-public-key": {
"type": "PEM-X509",
"value": "-----BEGIN CERTIFICATE----- MIIFmTCCA4GgAwIBj2q6Gv..."
}
},
"type": "prometheus-remote-write",
"url": "https://prometheus.srv:9090/api/v1/write"
}
]}
}
/opt/CPotelcol/REST.py --set_open_telemetry “$(cat payload.json)”