在ops-agent當中可以安裝 JVM 來收集 Java 參數,該工具主要收集 memory 以及 garbage collection 的參數,其中監控的選項有包含以下:
jvm.classes.loaded
jvm.gc.collections.count
jvm.gc.collections.elapsed
jvm.memory.heap.committed
jvm.memory.heap.init
jvm.memory.heap.max
jvm.memory.heap.used
jvm.memory.nonheap.committed
jvm.memory.nonheap.init
jvm.memory.nonheap.max
jvm.memory.nonheap.used
jvm.memory.pool.committed
jvm.memory.pool.init
jvm.memory.pool.max
jvm.memory.pool.used
jvm.threads.count
詳細的設定方式您可以參考 [1] 文檔中的範例
set -e
# Create a back up of the existing file so existing configurations are not lost.
sudo cp /etc/google-cloud-ops-agent/config.yaml /etc/google-cloud-ops-agent/config.yaml.bak
# Configure the Ops Agent.
sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF
metrics:
receivers:
jvm:
type: jvm
endpoint: service:jmx:rmi:///jndi/rmi://127.0.0.1:9010/jmxrmi
service:
pipelines:
jvm:
receivers:
- jvm
EOF
sudo systemctl restart google-cloud-ops-agent.service
sleep 60
安裝完後,可於 Monitoring 當中檢視數值,檢視方式請參考 [2]
[1] https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/third-party/jvm#configure-instance
[2] https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/third-party/jvm#verify-configs