一、基础环境

系统

IP

监控主机

CentOS 7

192.168.56.200

被监控主机

CentOS 7

192.168.56.201

二、Prometheus服务端安装

以下操作皆在监控主机(192.168.56.200)上执行。

2.0 关闭机器防火墙

# systemctl stop firewalld
# systemctl disable firewalld

2.1 安装 go 环境

由于Prometheus是由go语言开发的,所以在安装Prometheus之前需要先在监控主机上安装go环境。这里采用源码编译的方式安装。

由于国内网络环境的原因,如果能够科学的上网,可从此地址下载最新版本的安装包:https://golang.org/dl/ 。

未能科学的上网的,可从此链接下载:链接:https://pan.baidu.com/s/1gefGeXmoFmjGxSGxgCuQfw      提取码:cz6l

安装包下载以后,上传至监控主机的 /usr/local 目录下。

2.1.1 解压安装包

# tar -xvf go1.13.1.linux-amd64.tar.gz

2.1.2 配置环境变量

添加/usr/loacl/go/bin目录到PATH变量中。添加到/etc/profile 或$HOME/.profile都可以

# vim /etc/profile
// 在最后一行添加
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
// wq保存退出后source一下
# source /etc/profile

执行go version,如果显示版本号,则Go环境安装成功。

2.2 安装Prometheus

安装包下载地址:https://prometheus.io/download/#prometheus

2.2.1 安装

将下载后安装包,上传至  /usr/local 目录下

解压安装包:

#  tar -xvf prometheus-2.4..linux-amd64.tar.gz
# mv prometheus-2.4..linux-amd64/ prometheus

2.2.2 启动

Prometheus的配置文件位于 /usr/local/Prometheus/prometheus.yml  ,此处采用默认配置。

进入解压后的文件夹下,启动Prometheus。

#  cd prometheus
# ./prometheus --config.file=/usr/local/prometheus/prometheus.yml &

2.2.3 验证

浏览器打开http://192.168.56.200:9090(IP:9090端口)即可打开普罗米修斯自带的监控页面

2.2.4 以服务的方式启动

Ctrl+C 结束掉Prometheus进程。创建Prometheus服务,让Prometheus以服务的方式,开机自启。

添加系统服务

#  vim /etc/systemd/system/prometheus.service

将以下内容写入文件中

[Unit]
Description=Prometheus Monitoring System
Documentation=Prometheus Monitoring System [Service]
ExecStart=/usr/local/prometheus/prometheus \
--config.file=/usr/local/prometheus/prometheus.yml \
--web.listen-address=:9090
Restart=on-failure
[Install]
WantedBy=multi-user.target

启动服务,设置开机自启,并检查服务开启状态

#  systemctl daemon-reload
# systemctl enable prometheus
# systemctl start prometheus
# systemctl status prometheus

三、安装Grafana

Prometheus自带的监控页面显示的内容没有那么直观,我们安装grafana来使监控数据看起来更加直观

3.1、安装grafana

此处安装采用源码编译的方式安装。在监控主机(192.168.56.200)/usr/local 目录下 下载安装包,并安装

# wget https://dl.grafana.com/oss/release/grafana-6.4.3-1.x86_64.rpm
# yum localinstall grafana-6.4.-.x86_64.rpm

没有wget工具的,首先安装wget工具:

# yum -y install wget

3.2、启动grafana

设置grafana服务开机自启,并启动服务

#  systemctl daemon-reload
# systemctl enable grafana-server.service
# systemctl start grafana-server.service

3.3、访问grafana

浏览器访问http://192.168.56.200:3000(IP:3000端口),即可打开grafana页面,默认用户名密码都是admin,初次登录会要求修改默认的登录密码

3.4、添加Prometheus数据源

(1)点击主界面的“Add data source”

(2)选择Prometheus

(3)填写数据源设置项

URL处填写Prometheus服务所在的IP地址,此处我们将Prometheus服务与Grafana安装在同一台机器上,直接填写localhost即可

点击下方 【Save & Test】按钮,保存设置

