k8s记录-prometheus部署

prometheus 安装

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

wget https://github.com/prometheus/prometheus/releases/download/v2.10.0/prometheus-2.10.0.linux-amd64.tar.gz
tar xvf prometheus-2.10.0.linux-amd64.tar.gz
mv prometheus-2.10.0.linux-amd64 /usr/local/prometheus

cd /usr/local/prometheus

vim prometheus.yml

1
2
3
4
5
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    # 监控本地及端口
    - targets: ['xiangsikai:9090']

注:Prometheus从目标机上通过http方式拉取采样点数据, 它也可以拉取自身服务数据并监控自身的健康状况。

启动服务

./prometheus --config.file=prometheus.yml

 

1
2
3
4
5
6
7
8
9
10
# 指定配置文件
--config.file="prometheus.yml"
# 指定监听地址端口
--web.listen-address="0.0.0.0:9090"
# 最大连接数
--web.max-connections=512
# tsdb数据存储的目录,默认当前data/
--storage.tsdb.path="data/"
# premetheus 存储数据的时间,默认保存15天
--storage.tsdb.retention=15d

 

查看暴露指标:http://localhost.com:9090/metrics

创建用户

groupadd prometheus
useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
chown prometheus.prometheus -R /usr/local/prometheus
创建Systemd服务

cat > /etc/systemd/system/prometheus.service <<EOF
[Unit]
Description=prometheus
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/data
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
其他参数

# 控制对admin HTTP API的访问,其中包括删除时间序列等功能
--web.enable-admin-api

# 支持热更新,直接执行localhost:9090/-/reload立即生效
--web.enable-lifecycle

# 热更新
curl -X POST http://prometheous_ip:9090/-/reload
启动Prometheus

systemctl start prometheus

验证Prometheus是否启动成功
systemctl status prometheus

开机启动
systemctl enable prometheus
访问自带Web

自带Web默认http://ip:9090

posted @   信方  阅读(667)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示