I have 100's of instances I want to make sure that stackdriver monitoring agent is installed in all my gcp instances. Is there any way I can get a list of instances which does not have stackdriver monitoring agent installed in a project or the other way around either by using python modules or gcloud?
Asked
Active
Viewed 331 times
0
-
What is the use case? As in how will you use this data if you know where its installed. Ideally i expect agent to be installed from either Ansible/Terraform. So its configuration should give you the details? – Prashant Oct 29 '19 at 10:54
-
There are lot of frequent instances being created so it becomes hard to keep a track and we cannot use ansible/terraform as rhel repo does not connect to internet so its not direct to install monitoring agent. – shrey tyagi Oct 29 '19 at 11:03
-
I dont think it is supported at the moment. But you can write a wrapper using the Monitoring agent API count https://cloud.google.com/monitoring/api/metrics_agent#agent-agent – Prashant Oct 29 '19 at 11:13
-
@Prashant is there any way I get memory usage data of instances using gcloud? since memory usage does not come for instances which does not have monitoring agent I can figure that part then? – shrey tyagi Oct 29 '19 at 11:59
-
You mean this one https://cloud.google.com/monitoring/api/metrics_agent#agent-memory ? – Prashant Oct 29 '19 at 12:07
-
1I would write a program that lists my instances. Then I would list the instances in Stackdriver via the log name. Compare the list. I am not aware of a tool that does this for you. Note that the monitoring agent and the logging agent are different software. – John Hanley Oct 29 '19 at 13:44
1 Answers
0
You could query the agent version when you connect through SSH from the Cloud Shell
gcloud compute ssh INSTANCE-NAME -- "dpkg-query --show --showformat \
'${Package} ${Version} ${Architecture} ${Status}\n' \
stackdriver-agent" --zone=INSTANCE-ZONE
Option -- of gcloud compute ssh allows you to send arguments to the SSH command , from there you can just list the agent version and if it is not installed it will not return a version

Ernesto U
- 786
- 3
- 14