(4)Dashboards页面选择“Prometheus 2.0 Stats”

点击Dashboards选项卡,选择Prometheus 2.0 Stats

(5)查看监控

点击Grafana图标,切换到Grafana主页面,然后点击Home,选择我们刚才添加的Prometheus 2.0 Stats,即可看到监控数据

至此Prometheus服务端及Grafana配置完成。

四、安装 node-exporter

以下操作皆在被监控主机(192.168.56.201)上操作。

4.0、关闭机器防火墙

# systemctl stop firewalld
# systemctl disable firewalld

4.1、安装node-exporter

首先下载node-exporter安装包,下载地址:https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-arm64.tar.gz

将下载的安装包上传至被监控主机(192.168.56.201)的 /usr/local 目录下

解压安装包

#  tar -zvxf node_exporter-0.18..linux-amd64.tar.gz
# mv node_exporter-0.18..linux-amd64/ node_exporter

4.2、启动node-exporter

进入解压后的node_exporter文件夹下,启动node_exporter

#  cd node_exporter
# ./node_exporter

4.3、验证

在浏览器访问 http://192.168.56.201:9100/metrics ,若出现数据则服务开启成功

4.4、设置node_exporter 以服务的方式启动并设置开机自启

Ctrl+C 结束掉node_exporter进程,创建node_exporter服务,让node_exporter以服务的方式,开机自启。

添加系统服务

#  vim /etc/systemd/system/node_exporter.service

将以下内容写入文件中

[Unit]
Description=node_exporter
After=network.target [Service]
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure [Install]
WantedBy=multi-user.target

启动服务,设置开机自启,并检查服务开启状态

#  systemctl daemon-reload
# systemctl enable node_exporter
# systemctl start node_exporter
# systemctl status node_exporter

至此node_exporter配置完成。

五、修改Prometheus 配置,监控Linux机器

以下操作皆在监控主机(192.168.56.200)上进行。

5.1、修改Prometheus配置

进入Prometheus的安装文件夹,打开Prometheus配置文件

#  cd /usr/local/prometheus
# vim prometheus.yml

在scrape_configs标签下,添加以下内容,配置监控

- job_name: 'Linux'
static_configs:
- targets: ['192.168.56.201:9100']
labels:
instance: Linux

以下是Prometheus.yml 文件全部内容

# my global config
global:
scrape_interval: 15s # Set the scrape interval to every seconds. Default is every minute.
evaluation_interval: 15s # Evaluate rules every seconds. The default is every minute.
# scrape_timeout is set to the global default (10s). # Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager: # 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: 'Linux'
static_configs:
- targets: ['192.168.56.201:9100']
labels:
instance: Linux

保存退出,重启Prometheus服务

#  systemctl restart prometheus

浏览器访问 http://192.168.56.200:9090/targets  查看监控信息

可以看到,Linux机器已经加入进来。

5.2、配置Grafana

添加dashboard

Grafana官方为我们提供了很多dashboard页面,可直接下载使用。浏览器访问 https://grafana.com/grafana/dashboards 下载所需要的dashboard页面

选择数据源为Prometheus,然后我们选择第一个dashboard

复制dashboard Id

然后打开我们的Grafana监控页面,打开dashboard的管理页面

点击【import】按钮

然后将我们刚才的复制的dashboard Id 复制进去

Grafana会自动识别dashboard Id 。

然后点击【change】按钮,生成一个随机的UID,然后点击下方输入框,选择我们之前创建的数据源Prometheus,最后点击【Import】按钮,即可完成导入。

导入成功后,会自动打开该Dashboard,即可看到我们刚才设置好的node监控

至此Prometheus+Grafana 安装配置,并监控Linux机器,配置完成。

