Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Google Monitoring - How to retrieve VM name from instance ID

I have this metric selected for my apache monitor:  VM Instance - workload/apache.requests

When the alert is triggered, I receive this info in the email sent to me:
   metric : workload.googleapis.com/apache.requests
   instance_id : 2345xxxxxx2345
   instrumentation_source : agent.googleapis.com/apache
   server_name : 127.0.0.1
   zone : us-xxxxxx

While the instance-ID can identify which apache server was alerting, the VM-name is much more obvious to user than the instance-id.

When setting up the the monitor we are able to pass along notes in the alert email via the POLICY DOCUMENTATION text field.   How can I retrieve  the VM instance NAME from the instance-ID so I can display the VM name in the POLICY DOCUMENTATION text field emailed to the user? .

1 1 390
1 REPLY 1

Hello @tacoma50  ,Welcome on Google Cloud Community.

You can utilize documentation variables:  https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars , especially resource.label.KEY , where key can be found here https://cloud.google.com/monitoring/api/resources.

--
cheers,
DamianS
LinkedIn medium.com Cloudskillsboost Sessionize Youtube

Top Solution Authors