当前位置: 首页 > article >正文

Ubantu安装Prometheus、Grafana、node_exporter、elasticsearch_exporter监控运行状态

Prometheus安装

更新系统包索引:apt-get update && apt-get upgrade -y

官网下载Prometheus: Prometheus
命令下载:wget https://github.com/prometheus/prometheus/releases/download/vX.X.X/prometheus-X.X.X.linux-amd64.tar.gz

上传并解压
修改prometheus.yml

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"]

  - job_name: 'elasticsearch' # 监控ElasticSearch的job名称,自定义即可
    scrape_interval: 60s
    scrape_timeout:  30s
    metrics_path: "/metrics" # 监控后缀
    static_configs:
    - targets: ["192.168.xxx.xxx:9114"] # 刚刚配置的elasticsearch_exporter监控地址

  - job_name: 'Linux'
    scrape_interval: 60s
    scrape_timeout:  30s
    metrics_path: "/metrics"
    static_configs:
    - targets: ["192.168.xxx.xxx:9100"]

后台启动:nohup ./prometheus --config.file=prometheus.yml & (注意这里–有两个)
prometheus 默认端口为9090,如果想切换一个端口,可以在启动的时候直接指定,如下:

./prometheus --config.file=prometheus.yml --web.listen-address=:9091 &

验证:http:ip:9090 点击targets

配置快速启动:

vim /etc/systemd/system/prometheus .service
[Unit]
Requires=network.target
After=network.target

[Service]
Type=simple
WorkingDirectory=/usr/local/prometheus 
ExecStart=/usr/local/prometheus/prometheus --log.level=info
TimeoutSec=30
Restart=always

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start prometheus.service
systemctl status prometheus.service

Grafana安装

直接官网安装:Grafana安装

验证:http:ip:3000 默认账号密码:admin 不改就点击skip

在Grafana Web界面中,点击“Connections” > “Data Sources”。添加一个新的数据源并选择Prometheus。提供你的Prometheus服务器的URL(例如,http://your_domain:9090)并保存配置。

创建仪表盘dashboards

Grafana 的模板商店:Grafana模板商店

配置快速启动:

sudo vim /lib/systemd/system/grafana-server.service
[Unit]
Description=Grafana
After=network-online.target

[Service]
ExecStart=/usr/local/grafana/bin/grafana-server -homepath /usr/local/grafana

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl enable grafana-server 

node_exporter安装

下载地址:node_exporter

上传并解压然后启动: nohup ./node_exporter &

需要重启Prometheus

配置快速启动:

vim /etc/systemd/system/node_exporter.service
[Unit]
Description=prometheus node_exporter Daemon
Documentation=https://github.com/prometheus/node_exporter
Requires=network.target
After=network.target

[Service]
Type=simple
WorkingDirectory=/usr/local/node_exporter
ExecStart=/usr/local/node_exporter/node_exporter --log.level=info
TimeoutSec=30
Restart=always

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start node_exporter.service
systemctl status node_exporter.service

elasticsearch_exporter安装

下载地址:elasticsearch_exporter

上传并解压

配置文件是deployment.yml 一般不用改啥

然后启动: nohup ./elasticsearch_exporter &

需要重启Prometheus


http://www.kler.cn/a/550670.html

相关文章:

  • linux中(base) [root@ZS ~]# 是什么情况,怎么退出
  • 【C++指南】类和对象(十):const成员函数
  • ctf网络安全大赛python
  • Mysql-死锁图文详解
  • 前端JS接口加密攻防实操
  • 进阶——第十六届蓝桥杯嵌入式熟练度练习(开发板捕获频率和占空比)
  • OpenCV中的边缘检测
  • 基于YOLO11深度学习的胃肠道息肉智能检测分割与诊断系统【python源码+Pyqt5界面+数据集+训练代码】深度学习实战、目标分割、人工智能
  • uniapp 安卓10+ 选择并上传文件
  • 数据驱动业务增长,E-MapReduce 真实案例解析
  • 数据分析简介及其常用指标与方法
  • DeepSeek 引领AI 大模型时代,服务器产业如何破局进化?
  • 案例|平顶山某大型能源化工集团配电房轨道巡检机器人解决方案
  • Spring Cloud Gateway可以做什么?
  • Python中如何进行数据库连接?
  • win10 系统 自定义Ollama安装路径 及模型下载位置
  • CViewState::InitializeColumns函数分析之_hdsaColumnStates的结构
  • Xorp架构下的XRL,Unix_TCP_ Socket与异步IO回调函数技术
  • 【分布式理论11】分布式协同之分布式事务(一个应用操作多个资源):从刚性事务到柔性事务的演进
  • python学opencv|读取图像(六十七)使用cv2.convexHull()函数实现图像轮廓凸包标注