How to get the exact used ram percentage in Grafana?

by wayne.swaniawski , in category: General Help , 7 months ago

How to get the exact used ram percentage in Grafana?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by damian_mills , 7 months ago


To get the exact used RAM percentage in Grafana, you can follow these steps:

  1. 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.
  2. 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.
  3. Open Grafana and log in to your dashboard.
  4. Create a new panel or navigate to an existing one where you want to display the RAM usage percentage.
  5. Click on "Edit" to open the panel editor.
  6. In the panel editor, click on the "Metrics" tab.
  7. Under the "Query" section, select the data source you have configured for Prometheus.
  8. 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.
  9. Click on the "Run" button to test the query. Ensure that it returns the expected results.
  10. Once the query is working, click on the "Visualization" tab in the panel editor.
  11. Choose the type of visualization you want to use to display the RAM usage percentage, such as a gauge, graph, or single stat.
  12. Configure the visualization settings to customize the appearance of the displayed RAM usage percentage.
  13. 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.

by noemy.bosco , 2 months ago


If you prefer a more straightforward way to showcase the RAM usage percentage in Grafana without the intricacies of PromQL queries, you can follow these steps:

In your Grafana dashboard, click on the "Add panel" button to create a new panel. Select the data source (e.g., Prometheus) from the drop-down menu that collects RAM usage data. Now, go to the Metrics tab and search for the appropriate RAM metric (for example, 'node_memory_MemUsed_bytes' and 'node_memory_MemTotal_bytes'). Here you can create a new query that displays used RAM in bytes by subtracting the 'MemFree' from 'MemTotal,' or use the 'MemAvailable' and 'MemTotal' fields to calculate used RAM. Once you have configured the query, click on "Apply" or "Run" to see the RAM usage data in bytes. To convert this into a percentage, you can use a transformation plugin like the Math feature in the "Transform" tab of the panel editor and apply the appropriate calculations to get the percentage display. You can also add a separate gauge visualization panel to showcase the RAM usage percentage visually. Adjust the gauge settings to represent the value as desired. Save the changes to the panel and enjoy the accurate representation of the RAM usage percentage in your Grafana dashboard.