1、下载安装包并解压到相关目录

#创建prometheus用户
useradd prometheus
cd /home/prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.26.0/prometheus-2.26.0.linux-amd64.tar.gztar -xf prometheus-2.26.0.linux-amd64.tar.gz -C /home/prometheus/
cd /home/prometheus
mv prometheus-2.26.0.linux-amd64 prometheus

2、使用systemd接管prometheus
–web.enable-lifecycle这个参数要配置上,可以使用curl直接重载配置文件而不用重启服务

重载配置两种方法
# 第一种,向prometheus进行发信号
kill -HUP  pid# 第二种,向prometheus发送HTTP请求
# /-/reload只接收POST请求,并且需要在启动prometheus进程时,指定 --web.enable-lifecycle
curl -XPOST http://localhost:9090/-/reload
cat <<EOF > /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target[Service]
User=prometheus
Type=simple
ExecStart=/home/prometheus/prometheus/prometheus \--config.file=/home/prometheus/prometheus/prometheus.yml \--web.enable-lifecycle
#    --storage.tsdb.path /var/lib/prometheus/ \
#    --web.console.templates=/etc/prometheus/consoles \
#    --web.console.libraries=/etc/prometheus/console_libraries \
#    --web.listen-address=:9090
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF

prometheus.yml

cat <<EOF > /home/prometheus/prometheus/prometheus.yml
# 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']- job_name: "gitlab-runner"static_configs:- targets: ['172.16.14.127:9100']
EOF
systemctl start prometheus
netstat -tunlp|grep 9090

访问
http://ip:9090/

按照上面的步骤会遇到的问题
使用prometheus用户的service时,启动时会报错
jenkins prometheus: level=error ts=2021-11-01T12:15:36.698Z caller=query_logger.go:87 component=activeQueryTracker msg=“Error opening query log file” file=data/queries.active err=“open data/queries.active: permission denied”


原因是prometheus启动时,会创建/data目录,但是启动时用的是prometheus用户,权限不够,方法,先用root用户创建/data目录,再使用chown prometheus:prometheus /data即可

prometheus安装相关推荐

  1. 监控工具—Prometheus—安装部署

    原文作者:虎纠卫 原文地址:监控神器-普罗米修斯Prometheus的安装 目录 步骤1:安装go 语言环境 步骤2:在监控服务器上安装prometheus 步骤3:在系统层用作系统监控 步骤4:安装 ...

  2. Prometheus 安装、部署、出图(使用grafana)

    一.Prometheus安装与部署 注意:gitlab自带Prometheus,并会启动Prometheus服务,所以会冲突,不要将gitlab与Prometheus部署在一起,否则会出现端口冲突问题 ...

  3. 普罗米修斯Prometheus安装和使用

    文章目录 一.prometheus安装 二.AlertManager的使用(邮件告警) 1.原文链接 2.自己操作-prometheus+alertmanager实现CPU的监控报警 3.promet ...

  4. 监控神器普罗米修斯Prometheus安装配置

    一.基础环境 环境/组件 版本 下载地址 操作系统 CentOS 7.3 http://archive.kernel.org/centos-vault/7.3.1611/isos/x86_64/Cen ...

  5. mac m1 prometheus安装与启动

    安装 使用homebrew: brew install prometheus 启动 安装时有提示: 两种启动方式: When run from brew services, prometheus is ...

  6. prometheus安装及使用

    一.简介 Prometheus是最初在SoundCloud上构建的开源系统监视和警报工具包 .自2012年成立以来,许多公司和组织都采用了Prometheus,该项目拥有非常活跃的开发人员和用户社区. ...

  7. Prometheus — 安装部署(主机安装)

    目录 文章目录 目录 环境信息 部署 Prometheus Server 部署 Node Exporter 部署 AlertManager 部署 Grafana 添加 Node Exporter 界面 ...

  8. Mac安装prometheus node_exporter

    Mac 安装prometheus brew install prometheus 启动prometheus prometheus --config.file=/usr/local/etc/promet ...

  9. java ini文件_java应用监控之prometheus、node export、grafana安装和配置

    为了与时俱进,介绍基于docker的安装部署,如果想用非docker化部署,可以参考官网教程 对于docker的安装,在cat安装部署已经介绍过了,这里就不再重复了,如果还有不清楚的可以点击这里 do ...

最新文章

  1. eNSP中浮动路由的配置
  2. 前端构建工具gulpjs的使用介绍及技巧 (转)
  3. 易百教程人工智能python修正-人工智能NLTK性别发现器
  4. 开源 免费 java CMS - FreeCMS1.2-标签 userList
  5. command not found: django-admin.py
  6. wildfly mysql_MySQL作为Kubernetes服务,可从WildFly Pod访问
  7. powerdesigner生成表sql语句时,统一添加默认字段(生成时间、生成人等)
  8. 机器人剥人皮眼看自己是机器人_高中生自己编程机器人,获世界大赛“全能奖”...
  9. 53 岁张亚勤官宣:正式加入清华!
  10. enum类型的标签内容根据语言的取法
  11. 重新组织和重新生成索引sp_RefreshIndex
  12. Google 工作十年后,我选择离开!
  13. MATLAB----小波去噪
  14. PNAS | 人类线粒体的双亲遗传模式
  15. js 如何获取浏览器的高度和宽度
  16. 基于python的论文摘要怎么写_Django显示文章摘要需要如何写
  17. Blender_7_倒角
  18. RxJava相关 - 收藏集 - 掘金
  19. 怎样识别图片中的文字?手机电脑都可以的
  20. 什么是云存储?它的优势在哪里

热门文章

  1. 小米遥控车吉姆尼加装车灯~
  2. 独家 | 机器学习x环境科学:实时预测下一小时的降雨
  3. [HY000][1366] Incorrect string value: '\xE3\x81\x94\xE6\xB3\xA8...' for column 'content' at row 1
  4. 火狐开发者工具_性能审核:Firefox开发人员工具深入研究
  5. java绘制海报,使用BufferedImage,Graphics2D,drawString方法在图片上写文字,中文不显示;drawString写文字为空问题
  6. 一键查询物流,教你查找快递延误件并导出EXCEL表格
  7. Oracle LiveLabs实验:DB Security - Key Vault
  8. 解决c++错误:redefinition of class xxx
  9. java面试题题库大全800题
  10. windows10下使用gyp编译google_breakpad