查询监控配置
更新时间 2026-08-17 09:47:30
最近更新时间: 2026-08-17 09:47:30
本节主要介绍如何使用API查询Pushgateway监控配置。
此操作用来查询Pushgateway监控配置信息。
请求语法
查询指定服务器的监控配置
GET /rest/v1/system/config/monitor?serverId=serverid1,serverid2,serveridN HTTP/1.1
HTTP/1.1
Date:date
Host: ip:port
Authorization:authorization查询所有服务器的监控配置
GET /rest/v1/system/config/monitor HTTP/1.1
HTTP/1.1
Date:date
Host: ip:port
Authorization:authorization请求参数
| 参数 | 类型 | 描述 | 是否必须 |
|---|---|---|---|
| serverId | String | 指定查询Pushgateway监控配置的HBlock服务器ID。一次可以指定多个HBlock服务器的ID,以英文逗号(,)分开。如果不填写,默认查询所有HBlock服务器的Pushgateway监控配置。 | 否 |
响应结果
| 名称 | 类型 | 描述 |
|---|---|---|
| monitors | Array of monitor | 监控信息,详见“表1 响应参数monitor说明”。 |
表1 响应参数monitor说明
| 名称 | 类型 | 描述 |
|---|---|---|
| serverId | String | 服务器ID。 |
| send | Object of send | 发送端监控配置,详见“表2 响应参数send说明”。 |
| collect | Object of collect | 硬件采集信息,详见表“表7 响应参数collect说明”。 |
表2 响应参数send说明
| 名称 | 类型 | 描述 |
|---|---|---|
pushgatewayTimeout | Long | 向所有Pushgateway推送数据的超时时长,超时即认为推送失败。 |
| pushgateways | Array of pushgateway | Pushgateway信息,详见“表3 响应参数Pushgateway说明”。 |
| receiverTimeout | Long | 向所有receiver发送数据的超时时间。 |
| receivers | Array of receiver | receiver信息,详见“表5 响应参数receiver说明”。 |
表3 响应参数Pushgateway说明
| 名称 | 类型 | 描述 |
|---|---|---|
| address | String | Pushgateway的IP或域名。 |
| port | Integer | Pushgateway的端口号。 |
| labels | Object of label | Pushgateway标签信息,详见“表4 响应参数label说明”。 |
表4 响应参数label说明
| 名称 | 类型 | 描述 |
|---|---|---|
| agent | String | Pushgateway的客户端。 |
| idc | Integer | 数据所属的数据中心。 |
| hostname | String | 主机名称。 |
| serverIp | String | 服务器IP。 |
| clusterId | String | 集群ID。 |
| clusterName | String | 集群名称。 |
| job | String | Pushgateway推送数据的来源。 |
表5 响应参数receiver说明
| 名称 | 类型 | 描述 |
|---|---|---|
receiverUrl | String | 监控数据推送地址URL。 |
method | Integer | 推送监控数据的请求方法。 |
authType | String | 认证鉴权类型。 |
basicUsername | String | 鉴权类型为Basic时,basic的用户名。 |
basicPassword | String | 鉴权类型为Basic时,basic的密码。 说明 仅当请求包含请求头x-http-client: http-shell 时,响应才会返回此字段。 |
bearerToken | String | 鉴权类型为Bearer时,Bearer的token。 说明 仅当请求包含请求头x-http-client: http-shell 时,响应才会返回此字段。 |
metricLabels | Object of metricLabel | 监控数据推送地址对应的标签值,详见“表6 响应参数metricLabel说明”。 |
表6 响应参数metricLabel说明
| 名称 | 类型 | 描述 |
|---|---|---|
agent | String | 监控数据推送的客户端。 |
| idc | Integer | 数据所属的数据中心。 |
| hostname | String | 主机名称。 |
serverIp | String | 服务器IP。 |
clusterId | String | 集群ID。 |
| clusterName | String | 集群名称。 |
| job | String | 推送数据的来源。 |
表7 响应参数collect说明
| 名称 | 类型 | 描述 |
|---|---|---|
interval | Long | 硬件指标采集的采集间隔。 |
metrics | Array of metric | 硬件采集指标信息,详见“表8 响应参数metric说明”。 |
表8 响应参数metric说明
| 名称 | 类型 | 描述 |
|---|---|---|
| name | String | 采集间隔或采集对象的硬件指标类别名称。 |
| interval | Long | 硬件指标类别单独设置的采集间隔。 |
| items | String | 硬件指标类别单独设置的采集对象。 |
请求示例1
查询服务器hblock_2、hblock_3的监控配置。
GET /rest/v1/system/config/monitor?serverId=hblock_2,hblock_3 HTTP/1.1
Date: Fri, 12 Jun 2026 03:52:52 GMT
Content-Type: application/json; charset=utf-8
Authorization: HBlock userName:signature
Host: 192.168.0.65:1443 响应示例1
HTTP/1.1 200 OK
x-hblock-request-id: b6ad9803976a40f9a835c1f81b8abc6a
Connection: keep-alive
Content-Length: 1528
Date: Fri, 12 Jun 2026 03:52:53 GMT
Content-Type: application/json;charset=utf-8
Server: HBlock
{
"data": {
"monitors": [
{
"serverId": "hblock_2",
"send": {
"interval": 19000,
"timeout": 2000,
"pushgatewayTimeout": 10000,
"pushgateways": [
{
"address": "192.168.0.1",
"port": 9091,
"labels": {
"agent": "ctyun",
"idc": "idc8",
"hostname": "k8s-master",
"serverIp": "192.168.0.64",
"clusterId": "B0A49942-62C8-42FB-9F0B-6CE76BE8A20B",
"clusterName": "test",
"job": "hblock"
}
}
],
"receiverTimeout": 20000,
"receivers": [
{
"receiverUrl": "http://192.168.0.1:9093/metrics",
"method": "PUT",
"authType": "Basic",
"basicUsername": "user1",
"metricLabels": {
"agent": "ctyun",
"idc": "idc1",
"hostname": "k8s-master",
"serverIp": "192.168.0.64",
"clusterId": "B0A49942-62C8-42FB-9F0B-6CE76BE8A20B",
"clusterName": "test",
"job": "hblock"
}
}
]
},
"collect": {
"interval": 14000,
"metrics": [
{
"name": "storFs",
"interval": 14000,
"items": [
"mdm",
"ds-2",
"ds-1"
]
}
]
}
},
{
"serverId": "hblock_3",
"send": {
"interval": 19000,
"timeout": 2000,
"pushgatewayTimeout": 10000,
"pushgateways": [
{
"address": "192.168.0.1",
"port": 9091,
"labels": {
"agent": "ctyun",
"idc": "idc8",
"hostname": "songt-0006",
"serverIp": "192.168.0.67",
"clusterId": "B0A49942-62C8-42FB-9F0B-6CE76BE8A20B",
"clusterName": "test",
"job": "hblock"
}
}
],
"receiverTimeout": 20000,
"receivers": [
{
"receiverUrl": "http://192.168.0.1:9093/metrics",
"method": "PUT",
"authType": "Basic",
"basicUsername": "user1",
"metricLabels": {
"agent": "ctyun",
"idc": "idc1",
"hostname": "songt-0006",
"serverIp": "192.168.0.67",
"clusterId": "B0A49942-62C8-42FB-9F0B-6CE76BE8A20B",
"clusterName": "test",
"job": "hblock"
}
}
]
},
"collect": {
"interval": 14000,
"metrics": [
{
"name": "storFs",
"interval": 14000,
"items": [
"ds-1"
]
}
]
}
}
]
}
}请求示例2
查询所有服务器的监控配置。
GET /rest/v1/system/config/monitor HTTP/1.1
Date: Fri, 12 Jun 2026 03:14:46 GMT
Content-Type: application/json; charset=utf-8
Authorization: HBlock userName:signature
Host: 192.168.0.65:1443 响应示例2
HTTP/1.1 200 OK
x-hblock-request-id: 0a60d8a0e050436bb3198eee68a0d6c9
Connection: keep-alive
Content-Length: 3031
Date: Fri, 12 Jun 2026 03:14:46 GMT
Content-Type: application/json;charset=utf-8
Server: HBlock
{
"data": {
"monitors": [
{
"serverId": "hblock_1",
"send": {
"interval": 19000,
"timeout": 2000,
"pushgatewayTimeout": 10000,
"pushgateways": [
{
"address": "192.168.0.1",
"port": 9091,
"labels": {
"agent": "ctyun",
"idc": "idc8",
"hostname": "songt-0004",
"serverIp": "192.168.0.65",
"clusterId": "B0A49942-62C8-42FB-9F0B-6CE76BE8A20B",
"clusterName": "test",
"job": "hblock"
}
}
],
"receiverTimeout": 20000,
"receivers": [
{
"receiverUrl": "http://192.168.0.1:9093/metrics",
"method": "PUT",
"authType": "Basic",
"basicUsername": "user1",
"metricLabels": {
"agent": "ctyun",
"idc": "idc1",
"hostname": "songt-0004",
"serverIp": "192.168.0.65",
"clusterId": "B0A49942-62C8-42FB-9F0B-6CE76BE8A20B",
"clusterName": "test",
"job": "hblock"
}
}
]
},
"collect": {
"interval": 14000,
"metrics": [
{
"name": "storFs",
"interval": 14000,
"items": [
"mdm",
"ds-2",
"ds-1"
]
}
]
}
},
{
"serverId": "hblock_4",
"send": {
"interval": 19000,
"timeout": 2000,
"pushgatewayTimeout": 10000,
"pushgateways": [
{
"address": "192.168.0.1",
"port": 9091,
"labels": {
"agent": "ctyun",
"idc": "idc8",
"hostname": "songt-007",
"serverIp": "192.168.0.68",
"clusterId": "B0A49942-62C8-42FB-9F0B-6CE76BE8A20B",
"clusterName": "test",
"job": "hblock"
}
}
],
"receiverTimeout": 20000,
"receivers": [
{
"receiverUrl": "http://192.168.0.1:9093/metrics",
"method": "PUT",
"authType": "Basic",
"basicUsername": "user1",
"metricLabels": {
"agent": "ctyun",
"idc": "idc1",
"hostname": "songt-007",
"serverIp": "192.168.0.68",
"clusterId": "B0A49942-62C8-42FB-9F0B-6CE76BE8A20B",
"clusterName": "test",
"job": "hblock"
}
}
]
},
"collect": {
"interval": 14000,
"metrics": [
{
"name": "storFs",
"interval": 14000,
"items": [
"ds-1"
]
}
]
}
},
{
"serverId": "hblock_3",
"send": {
"interval": 19000,
"timeout": 2000,
"pushgatewayTimeout": 10000,
"pushgateways": [
{
"address": "192.168.0.1",
"port": 9091,
"labels": {
"agent": "ctyun",
"idc": "idc8",
"hostname": "songt-0006",
"serverIp": "192.168.0.67",
"clusterId": "B0A49942-62C8-42FB-9F0B-6CE76BE8A20B",
"clusterName": "test",
"job": "hblock"
}
}
],
"receiverTimeout": 20000,
"receivers": [
{
"receiverUrl": "http://192.168.0.1:9093/metrics",
"method": "PUT",
"authType": "Basic",
"basicUsername": "user1",
"metricLabels": {
"agent": "ctyun",
"idc": "idc1",
"hostname": "songt-0006",
"serverIp": "192.168.0.67",
"clusterId": "B0A49942-62C8-42FB-9F0B-6CE76BE8A20B",
"clusterName": "test",
"job": "hblock"
}
}
]
},
"collect": {
"interval": 14000,
"metrics": [
{
"name": "storFs",
"interval": 14000,
"items": [
"ds-1"
]
}
]
}
},
{
"serverId": "hblock_2",
"send": {
"interval": 19000,
"timeout": 2000,
"pushgatewayTimeout": 10000,
"pushgateways": [
{
"address": "192.168.0.1",
"port": 9091,
"labels": {
"agent": "ctyun",
"idc": "idc8",
"hostname": "k8s-master",
"serverIp": "192.168.0.64",
"clusterId": "B0A49942-62C8-42FB-9F0B-6CE76BE8A20B",
"clusterName": "test",
"job": "hblock"
}
}
],
"receiverTimeout": 20000,
"receivers": [
{
"receiverUrl": "http://192.168.0.1:9093/metrics",
"method": "PUT",
"authType": "Basic",
"basicUsername": "user1",
"metricLabels": {
"agent": "ctyun",
"idc": "idc1",
"hostname": "k8s-master",
"serverIp": "192.168.0.64",
"clusterId": "B0A49942-62C8-42FB-9F0B-6CE76BE8A20B",
"clusterName": "test",
"job": "hblock"
}
}
]
},
"collect": {
"interval": 14000,
"metrics": [
{
"name": "storFs",
"interval": 14000,
"items": [
"mdm",
"ds-2",
"ds-1"
]
}
]
}
}
]
}
}