VMware Modern Apps Community
thberry10
VMware Employee
VMware Employee
Jump to solution

How can I obtain a list of all metric names for a given host, when that host has many metrics

I wish to obtain a list of all metric names (all time series names) that were generated by a given source (host).

Normally I would do this by creating a blank dashboard, entering a query such as ts("*",source=data4099.svc.devqaprod.pdx.wd), and displaying the results in tablular view. For this host the results are very hard to read in Wavefront, I believe because there are many metric names generated for this host. And right-clicking and choosing Copy only copies a single metric name.

Is there a way I can do this?

0 Kudos
1 Solution

Accepted Solutions
thberry10
VMware Employee
VMware Employee
Jump to solution

Hi Owen,

Here's probably the easiest way to do this - just substitute your token and source name, and run the script:

  1. import json, time, urllib2, urllib 
  2. TOKEN = "<TOKEN>" 
  3. SOURCE = "svc0128.svc.prod.ash.wd" 
  4. query = ("{{\"queries\":[{{\"query\":\"ts(\\\"*\\\",source={})\",\"name\":\"queryKeys\"}}],\"start\":{},\"end\":{}," 
  5.   "\"queryParameters\":{{}}}}").format(SOURCE, int(time.time()-2419200), int(time.time())) 
  6. req = urllib2.Request("https://workday.wavefront.com/chart/api/keys?request={}".format(urllib.quote(query))) 
  7. req.add_header('X-AUTH-TOKEN', TOKEN) 
  8. for metric in json.loads(urllib2.urlopen(req).read())["metrics"]: 
  9.   print metric 

Please let us know if this helps!

-Vasily

View solution in original post

0 Kudos
2 Replies
thberry10
VMware Employee
VMware Employee
Jump to solution

Hi Owen,

Here's probably the easiest way to do this - just substitute your token and source name, and run the script:

  1. import json, time, urllib2, urllib 
  2. TOKEN = "<TOKEN>" 
  3. SOURCE = "svc0128.svc.prod.ash.wd" 
  4. query = ("{{\"queries\":[{{\"query\":\"ts(\\\"*\\\",source={})\",\"name\":\"queryKeys\"}}],\"start\":{},\"end\":{}," 
  5.   "\"queryParameters\":{{}}}}").format(SOURCE, int(time.time()-2419200), int(time.time())) 
  6. req = urllib2.Request("https://workday.wavefront.com/chart/api/keys?request={}".format(urllib.quote(query))) 
  7. req.add_header('X-AUTH-TOKEN', TOKEN) 
  8. for metric in json.loads(urllib2.urlopen(req).read())["metrics"]: 
  9.   print metric 

Please let us know if this helps!

-Vasily

0 Kudos
thberry10
VMware Employee
VMware Employee
Jump to solution

Thanks Vasily, that worked.

0 Kudos