浏览代码

[home,collector]文档新增常见问题,采集器http参数优化校验

tomsun28 3 年之前
父节点
当前提交
935378f90b

+ 1 - 1
README.md

@@ -55,7 +55,7 @@
 
 ### 🐵 依赖服务部署
 
-> HertzBeat最少依赖于 关系型数据库[MYSQL8+](https://www.mysql.com/) 和 时序性数据库[TDengine2+](https://www.taosdata.com/getting-started)
+> HertzBeat最少依赖于 关系型数据库[MYSQL5+](https://www.mysql.com/) 和 时序性数据库[TDengine2+](https://www.taosdata.com/getting-started)
 
 ##### 安装MYSQL
 1. docker安装MYSQl  

+ 11 - 6
collector/src/main/java/com/usthe/collector/collect/http/HttpCollectImpl.java

@@ -350,15 +350,16 @@ public class HttpCollectImpl extends AbstractCollect {
         HttpProtocol.Authorization auth = httpProtocol.getAuthorization();
         if (auth != null && !DispatchConstants.BEARER_TOKEN.equals(auth.getType())) {
             HttpClientContext clientContext = new HttpClientContext();
-            if (DispatchConstants.BASIC_AUTH.equals(auth.getType()) && auth.getBasicAuthUsername() != null
-                    && auth.getBasicAuthPassword() != null) {
+            if (DispatchConstants.BASIC_AUTH.equals(auth.getType())
+                    && StringUtils.hasText(auth.getBasicAuthUsername())
+                    && StringUtils.hasText(auth.getBasicAuthPassword())) {
                 CredentialsProvider provider = new BasicCredentialsProvider();
                 UsernamePasswordCredentials credentials
                         = new UsernamePasswordCredentials(auth.getBasicAuthUsername(), auth.getBasicAuthPassword());
                 provider.setCredentials(AuthScope.ANY, credentials);
                 clientContext.setCredentialsProvider(provider);
-            } else if (DispatchConstants.DIGEST_AUTH.equals(auth.getType()) && auth.getDigestAuthUsername() != null
-                    && auth.getDigestAuthPassword() != null) {
+            } else if (DispatchConstants.DIGEST_AUTH.equals(auth.getType()) && StringUtils.hasText(auth.getDigestAuthUsername())
+                    && StringUtils.hasText(auth.getDigestAuthPassword())) {
                 CredentialsProvider provider = new BasicCredentialsProvider();
                 UsernamePasswordCredentials credentials
                         = new UsernamePasswordCredentials(auth.getBasicAuthUsername(), auth.getBasicAuthPassword());
@@ -400,14 +401,18 @@ public class HttpCollectImpl extends AbstractCollect {
         Map<String, String> params = httpProtocol.getParams();
         if (params != null && !params.isEmpty()) {
             for (Map.Entry<String, String> param : params.entrySet()) {
-                requestBuilder.addParameter(param.getKey(), param.getValue());
+                if (StringUtils.hasText(param.getValue())) {
+                    requestBuilder.addParameter(param.getKey(), param.getValue());
+                }
             }
         }
         // headers
         Map<String, String> headers = httpProtocol.getHeaders();
         if (headers != null && !headers.isEmpty()) {
             for (Map.Entry<String, String> header : headers.entrySet()) {
-                requestBuilder.addHeader(header.getKey(), header.getValue());
+                if (StringUtils.hasText(header.getValue())) {
+                    requestBuilder.addHeader(header.getKey(), header.getValue());
+                }
             }
         }
         // keep-alive

+ 42 - 0
home/docs/help/issue.md

@@ -0,0 +1,42 @@
+---
+id: issue  
+title: 常见问题    
+sidebar_label: 常见问题       
+---
+
+### 监控常见问题   
+
+1. ** 页面反馈:monitor.host:监控Host必须是ipv4,ipv6或域名 **   
+> 如信息所示,输入的监控Host须是ipv4,ipv6或域名,不能携带协议头,例如协议头http   
+
+2. ** 网站API等监控反馈statusCode:403或401,但对端服务本身无需认证,浏览器直接访问是OK **       
+> 请排查是否是被防火墙拦截,如宝塔等默认设置了对请求header中`User-Agent=Apache-HttpClient`的拦截,若被拦截请删除此拦截规则。         
+
+### Docker部署常见问题   
+
+1. **MYSQL,TDENGINE和HertzBeat都Docker部署在同一主机上,HertzBeat使用localhost或127.0.0.1连接数据库失败**     
+此问题本质为Docker容器访问宿主机端口连接失败,由于docker默认网络模式为Bridge模式,其通过localhost访问不到宿主机。
+> 解决办法一:配置application.yml将数据库的连接地址由localhost修改为宿主机的对外IP     
+> 解决办法二:使用Host网络模式启动Docker,即使Docker容器和宿主机共享网络 `docker run -d --network host .....`   
+
+2. **按照流程部署,访问 http://ip:1157/console 无界面**   
+请参考下面几点排查问题:  
+> 一:依赖服务MYSQL数据库,TDENGINE数据库是否已按照启动成功,对应hertzbeat数据库是否已创建,SQL脚本是否执行    
+> 二:HertzBeat的配置文件 `application.yml` 里面的依赖服务IP账户密码等配置是否正确  
+> 三:若都无问题可以 `docker logs hertzbeat` 查看容器日志是否有明显错误,提issue或交流群或社区反馈
+
+3. **日志报错TDengine连接或插入SQL失败**  
+> 一:排查配置的数据库账户密码是否正确,数据库是否创建   
+> 二:若是安装包安装的TDengine2.3+,除了启动server外,还需执行 `systemctl start taosadapter` 启动 adapter    
+
+### 安装包部署常见问题
+
+1. **按照流程部署,访问 http://ip:1157/console 无界面**   
+   请参考下面几点排查问题:
+> 一:依赖服务MYSQL数据库,TDENGINE数据库是否已按照启动成功,对应hertzbeat数据库是否已创建,SQL脚本是否执行    
+> 二:HertzBeat的配置文件 `hertzbeat/config/application.yml` 里面的依赖服务IP账户密码等配置是否正确    
+> 三:若都无问题可以查看 `hertzbeat/logs/` 目录下面的运行日志是否有明显错误,提issue或交流群或社区反馈
+
+2. **日志报错TDengine连接或插入SQL失败**
+> 一:排查配置的数据库账户密码是否正确,数据库是否创建   
+> 二:若是安装包安装的TDengine2.3+,除了启动server外,还需执行 `systemctl start taosadapter` 启动 adapter    

+ 3 - 0
home/docs/start/docker-deploy.md

@@ -99,3 +99,6 @@ sidebar_label: Docker方式部署
 > 二:HertzBeat的配置文件 `application.yml` 里面的依赖服务IP账户密码等配置是否正确  
 > 三:若都无问题可以 `docker logs hertzbeat` 查看容器日志是否有明显错误,提issue或交流群或社区反馈
 
+3. **日志报错TDengine连接或插入SQL失败**  
+> 一:排查配置的数据库账户密码是否正确,数据库是否创建   
+> 二:若是安装包安装的TDengine2.3+,除了启动server外,还需执行 `systemctl start taosadapter` 启动 adapter    

+ 4 - 0
home/docs/start/package-deploy.md

@@ -87,3 +87,7 @@ sidebar_label: 安装包方式部署
 > 一:依赖服务MYSQL数据库,TDENGINE数据库是否已按照启动成功,对应hertzbeat数据库是否已创建,SQL脚本是否执行    
 > 二:HertzBeat的配置文件 `hertzbeat/config/application.yml` 里面的依赖服务IP账户密码等配置是否正确    
 > 三:若都无问题可以查看 `hertzbeat/logs/` 目录下面的运行日志是否有明显错误,提issue或交流群或社区反馈
+
+2. **日志报错TDengine连接或插入SQL失败**
+> 一:排查配置的数据库账户密码是否正确,数据库是否创建   
+> 二:若是安装包安装的TDengine2.3+,除了启动server外,还需执行 `systemctl start taosadapter` 启动 adapter    

+ 1 - 1
home/docs/start/quickstart.md

@@ -11,7 +11,7 @@ sidebar_label: 快速开始
 
 ### 🐵 依赖服务部署   
 
-> HertzBeat最少依赖于 关系型数据库[MYSQL8+](https://www.mysql.com/) 和 时序性数据库[TDengine2+](https://www.taosdata.com/getting-started)
+> HertzBeat最少依赖于 关系型数据库[MYSQL5+](https://www.mysql.com/) 和 时序性数据库[TDengine2+](https://www.taosdata.com/getting-started)
 
 ##### 安装MYSQL  
 1. docker安装MYSQl  

+ 3 - 0
home/docs/start/tdengine-init.md

@@ -48,3 +48,6 @@ TDengine是一款国产的开源物联网时序型数据库,我们使用其替
    taos> show databases;
    taos> use hertzbeat;
    ```
+
+**注意⚠️若是安装包安装的TDengine2.3+版本**       
+> 除了启动server外,还需执行 `systemctl start taosadapter` 启动 adapter    

+ 2 - 1
home/sidebars.json

@@ -52,7 +52,8 @@
             "help/alert_dingtalk",
             "help/alert_feishu"
           ]
-        }
+        },
+        "help/issue"
       ]
     },
     {