adding py
parent
2ed52db914
commit
82818e5d49
|
|
@ -25,19 +25,55 @@ def GatherReportingInfo(DTAPIToken, DTENV,friendlyName):
|
||||||
env = DTENV
|
env = DTENV
|
||||||
DTAPIToken = DTAPIToken
|
DTAPIToken = DTAPIToken
|
||||||
|
|
||||||
DTAPIURL= env + "/api/config/v1/managementZones/"
|
if (DTENV.find('dynatracemgd') != -1):
|
||||||
|
verify=False
|
||||||
|
else:
|
||||||
|
verify=True
|
||||||
|
|
||||||
|
DTAPIURL= env + "/api/v2/metrics?metricSelector=calc:service.*&fields=created,lastWritten&pageSize=499"
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': 'Api-Token ' + DTAPIToken
|
'Authorization': 'Api-Token ' + DTAPIToken
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DTAPIURL.find('dynatracemgd') != -1):
|
#r = requests.get(DTAPIURL,headers=headers)
|
||||||
verify='./'
|
|
||||||
else:
|
|
||||||
verify=True
|
|
||||||
r = make_request(DTAPIURL,headers,verify)
|
r = make_request(DTAPIURL,headers,verify)
|
||||||
|
|
||||||
print(r)
|
df = pd.DataFrame()
|
||||||
|
mgmt = pd.DataFrame()
|
||||||
|
|
||||||
|
now=datetime.now()
|
||||||
|
strnow = now.strftime("%Y%m%d_%H%M")
|
||||||
|
metrics = r.json()
|
||||||
|
for metric in metrics['metrics']:
|
||||||
|
row={'metricID':metric['metricId'],'created':metric['created'],'lastWritten':metric['lastWritten']}
|
||||||
|
print(metric['metricId'])
|
||||||
|
cleanedMetric = metric['metricId'].replace('\"','')
|
||||||
|
cleanedMetric = cleanedMetric.replace('"','')
|
||||||
|
DTAPIURL= env + "/api/config/v1/calculatedMetrics/service/" + cleanedMetric
|
||||||
|
|
||||||
|
response = make_request(DTAPIURL,headers)
|
||||||
|
|
||||||
|
row.update({'name':response.json()['name']})
|
||||||
|
for condition in response.json()['conditions']:
|
||||||
|
i = 0
|
||||||
|
if(condition['attribute']=='SERVICE_TAG'):
|
||||||
|
try:
|
||||||
|
row.update({'SERVICE_TAG_KEY_'+str(i):condition['comparisonInfo']['value']['key'],'SERVICE_TAG_VALUE_'+str(i):condition['comparisonInfo']['value']['value']})
|
||||||
|
except:
|
||||||
|
row.update({'SERVICE_TAG_KEY_'+str(i):'NO DATA','SERVICE_TAG_VALUE_'+str(i):'NO DATA'})
|
||||||
|
|
||||||
|
if(condition['attribute']=='PROCESS_GROUP_TAG'):
|
||||||
|
try:
|
||||||
|
row.update({'PG_TAG_KEY_'+str(i):condition['comparisonInfo']['value']['key'],'PG_TAG_VALUE_'+str(i):condition['comparisonInfo']['value']['value']})
|
||||||
|
except:
|
||||||
|
row.update({'PG_TAG_KEY_'+str(i):'NO DATA','SERVICE_TAG_VALUE_'+str(i):'NO DATA'})
|
||||||
|
i=i+1
|
||||||
|
|
||||||
|
mgmt = mgmt.append(row,ignore_index=True)
|
||||||
|
|
||||||
|
# df.to_csv(reportingFolder + friendlyName + '_Restart_' + strnow +'.csv')
|
||||||
|
mgmt.to_csv(friendlyName + '_CalculatedMetrics_' + strnow +'.csv')
|
||||||
|
|
||||||
with open('./environment.yaml') as file:
|
with open('./environment.yaml') as file:
|
||||||
doc = yaml.safe_load(file)
|
doc = yaml.safe_load(file)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue