普罗米修斯 Prometheus grafana
#下载、安装
cd /opt
wget https://github.com/prometheus/prometheus/releases/download/v2.37.6/prometheus-2.37.6.linux-amd64.tar.gz
tar xvf prometheus-2.37.6.linux-amd64.tar.gz
ln -s /opt/prometheus-2.37.6.linux-amd64/prometheus /usr/bin
#启动
prometheus --config.file=/opt/prometheus-2.37.6.linux-amd64/prometheus.yml &
#docker版
docker pull prom/prometheus
mkdir /usr/local/prometheus
mkdir /usr/local/prometheus/data
cat > /usr/local/prometheus/data/prometheus.yml <<EOF # my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
EOF
#创建prometheus容器,指定端口、名称、挂载目录、设置时区
docker run -d -p 9090:9090 --name prom --restart=always \
-v /usr/local/prometheus/data/prometheus.yml:/data/prometheus.yml \
-v /etc/localtime:/etc/localtime:ro \
prom/prometheus \
--config.file=/data/prometheus.yml
grafana@docker
mkdir -p /opt/grafanaConfig/
# 启动grafana
docker run -itd --name grafana grafana/grafana
# 复制容器内部的配置文件到宿主机,不用事先创建$PWD/prometheus目录
docker cp -a grafana:/var/lib/grafana /opt/grafana-storage
docker cp -a grafana:/etc/grafana/grafana.ini /opt/grafanaConfig/grafana.ini
# 删除容器
docker rm -f grafana
# 添加目录权限(不添加权限不够,容器无法启动)
chmod -R 777 /opt/grafana-storage
chmod -R 777 /opt/grafanaConfig
# 启动容器 设置端口
docker run -itd --name=grafana --restart=always --privileged=true -p 3000:3000 \
-v /opt/grafana-storage:/var/lib/grafana \
-v /opt/grafanaConfig/grafana.ini:/etc/grafana/grafana.ini:ro \
grafana/grafana
参考:https://www.jianshu.com/p/acbc04040519
https://blog.csdn.net/vlking/article/details/126683785
https://blog.csdn.net/D_Janrry/article/details/128102635