docker-apps/prometheus/prometheus_jm.txt
2025-04-03 22:57:52 +02:00

78 lines
2.7 KiB
Plaintext

# https://mxulises.medium.com/simple-prometheus-setup-on-docker-compose-f702d5f98579
Create user and group
---------------------
Credentials -> Local Users -> Add
Full Name: prometheus
Username: prometh
Disable Password: <selected>
Email:
UID: 3021
Create New Primary Group: <selected>
Create Home Directory: <unchecked>
Samba Authentication: <unchecked>
Save
Check Credentials -> Local Groups for GID
Name: prometh
GID: 3020
prometh UID: 3021
prometh GID: 3020
Create datasets
---------------
/mnt/SSD1/docker/data/prometheus ; set Owner:Group to prometheus:prometheus
/mnt/SSD1/docker/data/prometheus/config ; set Owner:Group to prometheus:prometheus
/mnt/SSD1/docker/data/prometheus/appdata ; set Owner:Group to prometheus:prometheus
/mnt/SSD1/docker/data/prometheus/alertmgr ; set Owner:Group to prometheus:prometheus
Create folder
-------------
mkdir /mnt/SSD1/docker/stacks/prometheus
Create secrets
--------------
# In docker shell:
cd /opt/stacks/prometheus/secrets
# generate password hash and convert $ in hash to $$; password must be surrounded by single quotes
echo $(htpasswd -nB admin)
# Remove the single quotes from the generated hash and copy the result to local stacks\.env file
# Repeat the above for the prometheus metrics password
Creating user password hash strings for user authorisation using traefik basic-auth
-----------------------------------------------------------------------------------
# If not installed, install htpasswd:
jlmkr shell docker
apt update & apt install apache2-utils
# The user credentials can be applied as a label entry in the compose.yml file or as a line entry in a text file
# When used as a label entry, all '$' needs to be escaped with a second '$'; sed can be used for this purpose:
# To create user list textfile line item
echo $(htpasswd -nB admin)
# To create string to be used in compose file label
echo $(htpasswd -nB admin) | sed -e s/\\$/\\$\\$/g
# See traefik_jm.txt for more detailed instructions
Copy folder to docker stacks
----------------------------
# In Windows cmd shell in prometheus folder, enter:
./cp2nas 10.0.0.20
# OR
pscp -P 22 -r stacks/*.* root@10.0.0.20:/mnt/SSD1/docker/stacks/prometheus/
# The above should copy compose.yaml and .env to /mnt/SSD1/docker/stacks/prometheus
Prometheus exporters
--------------------
https://github.com/bairhys/prometheus-frigate-exporter
Troubleshooting
---------------
Config file
~~~~~~~~~~~
# Check for errors in config file with the following command:
docker exec prometheus-prometheus-1 promtool check config /etc/prometheus/prometheus.yml
# note that "prometheus-prometheus-1" is the prometheus container name
Endpoints
~~~~~~~~~
# Open "https://prometheus.sthome.org/targets" in browser to check whether endpoints are up