centos7下安装promethus及grafana

1、下载,如下地址下载prometheus和相应的exporter

https://github.com/prometheus/prometheus/releases

本次下载的是2.55.1

https://github.com/prometheus/prometheus/releases/download/v2.55.1/prometheus-2.55.1.linux-amd64.tar.gz

2、node_exporter

https://github.com/prometheus/node_exporter/releases

版本为1.8.2

https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz

3、解压并复制文件到/usr/bin

tar zxvf prometheus-2.55.1.linux-amd64.tar.gz

tar zxvf node_exporter-1.8.2.linux-amd64.tar.gz

prometheus.yaml 文件内容:其实是模板

bash 复制代码
# 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"]

4、设置服务

nano /usr/lib/systemd/system/prometheus.service

bash 复制代码
[Unit]
  Description=https://prometheus.io
  
  [Service]
  Restart=on-failure
  ExecStart=/usr/bin/prometheus --config.file=/app/prometheus/prometheus.yml --web.listen-address=:9090

  [Install]                      
  WantedBy=multi-user.target

systemctl status prometheus
systemctl start prometheus
systemctl enable prometheus

5、启动后

起来后使用 节点名或ip:9090访问

6、node_exporter启动

直接启动

bash 复制代码
./node_exporter &

启动后会监听9100端口

添加为服务方式启动

bash 复制代码
nano /usr/lib/systemd/system/node_exporter.service
bash 复制代码
[Unit]
Description=node_exporter
After=network.target 

[Service]
ExecStart=/usr/bin/node_exporter
Restart=on-failure

[Install]
WantedBy=multi-user.target

启动node_exporter

systemctl daemon-reload

systemctl start node_exporter

7、安装grafana

bash 复制代码
docker run -d -p 3000:3000 --name grafana swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/rancher/mirrored-grafana-grafana:9.1.5

8、下载grfana的promethus模板并导入

访问地址 节点ip:3000 默认admin/admin

promethus的grafana模板

https://grafana.com/grafana/dashboards/8919

相关推荐
忍冬行者1 天前
redis8.0三主三从集群基于prometheus+grafana监控
grafana·prometheus
我爱学习好爱好爱1 天前
Docker Compose 一键部署 Prometheus + Alertmanager + Grafana 完整监控方案
docker·grafana·prometheus
无心水1 天前
【神经风格迁移:性能】24、神经风格迁移全链路监控实战:基于Prometheus+Grafana的性能调优指南
数据库·人工智能·深度学习·机器学习·grafana·prometheus·神经风格迁移:性能
是Judy咋!1 天前
Loki + Promtail + Tempo + Grafana 实现日志与链路追踪一体化
grafana
BullSmall1 天前
Grafana 如何提供7*24小时的监控
产品运营·grafana
我爱学习好爱好爱2 天前
Prometheus监控栈 监控数据库mysql
docker·grafana·prometheus
我爱学习好爱好爱2 天前
Prometheus监控栈 监控Linux操作系统
linux·grafana·prometheus
yunson_Liu2 天前
grafana限制普通view角色用户查看默认的Dashboard
grafana·prometheus
我爱学习好爱好爱2 天前
Prometheus监控栈 监控redis和mongodb
redis·grafana·prometheus
为什么要内卷,摆烂不香吗4 天前
Grafana 12.2.0导入仪表盘
运维·grafana