The AMD SMI Exporter is a standalone app that can be run as a daemon, written in GO Language, that exports AMD CPU & GPU metrics to the Prometheus server. The AMD SMI Prometheus Exporter employs
- AMDSMI Library for its data acquisition and
- GO binding that provides an interface between the amdsmi and the GO exporter code.
The AMD SMI Exporter follows the AMDSMI library in its releases, as it is dependent on the underlying libraries for its data. The Exporter is currently under development, and therefore subject to change in the features it offers and at the interface with the GO binding.
While every effort will be made to ensure stable backward compatibility in software releases with a major version greater than 0, any code/interface may be subject to revision/change while the major version remains 0.
The standalone GO Exporter may be built from the src directory as follows:
The source code for the GO Exporter is AMD SMI Exporter.
Once the exporter source has been cloned to a local Linux machine, the directory structure of source is as below:
-
$ src/
Contains exporter source for package main -
$ src/collect/
Contains the implementation of the Scan function of the collector. -
$ grafana/
Contains the JSON files for Grafana dashboard. -
Change the directory to amd_smi_exporter/src
$ cd amd_smi_exporter/src
-
Execute "make clean" to clean pre-existing binaries and GO module files
amd_smi_exporter/src$ make clean
-
Execute "make" to perform a "go get" of dependent modules such as
- github.com/prometheus/client_golang
- github.com/prometheus/client_golang/prometheus
- github.com/prometheus/client_golang/prometheus/promhttp
- github.com/ROCm/amdsmi
amd_smi_exporter/src$ make
The aforementioned steps will create the "amd_smi_exporter" GO binary file. To install the binary in /usr/local/bin, and install the service file in /etc/systemd/system directory, one may execute:
```$ sudo make install```
Once the GO Exporter is built, one may proceed to create a containerized micro service of the go executable by executing the following commands:
Prerequisite: docker version 20.10.12 or later must be installed on the build server for the container build to succeed.
-
Execute "make container_clean" to clean pre-existing images and configuration of the container image.
amd_smi_exporter/src$ make container_clean
-
Build the fresh container image with the following command:
amd_smi_exporter/src$ make container
This command will build the container image and will be listed when the user issues the
sudo docker images
command. A tarball of the container image file "k8/amd_smi_exporter_container.tar" is also saved in the "k8" directory, and this may be used to deploy the container manually on respective nodes of the kubernetes cluster using the "k8/daemonset.yaml" file.
JSON files for Grafana dashboard are available under grafana/ of this repo
- AMDSmiExporter_CPU_GrafanaDashboard.json
- AMDSmiExporter_GPU_GrafanaDashboard.json
Please ensure the following are in place
- amdsmi library with goamdsmi_shim bindings installed under "/opt/rocm"
- GO v1.20
- Docker (tested on v20.10.12 or later)
To run on AMD rocm dockers, GO installation through apt install on Linux is only supported till 1.18. Manual installation can be done from here: https://go.dev/dl/ Below is an example of installing 1.20.12 of go.
$ wget -L "https://golang.org/dl/go1.20.12.linux-amd64.tar.gz"
$ tar -xf "go1.20.12.linux-amd64.tar.gz"
$ cd go/
$ ls -l
$ cd ..
$ sudo chown -R root:root ./go
$ sudo mv -v go /usr/local
$ export GOPATH=$HOME/go
$ export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
Add amdsmi library path to LD_LIBRARY_PATH environment variable and export.
$ export LD_LIBRARY_PATH=<path_to_amdsmi_library>
NOTE: Only one instance of the GO Exporter may be run on the server, either as a standalone service, or as a containerized micro service (started with "docker run" or as a daemonSet of a kubernetes deployment).
Prerequisite: To ensure that AMD custom parameters defined in the amd-smi-custom-rules.yml file are found in the promql queries, add the following rule_files and scrape_configs to the /etc/prometheus/prometheus.yml file:
rule_files:
- "amd-smi-custom-rules.yml"
scrape_configs:
- job_name: "prometheus"
- job_name: "amd-smi-exporter"
static_configs:
- targets: ["localhost:2021"]
The prometheus query language allows the user to customize his queries based on user requirements. The customizations may be added to the /usr/local/bin/prometheus/amd-smi-custom-rules.yml file". Here are a few sample queries that may be built over the aforementioned objects:
-
Displays the core energy of core 101 shifted by six decimal points.
-
Rule to check if socket power consumption has gone over 650.00
-
Alert to check if PROC_HOT status has been triggered
The GO exporter may be run manually in the following ways
```amd_smi_exporter/src$ ./amd_smi_exporter```
```$ sudo systemctl daemon-reload```
```$ sudo service prometheus restart```
```$ sudo service amd-smi-exporter start```
Assuming user has a running docker daemon and a kubernetes cluster.
```$ sudo docker run -d --name amd-exporter --device=/dev/cpu --device=/dev/kfd
--device=/dev/dri --privileged -p 2021:2021 amd_smi_exporter_container:0.1```
Alternatively, the docker image tarball of the container may be copied to individual kubernetes cluster node and loaded on the worker node. The daemonSet may then be applied from the master node as follows:
```$ sudo docker load -i amd_smi_exporter_container.tar```
On the master node, copy the daemonset.yaml file and execute:
```$ kubectl apply -f daemonset.yaml```
This will deploy a single running instance of the AMD SMI Exporter container micro
service on the worker nodes of the kubernetes cluster. The daemonset.yaml file may
be edited to apply taints for nodes where the exporter is not expected to run in
the cluster.
AMD EPYC TM line of server CPU Families:
- AMD CPU Family
19h
Models0h-Fh
(Milan),10h-1Fh
(Genoa),A0h-AFh
. - AMD CPU Family
1Ah
Models0h-Fh
(Turin),10h-1Fh
. - AMD APU Family
19h
Models90h-9fh
and - AMD GPUs MI200 and MI300.
### Description: Displays the per-core energy consumption of the processor so far.
This object may be queried at the core level or the thread level. The values reported by the threads in a hyperthreaded core will be the same. This object query will report the energy counter values for all threads. To query a single thread (lets say the thread number is 101), the user may use the following query:
amd_core_energy{thread="101"}
### Type: Counter
### Property: Read-only
### Description: Displays the per-core boost limit that the core is operating at.
### Type: Gauge
### Property: Read-only
### Description: Displays the per-socket cumulative energy consumed by all cores
so far. This value excludes the energy consumed by the AID (Active Interposer Die).To query a single socket (lets say socket 2), the user may use the following query:
amd_socket_energy{socket="2"}
### Type: Counter
### Property: Read-only
### Description: Displays the per-socket power consumed. This is a real time gauge
value that is queried at a time interval set by the scrape interval. ### Type: Gauge ### Property: Read-only
### Description: Displays the power limit at which the processor is operating at.
### Type: Gauge
### Property: Read-only
### Description: Displays a binary value of "0" or "1", where "1" implies that the
PROC_HOT status of the processor has been triggered. ### Type: Gauge ### Property: Read-only
### Description: Displays the number of sockets which the processor is seated in.
### Type: Gauge
### Property: Read-only
### Description: Displays the total number of threads (logical CPUs) in all.
### Type: Gauge
### Property: Read-only
### Description: Displays the number of threads (logical CPUs) per core.
### Type: Gauge
### Property: Read-only
### Description: Displays the number of gpus
### Type: Gauge
### Property: Read-only
### Description: Displays the dev id of the gpu
### Type: Gauge
### Property: Read-only
### Description: Displays the gpu power cap
### Type: Gauge
### Property: Read-only
### Description: Displays the gpu average power consumed
### Type: Counter
### Property: Read-only
### Description: Displays the current temperature of the gpu
### Type: Gauge
### Property: Read-only
### Description: Displays the GPU SCLK frequency
### Type: Gauge
### Property: Read-only
### Description: Displays the GPU MCLK frequency
### Type: Gauge
### Property: Read-only
### Description: Displays the GPU Use percent
### Type: Gauge
### Property: Read-only
### Description: Displays the GPU Memory busy percent
### Type: Gauge
### Property: Read-only
-
If the prometheus service fails to start properly, run the command
journalctl -u prometheus -f --no-pager
-
If an issue is related to "Web lister busy" or "Port is already in use", Please change Port from 9090 to 9091 in the following files
- /etc/systemd/system/prometheus.service file
- under line "--web.listen-address=0.0.0.0:9090"
- /etc/prometheus/prometheus.yml file
- under line "targets: ["localhost:9090"]
and restart the systemd service using command "service prometheus restart".
- /etc/systemd/system/prometheus.service file