简体   繁体   English

从谷歌云获取 Sensu go 的动态库存

[英]Getting Dynamic Inventory for Sensu go from google cloud

I need suggestion to provide the host IP and port to sensu-go at runtime.我需要建议在运行时提供主机 IP 和端口到sensu-go Currently, we are using static inventory for our VMs which are created in google cloud which causes issues when those instances get deleted and new gets created.目前,我们正在为我们的虚拟机使用 static 库存,这些虚拟机是在google cloud中创建的,当这些实例被删除并创建新实例时会导致问题。 So, I'm looking for a solution to provide the dynamic inventory to sensu-go .因此,我正在寻找一种解决方案来为sensu-go提供动态库存。 However, I could not find a way to query the google cloud in sensu-go and get the host IP(s) by providing tag and project name.但是,我找不到在 sensu-go 中查询谷歌云并通过提供标签和项目名称来获取主机 IP 的方法。

I'm looking for a suggestion to get the host IPs for a given tag from google cloud without using sensu-go client in each host.我正在寻找一个建议,以从谷歌云获取给定标签的主机 IP,而无需在每个主机中使用sensu-go客户端。

Thanks very much in advance.首先十分感谢。

To get a list of IP's used by instances tagged with, say, 'sensu' you can use gcloud commands.要获取标记为“sensu”的实例使用的 IP 列表,您可以使用 gcloud 命令。
To get internal IP:要获取内部 IP:

gcloud compute instances list --project=PROJECT_NAME --filter="tags.items=(SENSU)" --format="get(networkInterfaces[0].networkIP)"

For external IP:对于外部 IP:

gcloud compute instances list --project=PROJECT_NAME --filter="tags.items=(SENSU)" --format="get(networkInterfaces[0].accessConfigs[0].natIP)"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 谷歌云 - 通过ansible运行动态库存时权限被拒绝 - google cloud - permission denied when running dynamic inventory through ansible 如何使 Ansible 动态清单与 Google Cloud Platform (Google Compute Engine)、GCP 配合使用 - How to make Ansible Dynamic Inventory work with Google Cloud Platform (Google Compute Engine), GCP go 1.18 在 google.cloud - go 1.18 in google.cloud Google Cloud上的动态DNS? - dynamic DNS on Google Cloud? Google Cloud数据流:从具有动态文件名的文件读取 - Google Cloud dataflow : Read from a file with dynamic filename 使用 Go 的 Google 云客户端库时出错:未知凭据类型:“impersonated_service_account”? - Getting error using Google cloud client libraries for Go: unknown credential type: "impersonated_service_account"? 从Google Cloud中的Spark Worker获取日志输出 - Getting log output from spark workers in google cloud 使用Google Cloud从特定网站获取数据 - Getting Data From A Specific Website Using Google Cloud 从Google Cloud Load Balancer和cloudflare获取真正的IP - Getting real ip from Google Cloud Load Balancer and cloudflare 使用google-cloud-python从BigQuery获取JSON结果 - Getting results as JSON from BigQuery with google-cloud-python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM