prometheus+grafana安装和基本配置

官网地址:https://prometheus.io/download/

安装prometheus:

wget https://github.com/prometheus/prometheus/releases/download/v2.26.0/prometheus-2.26.0.linux-386.tar.gz #找一个最新版的和自己系统吻合的版本
tar -xvf prometheus-2.26.0.linux-386.tar.gz -C /usr/local/
cd /usr/local/
mv prometheus-2.26.0.linux-386 prometheus

启停脚本

[Unit]
Description=Prometheus
[Service]
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=data/prometheus --web.enable-lifecycle --storage.tsdb.retention.time=2y
Restart=on-failure

[Install]
WantedBy=multi-user.target

systemctl start prometheus

systemctl enable prometheus

global:
  scrape_interval:     30s # 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:       15s
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']

利用prometheus监控其他主机需要在被监控的主机上面安装exporter,先安装一个node_exporter进行监控

wget https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz
tar -xvf node_exporter-1.1.2.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/
mv node_exporter-1.1.2.linux-amd64 node_exporter

启停脚本

[Unit]
Description=node_export

[Service]
ExecStart=/usr/local/node_exporter/node_exporter --web.listen-address=:9100 --collector.systemd --collector.systemd.unit-whitelist="(ssh|docker|rsyslog|redis-server).service" --collector.textfile.directory=/usr/local/node_exporter/node_exporter/textfile.collected
Restart=on-failure

[Install]
WantedBy=multi-user.target

systemctl start node_exporter

systemctl enable node_exporter

  - job_name: 'CICD'
    static_configs:
    - targets: ['192.168.1.160:8100']
      labels:
        app: gitlab
        nodename: gitlab
        role: git

    - targets: ['192.168.1.161:9100']
      labels:
        app: jenkins
        nodename: jenkins
        role: git

    - targets: ['192.168.1.169:9100']
      labels:
        app: nexus
        nodename: nexus
        role: git

    - targets: ['192.168.1.166:9100']
      labels:
        app: sonarqube
        nodename: sonarqube
        role: git

    - targets: ['192.168.1.183:9100']
      labels:
        app: verdaccio
        nodename: verdaccio
        role: git

  - job_name: 'service'
    static_configs:
    - targets: ['192.168.1.62:9100']
      labels:
        app: kvm1
        nodename: kvm1
        role: service

    - targets: ['192.168.1.61:9100']
      labels:
        app: kvm2
        nodename: kvm2
        role: service

systemctl restart prometheus

安装grafana:

下载地址:https://grafana.com/grafana/download

直接下载rpm包进行yum安装

ip:3000访问grafana就可以了,配置prometheus的数据源请自行百度,这里就不做详细介绍了,很简单!!!

https://grafana.com/grafana/dashboards这里推荐一个grafana模板下载地址

建议使用8919这个模板

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值