'How to find Memory used percentage by postgres DB using postgres-exporter

I am running postgres, postgres-exporter, prometheus, grafana and cadvisor all as docker containers. I need to find the percentage of memory used by postgres. My requirement is to send an alert when when postgres used more than 85% of memory.

I used below query, but I am not sure this gives exact memory usage.

sum(process_resident_memory_bytes) / sum(machine_memory_bytes) \* 100

Can someone please help me on this? Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source