当前位置:网站首页>prometheus、influxdb2.2安装及flume_export下载编译使用
prometheus、influxdb2.2安装及flume_export下载编译使用
2022-06-23 03:52:00 【韧小钊】
prometheus
一款监控告警软件,详见官方资料
创建用户
创建部署用户,赋予sudo权限
[[email protected] ~]# useradd prometheus
[[email protected] ~]# passwd prometheus
更改用户 prometheus 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[[email protected] ~]# echo 'prometheus ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
[[email protected] ~]# su - prometheus
[[email protected] ~]$ sudo -v
[[email protected] ~]$
下载解压部署
下载
prometheus下载地址
选择最新版amd64(网速差,可以先下载到本地,再上传到服务器)
wget https://github.com/prometheus/prometheus/releases/tag/v2.35.0/prometheus-2.35.0.linux-amd64.tar.gz --no-check-certificate

解压
解压修改配置文件,默认localhost替换为具体地址
[[email protected] ~]$ tar xf prometheus-2.35.0-rc0.linux-amd64.tar.gz
[[email protected] ~]$ ll
总用量 78748
drwxr-xr-x. 4 prometheus prometheus 132 4月 8 21:41 prometheus-2.35.0-rc0.linux-amd64
-rw-r--r--. 1 prometheus prometheus 80636489 5月 9 10:50 prometheus-2.35.0-rc0.linux-amd64.tar.gz
[[email protected] ~]$ mv prometheus-2.35.0-rc0.linux-amd64 prometheus
[[email protected] ~]$ cd prometheus
[[email protected] prometheus]$ ll
总用量 198240
drwxr-xr-x. 2 prometheus prometheus 38 4月 8 21:38 console_libraries
drwxr-xr-x. 2 prometheus prometheus 173 4月 8 21:38 consoles
-rw-r--r--. 1 prometheus prometheus 11357 4月 8 21:38 LICENSE
-rw-r--r--. 1 prometheus prometheus 3773 4月 8 21:38 NOTICE
-rwxr-xr-x. 1 prometheus prometheus 105568448 4月 8 21:29 prometheus
-rw-r--r--. 1 prometheus prometheus 934 4月 8 21:38 prometheus.yml
-rwxr-xr-x. 1 prometheus prometheus 97405202 4月 8 21:33 promtool
[[email protected] prometheus]$ sed -i 's/localhost/192.168.56.10/g' prometheus.yml
[[email protected] prometheus]$ pwd
/home/prometheus/prometheus
部署启动
nohup /home/prometheus/prometheus/prometheus --config.file=/home/prometheus/prometheus/prometheus.yml --web.enable-lifecycle > prometheus.log 2>&1 &
参数说明:
- nohup “xxxx” & :后端启动
- prometheus :执行命令文件
- –config.file :指定配置文件
- –web.enable-lifecycle:支持通过http请求重载配置(热加载)
prometheus.log 2>&1:>-覆盖写入日志、prometheus.log-日志名称、2>&1-写入全部日志,不管对错
查看日志,对应监听端口为9090
登录验证
数据存储
默认情况下prometheus会将采集的数据存放到本地磁盘data下面(二进制文件),为了方便查看和扩展,接下来使用influxdb来存储数据。
influxdb
创建用户
创建部署用户,赋予sudo权限
[[email protected] ~]# useradd influx
[[email protected] ~]# passwd influx
更改用户 influx 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[[email protected] ~]# echo 'influx ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
[[email protected] ~]# su - influx
[[email protected] ~]$ sudo -v
[[email protected] ~]$
下载解压部署
下载
官方资料,目前最新版本2.2
wget https://dl.influxdata.com/influxdb/releases/influxdb2-2.2.0-linux-amd64.tar.gz

解压部署
[[email protected] ~]$ tar xf influxdb2-2.2.0-linux-amd64.tar.gz
[[email protected] ~]$ mv influxdb2-2.2.0-linux-amd64 influxdb
[[email protected] ~]$ cd influxdb
[[email protected] influxdb]$ ll
总用量 169660
-rwxr-xr-x. 1 influx influx 173712472 4月 7 01:39 influxd
-rw-rw-r--. 1 influx influx 1067 4月 7 01:40 LICENSE
-rw-rw-r--. 1 influx influx 9834 4月 7 01:40 README.md
[[email protected] influxdb]$ nohup ./influxd &
查看日志,默认启动端口8086
登录验证
初始化用户信息,全都是必填项


查看数据库信息


