|
| 1 | +--- |
| 2 | +id: extend-http-default |
| 3 | +title: HTTP协议系统默认解析方式 |
| 4 | +sidebar_label: 系统默认解析方式 |
| 5 | +--- |
| 6 | +> HTTP接口调用获取响应数据后,用argusDBM默认的解析方式去解析响应数据。 |
| 7 | +
|
| 8 | +**此需接口响应数据结构符合argusDBM指定的数据结构规则** |
| 9 | + |
| 10 | +### argusDBM数据格式规范 |
| 11 | +注意⚠️ 响应数据为JSON |
| 12 | + |
| 13 | +单层格式:key-value |
| 14 | +```json |
| 15 | +{ |
| 16 | + "metricName1": "metricValue", |
| 17 | + "metricName2": "metricValue", |
| 18 | + "metricName3": "metricValue", |
| 19 | + "metricName4": "metricValue" |
| 20 | +} |
| 21 | +``` |
| 22 | +多层格式:数组里面套key-value |
| 23 | +```json |
| 24 | +[ |
| 25 | + { |
| 26 | + "metricName1": "metricValue", |
| 27 | + "metricName2": "metricValue", |
| 28 | + "metricName3": "metricValue", |
| 29 | + "metricName4": "metricValue" |
| 30 | + }, |
| 31 | + { |
| 32 | + "metricName1": "metricValue", |
| 33 | + "metricName2": "metricValue", |
| 34 | + "metricName3": "metricValue", |
| 35 | + "metricName4": "metricValue" |
| 36 | + } |
| 37 | +] |
| 38 | +``` |
| 39 | +样例: |
| 40 | +查询自定义系统的CPU信息,其暴露接口为 `/metrics/cpu`,我们需要其中的`hostname,core,useage`指标 |
| 41 | +若只有一台虚拟机,其单层格式为: |
| 42 | +```json |
| 43 | +{ |
| 44 | + "hostname": "linux-1", |
| 45 | + "core": 1, |
| 46 | + "usage": 78.0, |
| 47 | + "allTime": 200, |
| 48 | + "runningTime": 100 |
| 49 | +} |
| 50 | +``` |
| 51 | +若有多台虚拟机,其多层格式为: |
| 52 | +```json |
| 53 | +[ |
| 54 | + { |
| 55 | + "hostname": "linux-1", |
| 56 | + "core": 1, |
| 57 | + "usage": 78.0, |
| 58 | + "allTime": 200, |
| 59 | + "runningTime": 100 |
| 60 | + }, |
| 61 | + { |
| 62 | + "hostname": "linux-2", |
| 63 | + "core": 3, |
| 64 | + "usage": 78.0, |
| 65 | + "allTime": 566, |
| 66 | + "runningTime": 34 |
| 67 | + }, |
| 68 | + { |
| 69 | + "hostname": "linux-3", |
| 70 | + "core": 4, |
| 71 | + "usage": 38.0, |
| 72 | + "allTime": 500, |
| 73 | + "runningTime": 20 |
| 74 | + } |
| 75 | +] |
| 76 | +``` |
| 77 | + |
| 78 | +**对应的监控配置定义文件YML可以配置为如下** |
| 79 | + |
| 80 | +```yaml |
| 81 | +# 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 |
| 82 | +category: custom |
| 83 | +# 监控应用类型(与文件名保持一致) eg: linux windows tomcat mysql aws... |
| 84 | +app: example |
| 85 | +name: |
| 86 | + zh-CN: 模拟应用类型 |
| 87 | + en-US: EXAMPLE APP |
| 88 | +# 参数映射map. 这些为输入参数变量,即可以用^_^host^_^的形式写到后面的配置中,系统自动变量值替换 |
| 89 | +# type是参数类型: 0-number数字, 1-string明文字符串, 2-secret加密字符串 |
| 90 | +# 强制固定必须参数 - host |
| 91 | +configmap: |
| 92 | + - key: host |
| 93 | + type: 1 |
| 94 | + - key: port |
| 95 | + type: 0 |
| 96 | +# 指标组列表 |
| 97 | +metrics: |
| 98 | +# 第一个监控指标组 cpu |
| 99 | +# 注意:内置监控指标有 (responseTime - 响应时间) |
| 100 | + - name: cpu |
| 101 | + # 指标组调度优先级(0-127)越小优先级越高,优先级低的指标组会等优先级高的指标组采集完成后才会被调度,相同优先级的指标组会并行调度采集 |
| 102 | + # 优先级为0的指标组为可用性指标组,即它会被首先调度,采集成功才会继续调度其它指标组,采集失败则中断调度 |
| 103 | + priority: 0 |
| 104 | + # 指标组中的具体监控指标 |
| 105 | + fields: |
| 106 | + # 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位 |
| 107 | + - field: hostname |
| 108 | + type: 1 |
| 109 | + instance: true |
| 110 | + - field: usage |
| 111 | + type: 0 |
| 112 | + unit: '%' |
| 113 | + - field: core |
| 114 | + type: 0 |
| 115 | +# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk |
| 116 | + protocol: http |
| 117 | +# 当protocol为http协议时具体的采集配置 |
| 118 | + http: |
| 119 | + # 主机host: ipv4 ipv6 域名 |
| 120 | + host: ^_^host^_^ |
| 121 | + # 端口 |
| 122 | + port: ^_^port^_^ |
| 123 | + # url请求接口路径 |
| 124 | + url: /metrics/cpu |
| 125 | + # 请求方式 GET POST PUT DELETE PATCH |
| 126 | + method: GET |
| 127 | + # 是否启用ssl/tls,即是http还是https,默认false |
| 128 | + ssl: false |
| 129 | + # 响应数据解析方式: default-系统规则,jsonPath-jsonPath脚本,website-网站可用性指标监控 |
| 130 | + # 这里使用argusDBM默认解析 |
| 131 | + parseType: default |
| 132 | +``` |
0 commit comments