I am trying to utilize this python script:
import requests
import csv
DYNATRACE_BASE_URL = ‘https://your-dynatrace-instance.com/api/v1’
API_TOKEN = ‘your-api-token’
MANAGEMENT_ZONE_ID = ‘your-management-zone-id’
headers = {
‘Authorization’: ‘Api-Token {}’.format(API_TOKEN)
}
def get_metrics(management_zone_id):
endpoint = ‘{}/metrics’.format(DYNATRACE_BASE_URL)
params = {
‘managementZone’: management_zone_id
}
response = requests.get(endpoint, headers=headers, params=params)
response.raise_for_status()
return response.json()
def export_metrics_to_csv(metrics, filename=‘metrics.csv’):
if not metrics:
print(‘No metrics to export.’)
return
headers = metrics[0].keys()
with open(filename, ‘w’, newline=‘’) as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=headers)
writer.writeheader()
writer.writerows(metrics)
print(‘Metrics exported to {}’.format(filename))
def main():
try:
metrics_data = get_metrics(MANAGEMENT_ZONE_ID)
metrics = metrics_data.get(‘metrics’, [])
if not metrics:
print(‘No metrics found for the specified management zone.’)
return
export_metrics_to_csv(metrics)
except Exception as e:
print(‘Error occurred: {}’.format(e))
if __name__ == ‘__main__’:
main()
But on the execution, it says “the hostname does not match either of *.ypz572.dynatrace-managed.com”
my hostname is dynatrace.app.intra.pfs.local