prometheus指定数据库配置
prometheus.yml
添加如下配置
# set db
remote_write:
- url: "http://192.168.56.10:8086/api/v1/prom/write?db=prometheus&u=prometheus&p=prometheus"
remote_read:
- url: "http://192.168.56.10:8086/api/v1/prom/read?db=prometheus&u=prometheus&p=prometheus"
重新加载
直接刷新页面没反应,需执行如下命令
curl -X POST http://192.168.56.10:9090/-/reload
查看

flume_exporter
创建目录
直接在prometheus用户下面建立exporter目录
[[email protected] ~]$ ll
总用量 78748
drwxr-xr-x. 5 prometheus prometheus 166 5月 15 16:36 prometheus
-rw-r--r--. 1 prometheus prometheus 80636489 5月 9 10:50 prometheus-2.35.0-rc0.linux-amd64.tar.gz
[[email protected] ~]$ mkdir exporter
[[email protected] ~]$ cd exporter/
[[email protected] exporter]$ ll
总用量 0
[[email protected] exporter]$
[[email protected] exporter]$
下载
下载地址,下载下来的是源文件,还要进行编译(网上没找到编译好的压缩包)

编译
安装go环境
下载地址
解压配置环境变量
[[email protected] ~]$ tar xf go1.18.1.linux-amd64.tar.gz
[[email protected] ~]$ ll
总用量 217128
drwxrwxr-x. 3 prometheus prometheus 106 5月 15 17:45 exporter
drwxr-xr-x. 10 prometheus prometheus 257 4月 12 23:42 go
-rw-r--r--. 1 prometheus prometheus 141699677 5月 9 15:22 go1.18.1.linux-amd64.tar.gz
drwxr-xr-x. 5 prometheus prometheus 166 5月 15 16:36 prometheus
-rw-r--r--. 1 prometheus prometheus 80636489 5月 9 10:50 prometheus-2.35.0-rc0.linux-amd64.tar.gz
[[email protected] ~]$ vi .bash_profile
[[email protected] ~]$ . .bash_profile
[[email protected] ~]$ go version
go version go1.18.1 linux/amd64
[[email protected] ~]$
.bash_profile 文件配置如下
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin
编译flume_exporter项目
设置变量,初始化flume目录
[[email protected] exporter]$ ll
总用量 67908
-rw-r--r--. 1 prometheus prometheus 67938106 5月 9 16:45 apache-flume-1.9.0-bin.tar.gz
drwxrwxr-x. 6 prometheus prometheus 267 2月 20 2019 flume_exporter-0.0.2
-rw-r--r--. 1 prometheus prometheus 1594290 5月 15 17:05 flume_exporter-0.0.2.tar.gz
[[email protected] exporter]$ go env -w GO111MODULE=on
[[email protected] exporter]$ go mod init flume_exporter-0.0.2
go: creating new go.mod: module flume_exporter-0.0.2
go: to add module requirements and sums:
go mod tidy
[[email protected] exporter]$ go env -w GOPROXY=https://goproxy.cn
[[email protected] exporter]$
进入flume项目,执行安装
安装依赖包
下载logrus
[[email protected] flume_exporter-0.0.2]$ go get github.com/Sirupsen/logrus
go: github.com/Sirupsen/[email protected]: parsing go.mod:
module declares its path as: github.com/sirupsen/logrus
but was required as: github.com/Sirupsen/logrus
下载余下依赖
[[email protected] flume_exporter-0.0.2]$ go get github.com/prometheus/client_golang/prometheus &&go get github.com/prometheus/client_golang/prometheus/promhttp && go get github.com/prometheus/common/version && go get github.com/woozhijun/flume_exporter/exporter && go get gopkg.in/alecthomas/kingpin.v2

指定编译目录,执行安装
[[email protected] flume_exporter-0.0.2]$ export GOPATH=/home/prometheus/exporter/flume_exporter-0.0.2
[[email protected] flume_exporter-0.0.2]$ go install
go: downloading github.com/Sirupsen/logrus v1.0.6
go: downloading github.com/prometheus/client_golang v1.12.2
go: downloading github.com/prometheus/common v0.34.0
go: downloading github.com/woozhijun/flume_exporter v0.0.2
go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: downloading golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
go: downloading golang.org/x/sys v0.0.0-20220114195835-da31bd327af9
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.1.2
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/prometheus/procfs v0.7.3
go: downloading google.golang.org/protobuf v1.26.0
go: downloading github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
go: downloading github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
go: downloading github.com/bitly/go-simplejson v0.5.0
go: downloading gopkg.in/yaml.v2 v2.4.0
查看生成的文件,统一管理
启动
nohup /home/prometheus/exporter/flume_exporter/flume_exporter-0.0.2 --config-file=/home/prometheus/exporter/flume_exporter/config.yml --metric-file=/home/prometheus/exporter/flume_exporter/metrics.yml >flumexport.log 2>&1 &
config.yml 配置flume机器IP信息,为了查看效果,只能再搭建一个flume单机版了
简单部署flume
下载地址
下载解压
配置java变量
[[email protected] flume]$ cd conf/
[[email protected] conf]$ ls
flume-conf.properties.template flume-env.ps1.template flume-env.sh.template log4j.properties
[[email protected] conf]$ cp flume-env.sh.template flume-env.sh
[[email protected] conf]$ cp flume-conf.properties.template flume-conf.properties
[[email protected] conf]$ vi flume-env.sh

