grafana与prometheus安装部署

1、prometheus安装
# 新建用户,下载GO语言的2进制执行软件包
useradd prometheus; passwd prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.15.2/prometheus-2.15.2.linux-amd64.tar.gz
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
tar -xvzf prometheus*.tar.gz
tar -xvzf node_exporter*.tar.gz

# 编辑监控本机自启动配置文件
vi /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/home/prometheus/node_exporter/node_exporter

[Install]
WantedBy=multi-user.target

# 设置成为自启动
systemctl enable node_exporter

————————-
# 文件尾部添加node_exporter本机监控模块
vi home/prometheus/prometheus.yml
– job_name: ‘node_exporter’
scrape_interval: 15s
static_configs:
– targets: [‘localhost:9100’]

# 编辑时序DB自启动配置文件
vi /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Monitoring
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/home/prometheus/prometheus/prometheus \
–config.file /home/prometheus/prometheus/prometheus.yml \
–storage.tsdb.path /home/prometheus/prometheus/ \
–web.console.templates=/home/prometheus/prometheus/consoles \
–web.console.libraries=/home/prometheus/prometheus/console_libraries
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

# 设置成为自启动
systemctl enable prometheus

2、安装Grafana
# 编辑源
vi /etc/yum.repos.d/grafana.repo
[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

# 在线安装
yum install grafana

# 设置成为自启动
systemctl enable grafana-server.service

# 添加数据源
点击Grafana logo打开侧边栏
点击 “Data Sources”
选择 “Add New”
选择 “Prometheus” 作为数据源
设置Prometheus服务的URL (例如本机: http://localhost:9090/)
点击 “Add” 测试连通性并保存数据源

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google photo

You are commenting using your Google account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s


%d 博主赞过: