./stor config add { -i | --item } monitor [ --metric-dataformat pushgateway ] --pushgateway PUSHGATEWAY [ --pushgateway-labels LABEL &<1-n> ] [ { -n | --server } SERVER_ID &<1-n> ]
./stor config add { -i | --item } monitor --metric-dataformat prometheus_text_based --receiver-url URL [ --method METHOD ] [ --auth-type AUTH_TYPE ] [ --basic-username USERNAME --basic-password PASSWORD ] [ --bearer-token TOKEN ] [ --metric-labels LABEL &<1-n> ] [ { -n | --server } SERVER_ID &<1-n> ]
此命令用来添加Pushgateway监控配置。
说明
添加监控配置时,默认携带下列label:job、集群ID、集群名称、ServerIP、hostname。用户有权限修改或删除集群ID、集群名称、ServerIP、hostname,但不建议修改和删除。用户添加的自定义label与默认label同名时,则label取值以用户设置的为准。
参数
Pushgateway的监控配置
| 参数 | 描述 |
|---|---|
| --metric-dataformat pushgateway | 指定metric的数据格式为pushgateway:通过Pushgateway方式推送指标。 |
| --pushgateway PUSHGATEWAY | Pushgateway的地址和接口,格式为IPv4:port、[IPv6]:port或者domain-name:port。 |
| --pushgateway-labels LABEL &<1-n> | Pushgateway对应的标签值,格式为KEY:VALUE。一次可以添加多个标签值,以英文逗号(,)分开。 |
| -n SERVER_ID &<1-n> ]或 --server SERVER_ID &<1-n> ] | 指定添加监控配置的HBlock服务器ID。一次可以指定多个HBlock服务器的ID,以英文逗号(,)分开。 默认为所有HBlock服务器添加监控配置。 |
Prometheus文本格式的监控配置
| 参数 | 描述 |
|---|---|
--metric-dataformat prometheus_text_based | 指定metric的数据格式为prometheus_text_based:表示添加Prometheus文本格式的监控配置。 |
--receiver-url URL | 指定监控数据推送地址URL,格式为:http://hostname:port/uri。 |
--method METHOD | 指定推送监控数据的请求方法。 取值:
默认值为POST。 |
--auth-type AUTH_TYPE | 指定认证鉴权类型。 取值:
默认值为None。 |
| --basic-username USERNAME | 鉴权类型为Basic时,basic的用户名。 取值:字符串,不能包含冒号(:)、空格。 说明 鉴权类型为Basic时,必填。 |
| --basic-password PASSWORD | 鉴权类型为Basic时,basic的密码。 取值:字符串,不能包含空格。 说明 鉴权类型为Basic时,必填。 |
| --bearer-token TOKEN | 鉴权类型为Bearer时,Bearer的token。 取值:字符串,不能包含空格。 说明 鉴权类型为Bearer时,必填。 |
| --metric-labels LABEL &<1-n> | 指定监控数据推送地址对应的标签值,格式为KEY:VALUE。一次可以添加多个标签值,以英文逗号(,)分开,最多可以添加64个标签值。 其中:
|
| -n SERVER_ID &<1-n> ]或 --server SERVER_ID &<1-n> ] | 指定添加监控配置的HBlock服务器ID。一次可以指定多个HBlock服务器的ID,以英文逗号(,)分开。 默认为所有HBlock服务器添加监控配置。 |
示例
示例1
为服务器hblock_1、hblock_2添加Pushgateway监控配置。
[root@hblockserver CTYUN_HBlock_Plus_4.1.0_x64]# ./stor config add -i monitor --pushgateway 192.168.0.1:9091 --pushgateway-labels agent:agentname,idc:idcname -n hblock_1,hblock_2
Added pushgateway 192.168.0.1:9091 with pushgateway labels agent:agentname,idc:idcname on server hblock_1,hblock_2 successfully.示例2
为所有HBlock服务器添加数据格式为prometheus_text_based监控配置。
[root@hblockserver CTYUN_HBlock_Plus_4.1.0_x64]# ./stor config add -i monitor --metric-dataformat prometheus_text_based --receiver-url http://192.168.0.1:9093/metrics --metric-labels agent:agentname,idc:idcname --auth-type Basic --basic-username user1 --basic-password pwd1
Added receiver http://192.168.0.1:9093/metrics with labels agent:agentname,idc:idcname successfully.