@kyanny's blog

My thoughts, my life. Views/opinions are my own.

Mackerel API からサービスメトリクス名の一覧を取得する

api_key = ''
service_name = ''

import requests
import json
import pprint

headers = {
    'X-Api-Key': api_key,
}

r = requests.get(f"https://api.mackerelio.com/api/v0/services/{service_name}/metric-names",
                 headers=headers,
                )
metric_names = json.loads(r.text)['names']

for metric_name in metric_names:
    print(metric_name)