定义相关参数
[[email protected] conf]$ vi flume-conf.properties
[[email protected] conf]$ cat flume-conf.properties
#Agent: 名称定义为 a1
#Source:可以理解为输入端,定义名称为 r1
#channel:传输频道,定义为 c1,设置为内存模式
#sinks:可以理解为输出端,定义为 s1
#命名此代理上的组件别名
a1.sources = r1
a1.channels = c1
a1.sinks = s1
#描述配置源
a1.sources.r1.type = netcat
a1.sources.r1.bind = 192.168.56.10
a1.sources.r1.port = 36001
#描述接收器
#设置 Sink 为 logger 模式
a1.sinks.s1.type = logger
#设置 channel 信息
a1.channels.c1.type = memory
#内存模式
a1.channels.c1.capacity = 1000
#通道中最大的缓冲事件,要大于或等于batchSize的数
a1.channels.c1.transactionCapacity = 100
#将源和接收器绑定到通道
a1.sources.r1.channels = c1
a1.sinks.s1.channel = c1
[[email protected] conf]$
启动flume
nohup /home/prometheus/flume/bin/flume-ng agent -n a1 -c conf -f /home/prometheus/flume/conf/flume-conf.properties -Dflume.monitoring.type=http -Dflume.monitoring.port=36001 -Dflume.root.logger=INFO,console &

promethues配置flume_exporter
prometheus.yml 添加配置信息
# set flume export
- job_name: flume
file_sd_configs:
- files:
- '/home/prometheus/exporter/flume_exporter/flume-nodes.json'
metric_relabel_configs:
- source_labels: [192.168.56.10]
regex: '192.168.56.10:36001'
replacement: flume-92.168.56.10-36001
target_label: logs
action: replace

创建json配置文件
[[email protected] prometheus]$ cd /home/prometheus/exporter/flume_exporter
[[email protected] flume_exporter]$ vi flume-nodes.json
[[email protected] flume_exporter]$ cat flume-nodes.json
[{
"targets": ["192.168.56.10:9360"],
"labels": {
"alias": "flume1",
"job": "flume"
}
}]
[[email protected] flume_exporter]$
加载验证
[[email protected] prometheus]$ curl -X POST http://192.168.56.10:9090/-/reload
[[email protected] prometheus]$
监控目标


influx查看flume指标数据
数据并未写入influxdb,看页面,还需要创建telegraf,而且上面配置的api应该也不对,里面有v1,实际上安装的是v2


安装telegrafs
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.22.3_linux_amd64.tar.gz
登录influxdb,拷贝前面定义的telegrafs的内容,添加到telegraf.conf配置文件,同时配置环境变量
export INFLUX_TOKEN=-jExfGZAinmMYdY98xQLuKK3xtuJdjvFasLBq_X8wb_gtnkgdHozcb0ph-gW-8C8xFtx3JFIM7irEwKe2kjkxw==


