有没有办法通过API从DataDog中提取特定度量的标记信息
我需要与Metrics Explorer显示的信息(主机和标记列表)相同的信息,仅用于一个度量
我可以检索使用正则表达式模式过滤的标记:
def _load_metrics(from_time, filter_pattern: str):
regex = re.compile(filter_pattern)
all_metrics = api.Metric.list(from_time)['metrics']
filtered = list(filter(regex.search, all_metrics))
if not len(filtered):
print('No metrics found with filter {}'.format(args.filter_pattern))
return None
print("Found {} metrics matching filter '{}'".format(len(filtered), args.filter_pattern))
return filtered
我可以从一个度量中得到所有主机:
def get_hosts_from_tag(tag_name: str):
hosts = api.Hosts.search(q='hosts:', filter='tag={}'.format(tag_name))
for host in hosts['host_list']:
print(host['name'])
使用datadogpy或DataDog API,如何从度量中获取所有标记?
谢谢
目前没有回答
相关问题 更多 >
编程相关推荐