首页 > 其他分享 >Prometheus + Grafana 安装配置

Prometheus + Grafana 安装配置

时间:2022-09-20 16:23:54浏览次数:93  
标签:opt amd64 -- prometheus Grafana Prometheus systemctl linux 安装

安装文件下载

文件下载地址:

prometheus-2.37.1.linux-amd64.tar.gz

pushgateway-1.4.3.linux-amd64.tar.gz

node_exporter-1.3.1.linux-amd64.tar.gz

alertmanager-0.24.0.linux-amd64.tar.gz

grafana-9.1.5.linux-amd64.tar.gz

将所有文件下载存放到 /opt/prom 目录并解压

prometheus 服务端部署

创建服务

vi /etc/systemd/system/prometheus.service

[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target

[Service]
Restart=on-failure
ExecStart=/opt/prom/prometheus-2.37.1.linux-amd64/prometheus --config.file=/opt/prom/prometheus-2.37.1.linux-amd64/prometheus.yml --web.listen-address=:9090 --web.enable-lifecycle

[Install]
WantedBy=multi-user.target

--web.enable-lifecycle 开启配置文件热加载,开启后修改 prometheus.yml 配置文件后不用重启 prometheus 服务,支持两种方式重新加载配置文件:

1、kill -HUP $(pidof prometheus)

2、curl -XPOST http://192.168.50.4:9090/-/reload

启动服务

systemctl daemon-reload
systemctl enable prometheus
systemctl start prometheus

执行 netstat 命令查看端口是否启动

netstat -nltup | grep 9090

浏览器访问:http://192.168.50.4:9090/

prometheus 推送网关部署

创建服务

vi /etc/systemd/system/pushgateway.service

[Unit]
Description=Prometheus Pushgateway
Documentation=https://prometheus.io/docs/instrumenting/pushing/
After=network-online.target

[Service]
Restart=on-failure
ExecStart=/opt/prom/pushgateway-1.4.3.linux-amd64/pushgateway --web.listen-address=:9091

[Install]
WantedBy=multi-user.target

启动服务

systemctl daemon-reload
systemctl enable pushgateway
systemctl start pushgateway

配置推送网关

编辑 prometheus.yml 文件,在 scrape_configs 配置下新增一个 job

  - job_name: "push-metrics"
    static_configs:
      - targets: ["192.168.50.4:9091"]

重新载入配置

kill -HUP $(pidof prometheus)

prometheus 节点导出器部署

创建服务

vi /etc/systemd/system/node_exporter.service

[Unit]
Description=Prometheus node_exporter
Documentation=https://prometheus.io/docs/instrumenting/exporters/
After=network.target

[Service]
Restart=on-failure
ExecStart=/opt/prom/node_exporter-1.3.1.linux-amd64/node_exporter --web.listen-address=:9100

[Install]
WantedBy=multi-user.target

启动服务

systemctl daemon-reload
systemctl enable node_exporter
systemctl start node_exporter

执行 netstat 命令查看端口是否启动

netstat -nltup | grep 9100

浏览器访问:http://192.168.50.4:9100/metrics

导出器配置

编辑 prometheus.yml 文件,在 scrape_configs 配置下新增一个 job

  - job_name: "192.168.50.4"
    static_configs:
      - targets: ["192.168.50.4:9100"]

重新载入配置

kill -HUP $(pidof prometheus)

prometheus 告警管理器部署

创建服务

vi /etc/systemd/system/alertmanager.service

[Unit]
Description=Prometheus Alertmanager
Documentation=https://prometheus.io/docs/alerting/latest/overview/
After=network-online.target

[Service]
Restart=on-failure
ExecStart=/opt/prom/alertmanager-0.24.0.linux-amd64/alertmanager --config.file=/opt/prom/alertmanager-0.24.0.linux-amd64/alertmanager.yml --web.listen-address=:9093

[Install]
WantedBy=multi-user.target

启动服务

systemctl daemon-reload
systemctl enable alertmanager
systemctl start alertmanager

执行 netstat 命令查看端口是否启动

netstat -nltup | grep 9093

浏览器访问:http://192.168.50.4:9093/

配置告警

将 prometheus.yml 文件的告警配置修改为如下内容:

alerting:
  alertmanagers:
    - static_configs:
        - targets:
          - 192.168.50.4:9093

重新载入配置

kill -HUP $(pidof prometheus)

Grafana 部署

创建服务

vi /etc/systemd/system/grafana.service

[Unit]
Description=Grafana Server
Documentation=https://grafana.com/docs/
After=network-online.target

[Service]
Restart=on-failure
ExecStart=/opt/prom/grafana-9.1.5/bin/grafana-server --homepath /opt/prom/grafana-9.1.5 --config /opt/prom/grafana-9.1.5/conf/defaults.ini

[Install]
WantedBy=multi-user.target

通过 defaults.ini 配置文件中的 http_port 修改服务端口号,注释时使用英文分号,即 ;

启动服务

systemctl daemon-reload
systemctl enable grafana
systemctl start grafana

执行 netstat 命令查看端口是否启动

netstat -nltup | grep 3000

浏览器访问:http://192.168.50.4:3000/

初始账号密码:admin/admin

参考链接

https://prometheus.io/docs/prometheus/2.37/getting_started/

https://blog.csdn.net/qq_36546699/article/details/108316533

https://www.cnblogs.com/yjmyzz/p/how-to-install-prometheus-and-grafana.html

标签:opt,amd64,--,prometheus,Grafana,Prometheus,systemctl,linux,安装
From: https://www.cnblogs.com/nihaorz/p/16711443.html

相关文章

  • k8s-安装教程
    kubelet版本过高,v1.24版本后kubernetes放弃docker了,所以我们安装1.24以下的。以下操作三台主机都要做。#关闭防火墙systemctlstopfirewalld&&systemctldisablefire......
  • 计算机安装不同版本sqlserver如何使用
    1.两个版本需要使用不同的实例名称2.设置不同的端口号3.客户端连接方式:ip地址,端口号4.如果需要远程连接,启用出入站的端口号新建入站规则:1出站规则和入站规......
  • Windows安装Jenkins详细教程(图文教程)
    一、安装前准备1、提前安装好jdk,可参考以下链接进行安装Windows安装JDK详细教程(图文教程)2、Jenkins官网下载安装包(因为本人jdk安装的是1.8,所以会和最新版jenkins不符合,......
  • containerd安装
    下载安装包wgethttps://github.com/containerd/containerd/releases/download/v1.6.8/cri-containerd-1.6.8-linux-amd64.tar.gzwgethttps://github.com/opencontainer......
  • paddleocr安装与图片识别快速开始
    本文首发我的个人博客:paddleocr安装教程快速开始1.安装Python环境wgethttps://mirrors.huaweicloud.com/python/3.8.5/Python-3.8.5.tgz下载后,解压,编译,安装,即可。......
  • docker离线安装
    //下载静态包//https://download.docker.com/linux/static/stable///解压tgz包到docker文件夹tar-xzvfdocker.tgz//将docker文件复制到/usr/bin下sudocpdocker/*/us......
  • Docker安装部署Mysql8(以作数据持久化)
    1.创建容器并进行持久化处理#拉取镜像dockerpullmysql:8.0.20#启动镜像,用于拷贝配置文件到宿主机dockerrun-p3306:3306--namemysql-eMYSQL_ROOT_PASSWORD=12......
  • 安装配置docker&maven环境
     原文视频:(https://blog.sechelper.com/20220919/code-review/docker-maven-install-guid/)Docker是什么Docker是一个开源的应用容器引擎。Docker可以让开发者打包他们......
  • ES介绍-安装-插件-ElasticSearch-head-ElasticSearch-安装Kibana
    ES介绍 #大规模数据如何存储和检索---》elasticsearch#Elasticsearch是一个基于Lucene的分布式搜索和分析引擎,分布式全文检索引擎,java开发,遵循apache开源协议使......
  • JDK安装与卸载
    #卸载JDK1.删除JAVA的安装目录2.删除JAVA_HOME3.删除path下关于java的目录4.java-version #安装JDK1.百度搜索JDK8,找到下载地址2.同意协议3.下载电脑的......