Has anyone used the Dynatrace Metrics API (v2) to pull data into a Jupyter notebook? I’m close, but need to pivot the default data format into something more friendly.
url = '{0}/api/v2/metrics/query?metricSelector={1}&from={2}&to={3}&resolution=2m&entitySelector=type({4}),entityId({5})'.format(base_url,metric,from_time,to_time,entity_type,entity_id)<br><br>result = requests.get(url, headers=headers)<br><br>result_json = result.json()<br><br>df = pd.DataFrame.from_dict(result_json['result'][0]['data'])<br> <br>df

I’m trying to gather 4-5 different metrics into a notebook to present to management.
Got it:
metric = 'builtin:service.response.time'<br>entity_type = 'SERVICE'<br>entity_id = 'SERVICE-64FED8674FB7BA98'<br>from_time = 'now-1h'<br>to_time = 'now'<br><br>url = '{0}/api/v2/metrics/query?metricSelector={1}&from={2}&to={3}&resolution=2m&entitySelector=type({4}),entityId({5})'.format(base_url,metric,from_time,to_time,entity_type,entity_id)<br><br>result = requests.get(url, headers=headers)<br><br>result_json = result.json()<br><br>in_data = result_json['result'][0]['data'][0]<br>del in_data['dimensions']<br><br>df = pd.DataFrame.from_dict(in_data)<br><br>df.timestamps = pd.to_datetime(df.timestamps, unit='ms', utc=True)<br>df.timestamps = df.timestamps.dt.tz_convert('US/Central')<br><br>df.plot(x='timestamps', y='values')