To get the exact used RAM percentage in Grafana, you can follow these steps:
- Make sure you have installed and configured the necessary components for Grafana, such as Prometheus, Node Exporter, and a data source for Prometheus in Grafana.
- Ensure that you have already set up the RAM monitoring in Prometheus using Node Exporter. This will collect RAM usage data and make it available to Grafana.
- Open Grafana and log in to your dashboard.
- Create a new panel or navigate to an existing one where you want to display the RAM usage percentage.
- Click on "Edit" to open the panel editor.
- In the panel editor, click on the "Metrics" tab.
- Under the "Query" section, select the data source you have configured for Prometheus.
- Write a PromQL expression to get the used RAM percentage. For example, the expression 100 * (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) can be used to calculate the used RAM percentage.
- Click on the "Run" button to test the query. Ensure that it returns the expected results.
- Once the query is working, click on the "Visualization" tab in the panel editor.
- Choose the type of visualization you want to use to display the RAM usage percentage, such as a gauge, graph, or single stat.
- Configure the visualization settings to customize the appearance of the displayed RAM usage percentage.
- Save the panel.
The panel will now display the exact used RAM percentage based on the query and visualization settings you have configured in Grafana.