<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem getting metrics from managed in Dynatrace API</title>
    <link>https://community.dynatrace.com/t5/Dynatrace-API/Problem-getting-metrics-from-Dynatrace-Managed/m-p/245995#M3134</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Easier way to me is from Data Explorer:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Select metrics you are interested. Those are built-in.&lt;/LI&gt;&lt;LI&gt;Split both by service.&lt;/LI&gt;&lt;LI&gt;Filter by management zone.&lt;/LI&gt;&lt;LI&gt;Change to table visualization.&lt;/LI&gt;&lt;LI&gt;Execute query.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AntonPineiro_0-1716034961278.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/19944iC2EC1C5C56EBE3D4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AntonPineiro_0-1716034961278.png" alt="AntonPineiro_0-1716034961278.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Select "..." and "Copy request":&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AntonPineiro_1-1716035024837.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/19945i2D08AB250BA41CEC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AntonPineiro_1-1716035024837.png" alt="AntonPineiro_1-1716035024837.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You will have a way to export information in JSON or CSV, just input your token:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AntonPineiro_2-1716035057122.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/19946iC98C3E4AC4AE03B9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AntonPineiro_2-1716035057122.png" alt="AntonPineiro_2-1716035057122.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Notice it is filtered by "mzId", you can filter also by "mzName" if you prefer.&lt;/P&gt;&lt;P&gt;This would be for one specific managment zone. If you need all of them:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Make a previous call to management zones APIs to reach all of them.&lt;/LI&gt;&lt;LI&gt;Make a loop to repeat similar GET request replacing mzIds.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
    <pubDate>Sat, 18 May 2024 12:26:05 GMT</pubDate>
    <dc:creator>AntonPineiro</dc:creator>
    <dc:date>2024-05-18T12:26:05Z</dc:date>
    <item>
      <title>Problem getting metrics from Dynatrace Managed</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/Problem-getting-metrics-from-Dynatrace-Managed/m-p/245910#M3129</link>
      <description>&lt;P&gt;I am trying to utilize this python script:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;import requests&lt;BR /&gt;import csv&lt;/P&gt;
&lt;P&gt;DYNATRACE_BASE_URL = '&lt;A href="https://your-dynatrace-instance.com/api/v1" target="_blank" rel="noopener"&gt;https://your-dynatrace-instance.com/api/v1&lt;/A&gt;'&lt;BR /&gt;API_TOKEN = 'your-api-token'&lt;BR /&gt;MANAGEMENT_ZONE_ID = 'your-management-zone-id'&lt;/P&gt;
&lt;P&gt;headers = {&lt;BR /&gt;'Authorization': 'Api-Token {}'.format(API_TOKEN)&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;def get_metrics(management_zone_id):&lt;BR /&gt;endpoint = '{}/metrics'.format(DYNATRACE_BASE_URL)&lt;BR /&gt;params = {&lt;BR /&gt;'managementZone': management_zone_id&lt;BR /&gt;}&lt;BR /&gt;response = requests.get(endpoint, headers=headers, params=params)&lt;BR /&gt;response.raise_for_status()&lt;BR /&gt;return response.json()&lt;/P&gt;
&lt;P&gt;def export_metrics_to_csv(metrics, filename='metrics.csv'):&lt;BR /&gt;if not metrics:&lt;BR /&gt;print('No metrics to export.')&lt;BR /&gt;return&lt;BR /&gt;headers = metrics[0].keys()&lt;BR /&gt;with open(filename, 'w', newline='') as csvfile:&lt;BR /&gt;writer = csv.DictWriter(csvfile, fieldnames=headers)&lt;BR /&gt;writer.writeheader()&lt;BR /&gt;writer.writerows(metrics)&lt;BR /&gt;print('Metrics exported to {}'.format(filename))&lt;/P&gt;
&lt;P&gt;def main():&lt;BR /&gt;try:&lt;BR /&gt;metrics_data = get_metrics(MANAGEMENT_ZONE_ID)&lt;BR /&gt;metrics = metrics_data.get('metrics', [])&lt;BR /&gt;if not metrics:&lt;BR /&gt;print('No metrics found for the specified management zone.')&lt;BR /&gt;return&lt;BR /&gt;export_metrics_to_csv(metrics)&lt;BR /&gt;except Exception as e:&lt;BR /&gt;print('Error occurred: {}'.format(e))&lt;/P&gt;
&lt;P&gt;if __name__ == '__main__':&lt;BR /&gt;main()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But on the execution, it says "the hostname does not match either of *.ypz572.dynatrace-managed.com"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my hostname is dynatrace.app.intra.pfs.local&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2024 10:48:37 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/Problem-getting-metrics-from-Dynatrace-Managed/m-p/245910#M3129</guid>
      <dc:creator>geonaute123</dc:creator>
      <dc:date>2024-06-07T10:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problem getting metrics from managed</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/Problem-getting-metrics-from-Dynatrace-Managed/m-p/245944#M3132</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Which metrics you are interested in?&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 16:35:37 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/Problem-getting-metrics-from-Dynatrace-Managed/m-p/245944#M3132</guid>
      <dc:creator>AntonPineiro</dc:creator>
      <dc:date>2024-05-17T16:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problem getting metrics from managed</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/Problem-getting-metrics-from-Dynatrace-Managed/m-p/245985#M3133</link>
      <description>&lt;P&gt;Number of web service requests and response time for each of the element of the management zone,&lt;/P&gt;</description>
      <pubDate>Sat, 18 May 2024 08:35:28 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/Problem-getting-metrics-from-Dynatrace-Managed/m-p/245985#M3133</guid>
      <dc:creator>geonaute123</dc:creator>
      <dc:date>2024-05-18T08:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem getting metrics from managed</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/Problem-getting-metrics-from-Dynatrace-Managed/m-p/245995#M3134</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Easier way to me is from Data Explorer:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Select metrics you are interested. Those are built-in.&lt;/LI&gt;&lt;LI&gt;Split both by service.&lt;/LI&gt;&lt;LI&gt;Filter by management zone.&lt;/LI&gt;&lt;LI&gt;Change to table visualization.&lt;/LI&gt;&lt;LI&gt;Execute query.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AntonPineiro_0-1716034961278.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/19944iC2EC1C5C56EBE3D4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AntonPineiro_0-1716034961278.png" alt="AntonPineiro_0-1716034961278.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Select "..." and "Copy request":&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AntonPineiro_1-1716035024837.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/19945i2D08AB250BA41CEC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AntonPineiro_1-1716035024837.png" alt="AntonPineiro_1-1716035024837.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You will have a way to export information in JSON or CSV, just input your token:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AntonPineiro_2-1716035057122.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/19946iC98C3E4AC4AE03B9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AntonPineiro_2-1716035057122.png" alt="AntonPineiro_2-1716035057122.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Notice it is filtered by "mzId", you can filter also by "mzName" if you prefer.&lt;/P&gt;&lt;P&gt;This would be for one specific managment zone. If you need all of them:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Make a previous call to management zones APIs to reach all of them.&lt;/LI&gt;&lt;LI&gt;Make a loop to repeat similar GET request replacing mzIds.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Sat, 18 May 2024 12:26:05 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/Problem-getting-metrics-from-Dynatrace-Managed/m-p/245995#M3134</guid>
      <dc:creator>AntonPineiro</dc:creator>
      <dc:date>2024-05-18T12:26:05Z</dc:date>
    </item>
  </channel>
</rss>

