[manager,collector] 支持HTTP类型监控的SSL参数

This commit is contained in:
tomsun28
2021-12-03 16:45:26 +08:00
parent 61d4759357
commit 3225961dc8
5 changed files with 108 additions and 4 deletions

View File

@@ -71,7 +71,7 @@ public class HttpCollectImpl extends AbstractCollect {
.execute(request, httpContext); .execute(request, httpContext);
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
log.debug("http response status: {}", statusCode); log.debug("http response status: {}", statusCode);
if (statusCode < HttpStatus.SC_OK || statusCode >= HttpStatus.SC_MULTIPLE_CHOICES) { if (statusCode < HttpStatus.SC_OK || statusCode >= HttpStatus.SC_BAD_REQUEST) {
// 1XX 3XX 4XX 5XX 状态码 失败 // 1XX 3XX 4XX 5XX 状态码 失败
builder.setCode(CollectRep.Code.FAIL); builder.setCode(CollectRep.Code.FAIL);
builder.setMsg("statusCode: " + statusCode); builder.setMsg("statusCode: " + statusCode);
@@ -327,7 +327,8 @@ public class HttpCollectImpl extends AbstractCollect {
if (IpDomainUtil.isHasSchema(httpProtocol.getHost())) { if (IpDomainUtil.isHasSchema(httpProtocol.getHost())) {
requestBuilder.setUri(httpProtocol.getHost() + ":" + httpProtocol.getPort() + httpProtocol.getUrl()); requestBuilder.setUri(httpProtocol.getHost() + ":" + httpProtocol.getPort() + httpProtocol.getUrl());
} else { } else {
if (httpProtocol.isSsl()) { boolean ssl = Boolean.parseBoolean(httpProtocol.getSsl());
if (ssl) {
requestBuilder.setUri("https://" + httpProtocol.getHost() + ":" + httpProtocol.getPort() + httpProtocol.getUrl()); requestBuilder.setUri("https://" + httpProtocol.getHost() + ":" + httpProtocol.getPort() + httpProtocol.getUrl());
} else { } else {
requestBuilder.setUri("http://" + httpProtocol.getHost() + ":" + httpProtocol.getPort() + httpProtocol.getUrl()); requestBuilder.setUri("http://" + httpProtocol.getHost() + ":" + httpProtocol.getPort() + httpProtocol.getUrl());

View File

@@ -32,7 +32,7 @@ public class HttpProtocol {
/** /**
* http是否使用链路加密ssl/tls,即是http还是https * http是否使用链路加密ssl/tls,即是http还是https
*/ */
private boolean ssl = false; private String ssl = "false";
/** /**
* http请求方法: get, post, put, delete, patch * http请求方法: get, post, put, delete, patch
*/ */

View File

@@ -44,7 +44,7 @@ metrics:
# 请求方式 GET POST PUT DELETE PATCH # 请求方式 GET POST PUT DELETE PATCH
method: ^_^method^_^ method: ^_^method^_^
# 是否启用ssl/tls,即是http还是https,默认false # 是否启用ssl/tls,即是http还是https,默认false
ssl: false ssl: ^_^ssl^_^
# 认证 # 认证
authorization: authorization:
# 认证方式: Basic Auth, Digest Auth, Bearer Token # 认证方式: Basic Auth, Digest Auth, Bearer Token

View File

@@ -0,0 +1,56 @@
# 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws...
app: website
# 参数映射map. type是参数类型: 0-number数字, 1-string明文字符串, 2-secret加密字符串
# 强制固定必须参数 - host
configmap:
- key: host
type: 1
- key: port
type: 0
- key: uri
type: 1
- key: method
type: 1
- key: ssl
type: 1
- key: username
type: 1
- key: password
type: 2
# 指标组列表
metrics:
# 第一个监控指标组 cpu
# 注意:内置监控指标有 (responseTime - 响应时间)
- name: summary
# 指标组调度优先级(0-127)越小优先级越高,优先级低的指标组会等优先级高的指标组采集完成后才会被调度,相同优先级的指标组会并行调度采集
# 优先级为0的指标组为可用性指标组,即它会被首先调度,采集成功才会继续调度其它指标组,采集失败则中断调度
priority: 0
# 指标组中的具体监控指标
fields:
# 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位
- field: responseTime
type: 0
unit: ms
# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: http
# 当protocol为http协议时具体的采集配置
http:
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# 端口
port: ^_^port^_^
# url请求接口路径
url: ^_^uri^_^
# 请求方式 GET POST PUT DELETE PATCH
method: ^_^method^_^
# 是否启用ssl/tls,即是http还是https,默认false
ssl: ^_^ssl^_^
# 认证
authorization:
# 认证方式: Basic Auth, Digest Auth, Bearer Token
type: Basic Auth
basicAuthUsername: ^_^username^_^
basicAuthPassword: ^_^password^_^
# 响应数据解析方式: default-系统规则,jsonPath-jsonPath脚本,website-网站可用性指标监控
# todo xmlPath-xmlPath脚本,prometheus-Prometheus数据规则
parseType: website

View File

@@ -0,0 +1,47 @@
# 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws...
app: website
# 强制固定必须参数 - host(ipv4,ipv6,域名)
param:
# field-字段名称标识符
- field: host
# name-参数字段显示名称
name: 主机Host
# type-字段类型,样式(大部分映射input标签type属性)
type: host
# 是否是必输项 true-必填 false-可选
required: true
- field: port
name: 端口
type: number
# 当type为number时,用range表示范围
range: '[0,65535]'
required: true
- field: uri
name: URI路径
type: text
# 当type为text时,用limit表示字符串限制大小
limit: 100
required: true
- field: method
name: 请求方式
type: text
# 当type为text时,用limit表示字符串限制大小
limit: 20
required: true
- field: username
name: 用户名
type: text
# 当type为text时,用limit表示字符串限制大小
limit: 20
required: false
- field: password
name: 密码
type: password
required: false
- field: ssl
name: 使用SSL
type: boolean
required: true
# 当type为boolean时,前端用switch展示开关
# 当type为radio单选框,checkbox复选框时,option表示可选项值列表
# option: Yes,No