Prometheus(一):Prometheus+Grafana 安装配置的更多相关文章

  1. grafana 安装配置

    Grafana安装配置 1.下载安装包 wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.1.3.l ...

  2. Jmeter+ InfluxDB+Grafana安装配置

    前置条件: 系统:windows jmeter:5.1 InfluxDB安装 下载InfluxDB-v1.7.9和Chronograf-v1.7.14(InfluxDB的可视化web端). 下载完成之 ...

  3. 监控服务器配置(二)-----Grafana安装配置

    1.下载grafana安装包(linux版)到 /opt/minitor/grafana . 下载地址:https://download.csdn.net/download/a15565772151/ ...

  4. Grafana安装配置介绍

    一.Grafana介绍 Grafana是一个可视化面板(Dashboard),有着非常漂亮的图表和布局展示,功能齐全的度量仪表盘和图形编辑器,支持Graphite.zabbix.InfluxDB.Pr ...

  5. influxDB+grafana安装配置及邮件告警发送配置

    1. InfluxDB安装 下载包并解压: $:wgethttps://dl.influxdata.com/influxdb/releases/influxdb-1.3.6_linux_amd64.t ...

  6. 01 . Prometheus简介及安装配置Grafana

    Promethus简介 Prometheus受启发于Google的Brogmon监控系统(相似的Kubernetes是从Google的Brog系统演变而来),从2012年开始由前Google工程师在S ...

  7. Prometheus 和 Grafana 安装部署

    Prometheus 是一套开源的系统监控报警框架.Prometheus 作为生态圈 Cloud Native Computing Foundation(简称:CNCF)中的重要一员,其活跃度仅次于 ...

  8. prometheus + grafana安装部署(centos6.8)

    官方网址:https://prometheus.io/ GitHub网址:https://github.com/prometheus/prometheus 软件下载地址:https://prometh ...

  9. centos7下安装配置prometheus

    prometheus官网:https://prometheus.io/download/ 搭建环境参考:https://blog.csdn.net/baidu_36943075/article/det ...

随机推荐

  1. day 24

    I am a slow walker, but I never walk back. 我走得很慢,但是我从来不会后退.

  2. beeline无密码连接hiveserver2

    1.说明 #hiveserver2增加了权限控制,需要在hadoop的配置文件中配置 core-site.xml 增加以下内容: <property> <name>hadoop ...

  3. [LeetCode] 738. Monotone Increasing Digits 单调递增数字

    Given a non-negative integer N, find the largest number that is less than or equal to N with monoton ...

  4. 日均5亿查询量的京东订单中心,为什么舍MySQL用ES?

    阅读本文大概需要 8 分钟. 来源:京东技术订阅号(ID:jingdongjishu) 作者:张sir   京东到家订单中心系统业务中,无论是外部商家的订单生产,或是内部上下游系统的依赖,订单查询的调 ...

  5. Word中怎么快速选中并组合多个文本框图形

    目的: 选中全部的文本框或者图形.图像,然后组合到一起 步骤: 点击开始(Home),点击右侧 选择--选择对象 (select -- select objects) -- 鼠标拖放框选图形 -- 右 ...

  6. spring boot开启gzip

    Web服务使用Spring Boot2X且运行在Tomcat或者Jetty中,支持gzip压缩可以 修改配置文件 application.properties server.compression.e ...

  7. Qt Quick 常用元素:ComboBox(下拉列表) 与 ProgressBar(进度条)

    一.ComboBox ComboBox,即下拉列表框,由一个列表框和一个标签控件(或编辑控件)组成.ComboBox 的下拉列表是使用 Menu 实现的,列表内的每个条目对应一个 Menultem. ...

  8. 《Interest Rate Risk Modeling》阅读笔记——第二章:债券价格、久期与凸性

    目录 第二章:债券价格.久期与凸性 思维导图 瞬时回报率-收益率的例子 第二章:债券价格.久期与凸性 思维导图 瞬时回报率-收益率的例子

  9. Spring Security简介与入门Demo

    1:Spring Security简介 Spring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架.它提供了一组可以在Spring应用上下文中配 ...

  10. idea中maven项目打jar包

    从Eclipse换成Idea的小伙伴们可能会找不到Eclipse中Maven项目打jar包的方法,因为eclipse只需要在工程上点击右键,右键菜单中就有Maven打包的相关选项. 然而Idea的右键 ...