Custom Metric Development
You can develop custom metrics in either of the following ways:
- Developing custom metrics using a file
Create a custom metric file that meets the requirements based on Custom Metrics File. When starting the NPU Exporter, set the-textMetricsFilePath parameter to specify the path of the custom metric file. For details, see Table 2. The NPU Exporter reads the custom metric file in each data collection period and reports the file content to Prometheus.
The development example is as follows:
Use the NPU Exporter to integrate and collect the hccs_bandwidth metric generated by DevKit. For details, see deployment guide for NPU Exporter integration with DevKit. For details about the hccs_bandwidth metric, see HCCS bandwidth monitoring.
- Developing custom metrics using a plugin
You can customize metrics by compiling a plugin. Before using the plugin, you need to learn the CGO and Go languages and read README to learn the usage.
- The custom metric name cannot be the same as an existing metric name.
- You are responsible for the stability of the custom plugin and ensure that no runtime panic occurs.
- You are responsible for the correctness of the custom metric file format.