【DockerCE】使用docker运行HertzBeat

news2024/10/7 2:28:59

HertzBeat是一款免Agent的监控平台,拥有强大自定义监控能力,可以对应用服务、数据库、中间件、操作系统、云原生等进行监控,配置告警阈值,以及告警通知(邮件微信钉钉飞书)。关于这个软件的介绍,我这里就不做过多的介绍了,感兴趣的可以去官网(https://hertzbeat.com/docs)去详细了解下。

今天我主要和大家分享下,如何使用docker来配置和运行HertzBeat。

HertzBeat将监控历史数据存储在时序数据库里面,官方文档给出了两款兼容的时序数据库软件,分别是IoTDB和TDengine,这里我使用的是TDengine。

首先,我们将所需的docker镜像下载到虚拟机(Docker已经提前安装,版本为20.10.21)。

# docker pull tancloud/hertzbeat
Using default tag: latest
latest: Pulling from tancloud/hertzbeat
751ef25978b2: Pull complete 
140e22108c7d: Pull complete 
993077aca88e: Pull complete 
d1a940e1e4e8: Pull complete 
4f368e97aba5: Pull complete 
4f4fb700ef54: Pull complete 
Digest: sha256:ed3d981673ee34e2d462ba0dda415f62aeec2380ccd0f45a8f1e481d05b2c735
Status: Downloaded newer image for tancloud/hertzbeat:latest
docker.io/tancloud/hertzbeat:latest

# docker pull  tdengine/tdengine:2.4.0.12
2.4.0.12: Pulling from tdengine/tdengine
2f94e549220a: Pull complete 
0c7809c5a70c: Pull complete 
354dceb62d94: Pull complete 
ded68138e6c3: Pull complete 
a049546d9313: Pull complete 
c67be503641a: Pull complete 
1f27396f6efc: Pull complete 
fe556ec02776: Pull complete 
Digest: sha256:0209b13bc6bffaac98fb05df58a86b06d998877d786efcdf59e68299b538d8bd
Status: Downloaded newer image for tdengine/tdengine:2.4.0.12
docker.io/tdengine/tdengine:2.4.0.12

然后,我们通过下面的命令来运行TDengine数据库

docker run -dti -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp \
    -v /data/taosdata:/var/lib/taos \
    -e TZ=Asia/Shanghai \
    --name tdengine tdengine/tdengine:2.4.0.12

数据库root用户的默认密码是taosdata,这里我将其修改为其他密码,通过docker exec进入容器内部执行下面的命令。

# docker exec -it tdengine /bin/bash
root@77a11dd2b845:~/TDengine-server-2.4.0.12# taos
taos> show databases;
taos> CREATE DATABASE hertzbeat KEEP 90 DAYS 10 BLOCKS 6 UPDATE 1; 
Query OK, 0 of 0 row(s) in database (0.001995s)
taos> alter user root pass 'YourPassword';
Query OK, 0 of 0 row(s) in database (0.002024s)
taos> quit
root@77a11dd2b845:~/TDengine-server-2.4.0.12# exit
exit

备注:

CREATE DATABASE hertzbeat KEEP 90 DAYS 10 BLOCKS 6 UPDATE 1

创建一个名为 hertzbeat 的库,这个库的数据将保留90天(超过90天将被自动删除),每 10 天一个数据文件,内存块数为 6,允许更新数据

下面,我们修改HertzBeat的两个关键的配置文件,分别是application.yml和sureness.yml

# application.yml
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
server:
  port: 1157
spring:
  application:
    name: ${HOSTNAME:@hertzbeat@}${PID}
  profiles:
    active: prod
  mvc:
    static-path-pattern: /**
  jackson:
    default-property-inclusion: ALWAYS
  web:
    resources:
      static-locations:
        - classpath:/dist/
        - classpath:../dist/
  # need to disable spring boot mongodb auto config, or default mongodb connection tried and failed..
  autoconfigure:
    exclude: org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration
  thymeleaf:
    prefix: classpath:/templates/
    check-template-location: true
    cache: true
    suffix: .html
    mode: HTML

management:
  endpoints:
    web:
      exposure:
        include: '*'
    enabled-by-default: off

sureness:
  auths:
    - digest
    - basic
    - jwt
  jwt:
    secret: 'CyaFv0bwq2Eik0jdrKUtsA6bx3sDJeFV643R
             LnfKefTjsIfJLBa2YkhEqEGtcHDTNe4CU6+9
             8tVt4bisXQ13rbN0oxhUZR73M6EByXIO+SV5
             dKhaX0csgOCTlCxq20yhmUea6H6JIpSE2Rwp'

---
spring:
  config:
    activate:
      on-profile: prod

  datasource:
    driver-class-name: org.h2.Driver
    username: sa
    password: 123456
    url: jdbc:h2:./data/hertzbeat;MODE=MYSQL
    hikari:
      max-lifetime: 120000

  jpa:
    hibernate:
      ddl-auto: update

  # Not Require, Please config if you need email notify
  # 非必填:不使用邮箱作为警告通知可以去掉spring.mail配置
  mail:
    # Attention: this is mail server address.
    # 请注意此为邮件服务器地址:qq邮箱为 smtp.qq.com qq企业邮箱为 smtp.exmail.qq.com
    host: smtp.exmail.qq.com
    username: example@tancloud.cn
    # Attention: this is not email account password, this requires an email authorization code
    # 请注意此非邮箱账户密码 此需填写邮箱授权码
    password: example
    port: 465
    default-encoding: UTF-8
    properties:
      mail:
        smtp:
          socketFactoryClass: javax.net.ssl.SSLSocketFactory
          ssl:
            enable: true
        debug: false

warehouse:
  store:
    td-engine:
      enabled: true
      driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
      url: jdbc:TAOS-RS://192.168.223.199:6041/hertzbeat
      username: root
      password: YourPassword
    iot-db:
      enabled: false
      host: 127.0.0.1
      rpc-port: 6667
      username: root
      password: root
      # org.apache.iotdb.session.util.Version: V_O_12 || V_0_13
      version: V_0_13
      # if iotdb version >= 0.13 use default queryTimeoutInMs = -1; else use default queryTimeoutInMs = 0
      query-timeout-in-ms: -1
      # 数据存储时间:默认'7776000000'(90天,单位为毫秒,-1代表永不过期)
      # data expire time, unit:ms, default '7776000000'(90 days, -1:never expire)
      expire-time: '7776000000'
    memory:
      enabled: true
      init-size: 1024
    redis:
      enabled: false
      host: 127.0.0.1
      port: 6379
      password: 123456

alerter:
  # custom console url
  console-url: https://console.tancloud.cn
  # base of alert eval interval time, unit:ms. The next time is 2 times the previous time.
  alert-eval-interval-base: 600000
  # max of alert eval interval time, unit:ms
  max-alert-eval-interval: 86400000
  # system alert(available alert, reachable alert...) trigger times
  system-alert-trigger-times: 1

备注:

上面的配置文件,仅修改了warehouse块的td-engine配置(紫色部分)

td-engine:

enabled: true

driver-class-name: com.taosdata.jdbc.rs.RestfulDriver

url: jdbc:TAOS-RS://192.168.223.199:6041/hertzbeat

username: root

password: YourPassword

# hertzbeat用户和用户权限配置-sureness.yml
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

## -- sureness.yml文本数据源 -- ##

# 加载到匹配字典的资源,也就是需要被保护的,设置了所支持角色访问的资源
# 没有配置的资源也默认被认证保护,但不鉴权
# eg: /api/v1/source1===get===[admin] 表示 /api/v2/host===post 这条资源支持 admin 这一种角色访问
# eg: /api/v1/source2===get===[] 表示 /api/v1/source2===get 这条资源不支持任何角色访问
resourceRole:
  - /api/account/auth/refresh===post===[admin,user,guest]
  - /api/apps/**===get===[admin,user,guest]
  - /api/monitor/**===get===[admin,user,guest]
  - /api/monitor/**===post===[admin,user]
  - /api/monitor/**===put===[admin,user]
  - /api/monitor/**===delete==[admin]
  - /api/monitors/**===get===[admin,user,guest]
  - /api/monitors/**===post===[admin,user]
  - /api/monitors/**===put===[admin,user]
  - /api/monitors/**===delete===[admin]
  - /api/alert/**===get===[admin,user,guest]
  - /api/alert/**===post===[admin,user]
  - /api/alert/**===put===[admin,user]
  - /api/alert/**===delete===[admin]
  - /api/alerts/**===get===[admin,user,guest]
  - /api/alerts/**===post===[admin,user]
  - /api/alerts/**===put===[admin,user]
  - /api/alerts/**===delete===[admin]
  - /api/notice/**===get===[admin,user,guest]
  - /api/notice/**===post===[admin,user]
  - /api/notice/**===put===[admin,user]
  - /api/notice/**===delete===[admin]
  - /api/tag/**===get===[admin,user,guest]
  - /api/tag/**===post===[admin,user]
  - /api/tag/**===put===[admin,user]
  - /api/tag/**===delete===[admin]
  - /api/summary/**===get===[admin,user,guest]
  - /api/summary/**===post===[admin,user]
  - /api/summary/**===put===[admin,user]
  - /api/summary/**===delete===[admin]

# 需要被过滤保护的资源,不认证鉴权直接访问
# /api/v1/source3===get 表示 /api/v1/source3===get 可以被任何人访问 无需登录认证鉴权
excludedResource:
  - /api/account/auth/**===*
  - /api/i18n/**===get
  - /api/apps/hierarchy===get
  - /actuator/**===get
  # web ui 前端静态资源
  - /===get
  - /dashboard/**===get
  - /monitors/**===get
  - /alert/**===get
  - /account/**===get
  - /setting/**===get
  - /passport/**===get
  - /**/*.html===get
  - /**/*.js===get
  - /**/*.css===get
  - /**/*.ico===get
  - /**/*.ttf===get
  - /**/*.png===get
  - /**/*.gif===get
  - /**/*.jpg===get
  - /**/*.svg===get
  - /**/*.json===get
  # swagger ui 资源
  - /swagger-resources/**===get
  - /v2/api-docs===get
  - /v3/api-docs===get
  # h2 database
  - /h2-console/**===*

# 用户账户信息
# 下面有 admin tom lili 三个账户
# eg: admin 拥有[admin,user]角色,密码为hertzbeat
# eg: tom 拥有[user],密码为hertzbeat
# eg: lili 拥有[guest],明文密码为lili, 加盐密码为1A676730B0C7F54654B0E09184448289
account:
  - appId: admin
    credential: hertzbeat
    role: [admin,user]
  - appId: tom
    credential: hertzbeat
    role: [user]
  - appId: guest
    credential: hertzbeat
    role: [guest]
  - appId: lili
    # 注意 Digest认证不支持加盐加密的密码账户
    # 加盐加密的密码,通过 MD5(password+salt)计算
    # 此账户的原始密码为 lili
    credential: 1A676730B0C7F54654B0E09184448289
    salt: 123
    role: [guest]

备注:这里没有做什么修改,密码是默认的。

account:

- appId: admin

credential: hertzbeat

在/data目录下创建上面两个文件,然后运行HertzBeat即可

docker run -dti -p 1157:1157 \
    -e LANG=zh_CN.UTF-8 \
    -e TZ=Asia/Shanghai \
    -v /data/hertzbeat/data:/opt/hertzbeat/data \
    -v /data/hertzbeat/logs:/opt/hertzbeat/logs \
    -v /data/application.yml:/opt/hertzbeat/config/application.yml \
    -v /data/sureness.yml:/opt/hertzbeat/config/sureness.yml \
    --restart=always \
    --name hertzbeat tancloud/hertzbeat:latest

运行成功后,我们可以使用docker ps查看tdengine数据库实例和HertzBeat实例的进程。

# docker ps
CONTAINER ID   IMAGE                        COMMAND                  CREATED       STATUS       PORTS                                                                                                                          NAMES
4bb57f02dedd   tancloud/hertzbeat:latest    "./bin/entrypoint.sh"    2 hours ago   Up 2 hours   0.0.0.0:1157->1157/tcp, :::1157->1157/tcp                                                                                      hertzbeat
77a11dd2b845   tdengine/tdengine:2.4.0.12   "/tini -- /usr/bin/e…"   4 hours ago   Up 4 hours   0.0.0.0:6030-6049->6030-6049/tcp, 0.0.0.0:6030-6049->6030-6049/udp, :::6030-6049->6030-6049/tcp, :::6030-6049->6030-6049/udp   tdengine

访问HertzBeat管理页面:http://192.168.223.199:1157/

在仪表盘,我们可以看见配置的监控的总览

下面分享下相关监控的趋势图:

1)服务器可用性监控

2)网页可用性监控

3)端口可用性监控

4)系统资源使用监控

5)中间件监控

备注:Tomcat中间件监控,跨服务器监控,要在catalina.sh里面配置开启JMX,还需要在tomcat-user.xml里面配置监控用户。

CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.223.199 -Dcom.sun.management.jmxremote.port=9011 -Dcom.su
n.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
  <role rolename="manager"/>
  <user username="monitor" password="YourPassword" roles="manager"/>

HertzBeat的配置信息如下:

监控告警测试:

模拟停掉Tomcat服务,然后再启动,就会出现下面的告警列表,看起来还是很清晰的。

在告警中心可以看见更加详细的告警信息记录:

总结,这款软件监控的对象还是很广的,监控配置也很简单。但是,监控数据的GUI展示和目前流行的Grafana相比,还是界面还是很简陋的,期待后期可以完善和提升。另外,软件的安全性也有待提升,因为明文密码配置在文件中,在生产环境中(尤其是大厂)肯定是不被安全所允许的。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/179488.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

在线工具轻松设计电商直通车主图,无需下载

电商直通车主图设计教程&#xff01;无门槛在线设计&#xff0c;零基础轻松入门的电商设计工具&#xff0c;轻松就能搞定的主图设计工具&#xff0c;下面跟着小编的设计教程&#xff0c;一起学习如何使用在线工具乔拓云轻松设计专属的商品直通车主图&#xff0c;在线模板轻松设…

QTableWidget表格使用及美化

QTableWidget使用 选中一行、选中单个目标、禁止编辑 ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);//选中的时候选中一行ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);//只能选中单个目标ui->tableWidg…

C++程序设计——泛型编程、函数模板、类模板

一、泛型编程 假如需要实现一个通用的加法函数&#xff0c;即可以实现多种类型的数据相加。这里当然可以使用函数重载来实现&#xff0c;但是其中会存在一些不好的地方&#xff0c;比如&#xff1a; &#xff08;1&#xff09;重载的函数仅仅是类型不同&#xff0c;代码复用率…

尚硅谷Vue3 笔记总结及代码

✨作者&#xff1a;猫十二懿 ❤️‍&#x1f525;账号&#xff1a;CSDN 、掘金 、个人博客 、Github &#x1f389;公众号&#xff1a;猫十二懿 笔记结合了总结视频中总结的内容 尚硅谷张天禹老师课程 空降视频 Vue3官网 1、Vue3简介 1.1 性能的提升 打包大小减少41%初次渲…

从源码解析代理模式

大纲代理模式&#xff08;结构型设计模式&#xff09;通过代理类去访问实现类中的方法&#xff0c;使用场景比如&#xff1a;已有接口和实现类的情况下&#xff0c;想要在已实现的方法基础上扩展更多的功能的场景。代理模式里的主要类&#xff1a;接口实现类&#xff0c;需实现…

数据结构 第三章 栈和队列(栈)

天空之外&#xff1a;点击收听 1 基本知识点 1、栈顶是指允许进行插入和删除操作的一端&#xff0c;另外一端称为栈底 2、进栈是指在栈顶位置插入元素(也叫入栈或者压栈)&#xff0c;出栈是指删除栈顶元素(也叫弹栈或者退栈) 3、栈溢出是指&#xff1a; 当栈满的时候&#x…

led和白炽灯哪个对眼睛好?分享光线舒适的LED护眼灯

最近对于白炽灯与LED灯哪个更护眼的话题受到很多人关注&#xff0c;经过综合考虑&#xff0c;LED灯更适合家庭使用的。 LED灯是电致发光的半导体芯片&#xff0c;抗震性能好&#xff0c;内置三基色荧光粉&#xff0c;让光线更加柔和&#xff0c;做到使用寿命长达10万小时&#…

通信原理简明教程 | 基本概念

文章目录1 通信及通信系统1.1 通信系统的基本组成模型1.2 通信系统的分类1.3 模拟通信和数字通信系统2 调制和解调2.1 调制解调的基本概念2.2 调制解调的分类2.3 调制解调的作用3 通信系统的质量指标3.1 模拟通信系统的质量指标3.2 数字通信系统的质量指标4 总结1 通信及通信系…

算法导论(二):渐进符号、递归及解法

渐近符号 基本的渐近符号&#xff1a; O 表示上界&#xff0c;即小于等于 ≤ Ω 表示下界&#xff0c;即大于等于 ≥ Θ 表示渐近等于 &#xff08;上一集也有使用这个符号&#xff09; 还有几个严格符号&#xff1a; o 表示小于 < ω 表示大于 > 渐近符号O 主要详细讲…

Latex中给图表添加中英文标题及生成相关目录

通常我们都是用\caption{这里是标题}的方式给图表添加对应的标题&#xff0c;如果我们需要同时给出两个标题呢&#xff1f;&#xff08;例如某些毕业论文中要求同时给出中英文标题&#xff09;如果我们还要生成对应的图表目录呢&#xff1f;这些问题都可以利用bicaption这个包来…

【论文翻译】A simple yet effective baseline for 3d human pose estimation

【论文】https://arxiv.org/abs/1705.03098v2 【pytorch】weigq/3d_pose_baseline_pytorch: A simple baseline for 3d human pose estimation in PyTorch. (github.com) 【tensorflow】https://github.com/una-dinosauria/3d-pose-baseline 摘要 随着深度卷积网络的成功&am…

手把手教你如何在项目中使用阿里字体图标IconFont

阿里图标官网地址&#xff1a;IconFont-阿里巴巴矢量图标库 一、注册账号 要使用阿里图标&#xff0c;首先你要在它的官网注册一个账号&#xff0c;注册的方式有多种&#xff08;手机号&#xff0c;Github&#xff0c;微博&#xff0c;阿里域账号&#xff09;&#xff0c;根据…

【CSDN的2022与2023】普普通通的三年,从懵懂、焦虑到坚定、奋进,破除焦虑努力成为更好的自己

大家好&#xff0c;我是黄小黄&#xff01;一名普通的软件工程在读学生。最近终于闲下来了一丢丢&#xff01;借着休息之余&#xff0c;来写一篇年度总结散散心~与其说是年度总结&#xff0c;不如说是给大学生活与莽莽撞撞的自己一个交代叭&#xff01; 这些都是小标题~碎碎念1…

行为型模式-观察者模式

1.概述 定义&#xff1a;又被称为发布-订阅&#xff08;Publish/Subscribe&#xff09;模式&#xff0c;它定义了一种一对多的依赖关系&#xff0c;让多个观察者对象同时监听某一个主题对象。这个主题对象在状态变化时&#xff0c;会通知所有的观察者对象&#xff0c;使他们能…

深度卷积对抗神经网络 基础 第四部分 可控制的GANs(Controllable GANs)

不同的生成模型定义 深度卷积对抗神经网络包含两种不同的生成模型&#xff0c; 条件生成模型 和非条件生成模型。非条件生成模型就像是一个彩票机或者赌博机&#xff0c;你输入一个任意数字的硬币数量&#xff0c;而输出则是随机的彩球。这样的系统&#xff0c;我们不能控制输…

第九层(3):STL之vector类

文章目录前情回顾vrctor类vrctor类的功能vector与普通数组的区别vector的迭代器vector类内的构造函数vector类内的赋值操作vector类内对容器和大小操作vector类内的插入操作vector类内的删除操作vector类内的单个访问vector类内的交换函数vector类内的预留空间下一座石碑&#…

goto语句——“C”

各位CSDN的uu你们好啊&#xff0c;好久不见&#xff0c;甚是想念。今天小雅兰要带大家学习的内容是一个小知识点——goto语句&#xff0c;好啦&#xff0c;就让我们进入goto语句的世界吧 C语言中提供了可以随意滥用的goto语句和标记跳转的标号。 从理论上 goto语句是没有必要…

Python爬虫教你爬取视频内容

前面介绍了基本的数据爬取&#xff0c;图片爬取的相关案例前面文章也有涉及&#xff0c;关于有些案例网站不能登录的问题&#xff0c;可以再找些别的网站&#xff0c;因为道理既然明白了&#xff0c;其实什么网站都一样&#xff0c;它有反爬机制&#xff0c;自然有应对它的办法…

安装mysql 5.7.24

官网 https://downloads.mysql.com/archives/community/ 安装 安装好后解压有如下内容 配置电脑环境变量 MYSQL_HOME mysql安装目录 PATH %MYSQL_HOME%\bin 配置mysql相关信息 &#xff08;1&#xff09;新建配置文件my.ini 配置的是字符集类信息与存储引擎相关信息 &…

(Java高级教程)第四章必备前端基础知识-第二节2:CSS属性

文章目录一&#xff1a;CSS属性一览表二&#xff1a;常用属性详解&#xff08;1&#xff09;字体属性&#xff08;2&#xff09;文本属性&#xff08;3&#xff09;背景属性一&#xff1a;CSS属性一览表 W3C&#xff1a;元素属性 A&#xff1a; align-content规定弹性容器内…