telegraf.conf 内容(增加了inputs.prometheus和inputs.http_listener_v2)
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
hostname = ""
omit_hostname = false
[[outputs.influxdb_v2]]
urls = ["http://192.168.56.10:8086"]
token = "$INFLUX_TOKEN"
organization = "prometheus"
bucket = "prometheus"
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
[[inputs.mem]]
[[inputs.net]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
[[inputs.prometheus]]
urls = ["http://192.168.56.10:9090/metrics","http://192.168.56.10:9360/metrics"]
[[inputs.http_listener_v2]]
service_address = ":8087"
paths = ["/receive"]
data_format = "influx"
[[email protected] telegraf]$
启动telegraf
nohup /home/influx/telegraf-1.22.3/usr/bin/telegraf --config /home/influx/telegraf-1.22.3/etc/telegraf/telegraf.conf &
prometheus修改db配置
修改为remote_write
remote_write:
- url: "http://192.168.56.10:8087/receive"

重新加载
[[email protected] prometheus]$ curl -X POST http://192.168.56.10:9090/-/reload
再次查看flume指标数据

注意:[[inputs.prometheus]]对应下面targets,配置几个采集几个!!!
[[inputs.prometheus]]
urls = ["http://192.168.56.10:9090/metrics","http://192.168.56.10:9360/metrics"]

其它
查看系统及处理器型号
[[email protected] ~]$ uname -a
Linux host1 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[[email protected] ~]$
[[email protected] ~]$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core
[[email protected] ~]$

lsb_release: 未找到命令
[pro[email protected] ~]$ lsb_release -a
-bash: lsb_release: 未找到命令
[[email protected] ~]$ yum provides lsb_release
已加载插件:fastestmirror
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
mysql-connectors-community | 2.6 kB 00:00:00
mysql-tools-community | 2.6 kB 00:00:00
mysql80-community | 2.6 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/4): mysql-tools-community/x86_64/primary_db | 86 kB 00:00:01
(2/4): mysql-connectors-community/x86_64/primary_db | 87 kB 00:00:01
(3/4): updates/7/x86_64/primary_db | 15 MB 00:00:01
(4/4): mysql80-community/x86_64/primary_db | 211 kB 00:00:02
Determining fastest mirrors
* base: mirrors.bfsu.edu.cn
* extras: mirrors.bfsu.edu.cn
* updates: mirrors.bfsu.edu.cn
base/7/x86_64/filelists_db | 7.2 MB 00:00:01
extras/7/x86_64/filelists_db | 277 kB 00:00:00
mysql-connectors-community/x86_64/filelists_db | 35 kB 00:00:00
mysql-tools-community/x86_64/filelists_db | 325 kB 00:00:01
mysql80-community/x86_64/filelists_db | 1.9 MB 00:00:01
updates/7/x86_64/filelists_db | 8.4 MB 00:00:01
redhat-lsb-core-4.1-27.el7.centos.1.i686 : LSB Core module support
源 :base
匹配来源:
文件名 :/usr/bin/lsb_release
redhat-lsb-core-4.1-27.el7.centos.1.x86_64 : LSB Core module support
源 :base
匹配来源:
文件名 :/usr/bin/lsb_release
[[email protected] ~]$ sudo yum install -y redhat-lsb
解压报错
包未下载完整,网速太差,可以浏览器下载之后,丢到服务器

influxdb2.0 写入数据库必须要telegrafs嘛
看2.0API官网说明不用好像也行,问题是不知道prometheus该怎么配。Java开发、curl模拟都ok
配置alertmanager
边栏推荐
- Current relay hdl-a/1-110vdc-1
- CVE-2019-14287(sudo提权)
- AD9使用技巧拾遗
- PCB任意角度和距离放置元器件
- Thinkphp6 solving jump problems
- Const understanding one
- 2020:VL-BERT: Pre-training of generic visual-linguistic representation
- Altium designer 09 screen printing displays a green warning near the pad. How to prevent it from alarming?
- 如何更好地组织最小 WEB API 代码结构
- Welcome to the CSDN markdown editor
猜你喜欢

PaddlePaddle模型服务化部署,重新启动pipeline后出现报错,trt报错
![[paper reading] semi supervised learning with ladder networks](/img/c9/e2f4b221d762f41ba6b75926293673.png)
[paper reading] semi supervised learning with ladder networks

在Pycharm中对字典的键值作更新时提示“This dictionary creation could be rewritten as a dictionary literal ”的解决方法

如何解决独立站多渠道客户沟通难题?这款跨境电商插件一定要知道!

Non return to zero code NRZ

Current relay hdl-a/1-110vdc-1

Halcon knowledge: binocular_ Discrimination knowledge

Common concepts and terms in offline warehouse modeling

McKinsey: in 2021, the investment in quantum computing market grew strongly and the talent gap expanded

智能语音时代到来,谁在定义新时代AI?
随机推荐
Project summary 1 (header file, switch, &, bit variables)
altium designer 09丝印靠近焊盘显示绿色警告,如何阻止其报警?
静态双位置继电器GLS-3004K/DC220V
开发一年不到,来面试居然敢开口要20K,面完连8K都不想给~
Less than a year after development, I dared to ask for 20k in the interview, but I didn't even want to give 8K after the interview~
Const understanding II
Usage of apipost interface test ------ get
ADR electronic transmission EDI solution of national adverse drug reaction monitoring center
Static two position relay gls-3004k/dc220v
Examples of corpus data processing cases (part of speech encoding, part of speech restoration)
Three operation directions of integral mall
ICer技能03Design Compile
openwrt目录结构
Shadertoy basic teaching 02. Drawing smiling faces
Abnova PSMA bead solution
Current relay jdl-1002a
开关磁阻电机悬浮驱动IR2128小结
dolphinscheduler 2.0.5 任务测试(spark task)报错:Container exited with a non-zero exit code 1
2 万字 + 20张图|细说 Redis 九种数据类型和应用场景
ICER skill 02makefile script self running VCs simulation
