OPMAAS-3581 report dashboards with Wirkkette

OPMAAS-3581
Doris Ruppert 2023-03-13 13:45:57 +01:00
parent 589d0ce28a
commit d9f2da77df
2 changed files with 47 additions and 55 deletions

View File

@ -30,7 +30,7 @@ def GatherReportingInfo(DTAPIToken, DTENV,friendlyName):
else:
verify=True
DTAPIURL= env + "/api/v2/metrics?metricSelector=calc:service.*&fields=created,lastWritten&pageSize=499"
DTAPIURL= env + "/api/config/v1/dashboards"
headers = {
'Content-Type': 'application/json',
'Authorization': 'Api-Token ' + DTAPIToken
@ -44,36 +44,28 @@ def GatherReportingInfo(DTAPIToken, DTENV,friendlyName):
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,verify)
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
try:
dashboards = r.json()
count = 0
for dashboard in dashboards['dashboards']:
row={'id':dashboard['id'],'name':dashboard['name'],'owner':dashboard['owner']}
DTAPIURL= env + "/api/config/v1/dashboards/" + dashboard['id']
r = make_request(DTAPIURL,headers,verify)
response = r.text
if ("wirkkette" in response.lower()):
print("Text Wirkkette found in dashboard json" + dashboard['name'])
mgmt = mgmt.append(row,ignore_index=True)
#mgmt= pd.concat((mgmt,row), axis=0)
mgmt = mgmt.append(row,ignore_index=True)
count=count+1
# df.to_csv(reportingFolder + friendlyName + '_Restart_' + strnow +'.csv')
mgmt.to_csv(friendlyName + '_CalculatedMetrics_' + strnow +'.csv',encoding='utf-8')
print (friendlyName + "done: " + str(count) + " dashboards checked.")
# df.to_csv(friendlyName + '_Restart_' + strnow +'.csv')
mgmt.to_csv(friendlyName + '_DashboardsWithWirkkette_' + strnow +'.csv',encoding='utf-8')
except:
print(r)
with open('./environment.yaml') as file:
doc = yaml.safe_load(file)

View File

@ -1,30 +1,30 @@
euprod:
- name: "EUprod"
- env-url: "https://xxu26128.live.dynatrace.com"
- env-token-name: "EUPROD_TOKEN_VAR"
- jenkins: "https://jaws.bmwgroup.net/opapm/"
eupreprod:
- name: "eupreprod"
- env-url: "https://qqk70169.live.dynatrace.com"
- env-token-name: "EUPREPROD_TOKEN_VAR"
- jenkins: "https://jaws.bmwgroup.net/opapm/"
napreprod:
- name: "napreprod"
- env-url: "https://onb44935.live.dynatrace.com"
- env-token-name: "NAPREPROD_TOKEN_VAR"
- jenkins: "https://jaws.bmwgroup.net/opapm/"
naprod:
- name: "naprod"
- env-url: "https://wgv50241.live.dynatrace.com"
- env-token-name: "NAPROD_TOKEN_VAR"
- jenkins: "https://jaws.bmwgroup.net/opapm/"
cnprod:
- name: "cnprod"
- env-url: "https://dynatracemgd-tsp.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b"
- env-token-name: "CNPROD_TOKEN_VAR"
- jenkins: "https://jaws-china.bmwgroup.net/opmaas/"
#euprod:
# - name: "EUprod"
# - env-url: "https://xxu26128.live.dynatrace.com"
# - env-token-name: "EUPROD_TOKEN_VAR"
# - jenkins: "https://jaws.bmwgroup.net/opapm/"
#eupreprod:
# - name: "eupreprod"
# - env-url: "https://qqk70169.live.dynatrace.com"
# - env-token-name: "EUPREPROD_TOKEN_VAR"
# - jenkins: "https://jaws.bmwgroup.net/opapm/"
#napreprod:
# - name: "napreprod"
# - env-url: "https://onb44935.live.dynatrace.com"
# - env-token-name: "NAPREPROD_TOKEN_VAR"
# - jenkins: "https://jaws.bmwgroup.net/opapm/"
#naprod:
# - name: "naprod"
# - env-url: "https://wgv50241.live.dynatrace.com"
# - env-token-name: "NAPROD_TOKEN_VAR"
# - jenkins: "https://jaws.bmwgroup.net/opapm/"
#cnprod:
# - name: "cnprod"
# - env-url: "https://dynatracemgd-cn.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b"
# - env-token-name: "CNPROD_TOKEN_VAR"
# - jenkins: "https://jaws-china.bmwgroup.net/opmaas/"
cnpreprod:
- name: "cnpreprod"
- env-url: "https://dynatracemgd-tsp.bmwgroup.net/e/ab88c03b-b7fc-45f0-9115-9e9ecc0ced35"
- env-url: "https://dynatracemgd-cn.bmwgroup.net/e/ab88c03b-b7fc-45f0-9115-9e9ecc0ced35"
- env-token-name: "CNPREPROD_TOKEN_VAR"
- jenkins: "https://jaws-china.bmwgroup.net/opmaas/"