Application method
Certificate Configuration
Before using BCM-Tool to push Monitor data, users must first create a certificate file (the BCM-Tool installation directory includes a certificate template, through which users can modify the certificate). There are no restrictions on the certificate file storage directory. Below is an example of the certificate file format:
1[USER]
2BCM_USER_ID = xxxxxxxxcfe04e2494c23974xxxxxxxx
3[AKSK]
4BCM_ACCESS_KEY = xxxxxxxx846d4884b9dfaed6xxxxxxxx
5BCM_SECRET_KEY = xxxxxxxxfd764b2996412a66xxxxxxxx
Users simply need to input their userId, accessKey, and secretKey in the designated fields within the certificate file, e.g., "xxxxxxxxcfe04e2494c23974xxxxxxxx" (placeholder example, not real information), and then specify the certificate when utilizing the tool.
Setting of environment variables
The BCM-Tool provides two parameters: -c/--credential-file to specify the credential file path and -u/--url to specify the BCM service URL. For example:
1bcm-tool metric-data-put --credential-file ./bcm-credential.template --url http://bcm.bj.baidubce.com
Since these two parameter values rarely change during usage, BCM-Tool allows users to retrieve certificate paths and BCM Service URLs from environment variables, removing the need for manual specification for every execution.
Configure environment variables as follows:
1export BCM_CREDENTIAL_FILE=<credential_path>
2 export BCM_URL=http://bcm.bj.baidubce.com or export BCM_URL=http://bcm.gz.baidubce.com
Where, <credential_path> is the absolute path of the certificate, bcm.bj.baidubce.com is the address of the BCM service (Beijing Region), and bcm.gz.baidubce.com is the address of the BCM service (Guangzhou Region). Region selection will be introduced later.
Description:
When users set both environment variables and specify the
--credential-fileand--urlparameters, the content specified by the parameters takes precedence.
Region Selection
BCM-Tool supports pushing Custom Monitor data to different regions. Users can specify a specific region by configuring the URL. For details, refer to [Region List](BCM/API Reference/Service domain.md).
BCM-Tool Command Introduction
BCM-Tool provides a series of Monitor and Alarm functions through sub-commands. Users can view the supported sub-commands of BCM-Tool in the following way:
1bcm-tool help
BCM-Tool currently supports three sub-commands: metric-data-put, metric-data-list, and metric-meta-list, which are used for pushing Monitor data, querying Monitor data, and querying Monitor metadata, respectively.
Users can also view detailed parameter descriptions and examples for each sub-command. The command is as follows (taking pushing Monitor data as an example):
bcm-tool help metric-data-putor bcm-tool metric-data-put --help.
Push Monitor Data
Push Data Sub-command Metric-data-put
- Push raw data.
bcm-tool metric-data-put --scope <SCOPE> --metric-name <METRICNAME> --value <VALUE> --timestamp <TIMESTAMP>
1- \\--scope (-S) defines the scope of the service to be pushed.
2- \\--metric-name (-m) defines the monitoring metric to be pushed.
3- \\--value (-v) indicates the Monitor value to be pushed.
4- \\--timestamp (-t) specifies the Timestamp to associate with the Monitor data.
- Push aggregated Monitor data.
bcm-tool metric-data-put --scope <SCOPE> --metric-name <METRICNAME> --statistic-value average=<VALUE>,sum=<VALUE>,maximum=<VALUE>,minimum=<VALUE> --timestamp <TIMESTAMP>
1- \\--statistic (-s) represents the aggregated Monitor value.
2
3**Note:** Only one of the two parameters, either --value or --statistic, can be used in a single data push.
- Provide Dimension details for the Monitor item.
bcm-tool metric-data-put --scope <SCOPE> --metric-name <METRICNAME> --value <VALUE> --timestamp <TIMESTAMP> --dimensions <NAME>=<VALUE>,<NAME>=<VALUE>
1- \\--dimensions (-d) designates the Dimension details of the Monitor item.
- Submit Monitor data through files (users need to generate Monitor data files in the correct JSON format).
bcm-tool metric-data-put --scope <SCOPE> --data-file ./data.template
1- \\--data-file (-f) specifies the data file.
Users can also utilize the BCM-Tool to generate Monitor data file templates. With this, only value modifications are needed, making the process significantly easier.
- Generate a Monitor data file template.
bcm-tool metric-data-put -T
Query Monitor Data
Query Monitor Data Sub-command: metric-data-list
For example: bcm-tool metric-data-list --scope <SCOPE> --metric-name <METRICNAME> --statistics sum,average --start-time <STARTTIME> --end-time <ENDTIME> --period <PERIOD>
1* --scope specifies the Service Scope for the query.
2 * --metric-name specifies the name of the Monitor item to be queried.
3 * --statistics specifies how to aggregate the queried raw data.
4 * --start-time and --end-time specify the time range for the query.
5 * --period specifies the aggregation period in seconds (default value is 60).
During Monitor data queries, Dimension details can be defined using the --dimensions (-d) parameter.
Query Monitor Metadata
Sub-command for querying Monitor metadata: metric-meta-list
For example: bcm-tool metric-meta-list -S <SCOPE>
Querying with Scope retrieves Monitor metadata within the current Scope. Running this command returns all Monitor item details under the Scope, including its Dimensions.
To view metadata of a Monitor item or specific Dimension, use the following command:
1bcm-tool metric-meta-list --scope <SCOPE> --metric-name <METRICNAME>
2
3bcm-tool metric-meta-list --scope <SCOPE> --metric-name <METRICNAME> --dimensions <NAME>=<VALUE>,<NAME>=<VALUE>
