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: else:
verify=True verify=True
DTAPIURL= env + "/api/v2/metrics?metricSelector=calc:service.*&fields=created,lastWritten&pageSize=499" DTAPIURL= env + "/api/config/v1/dashboards"
headers = { headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': 'Api-Token ' + DTAPIToken 'Authorization': 'Api-Token ' + DTAPIToken
@ -44,36 +44,28 @@ def GatherReportingInfo(DTAPIToken, DTENV,friendlyName):
now=datetime.now() now=datetime.now()
strnow = now.strftime("%Y%m%d_%H%M") strnow = now.strftime("%Y%m%d_%H%M")
metrics = r.json() try:
for metric in metrics['metrics']: dashboards = r.json()
row={'metricID':metric['metricId'],'created':metric['created'],'lastWritten':metric['lastWritten']} count = 0
print(metric['metricId']) for dashboard in dashboards['dashboards']:
cleanedMetric = metric['metricId'].replace('\"','') row={'id':dashboard['id'],'name':dashboard['name'],'owner':dashboard['owner']}
cleanedMetric = cleanedMetric.replace('"','')
DTAPIURL= env + "/api/config/v1/calculatedMetrics/service/" + cleanedMetric
response = make_request(DTAPIURL,headers,verify) 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)
row.update({'name':response.json()['name']}) count=count+1
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'): print (friendlyName + "done: " + str(count) + " dashboards checked.")
try: # df.to_csv(friendlyName + '_Restart_' + strnow +'.csv')
row.update({'PG_TAG_KEY_'+str(i):condition['comparisonInfo']['value']['key'],'PG_TAG_VALUE_'+str(i):condition['comparisonInfo']['value']['value']}) mgmt.to_csv(friendlyName + '_DashboardsWithWirkkette_' + strnow +'.csv',encoding='utf-8')
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) except:
print(r)
# df.to_csv(reportingFolder + friendlyName + '_Restart_' + strnow +'.csv')
mgmt.to_csv(friendlyName + '_CalculatedMetrics_' + strnow +'.csv',encoding='utf-8')
with open('./environment.yaml') as file: with open('./environment.yaml') as file:
doc = yaml.safe_load(file) doc = yaml.safe_load(file)

View File

@ -1,30 +1,30 @@
euprod: #euprod:
- name: "EUprod" # - name: "EUprod"
- env-url: "https://xxu26128.live.dynatrace.com" # - env-url: "https://xxu26128.live.dynatrace.com"
- env-token-name: "EUPROD_TOKEN_VAR" # - env-token-name: "EUPROD_TOKEN_VAR"
- jenkins: "https://jaws.bmwgroup.net/opapm/" # - jenkins: "https://jaws.bmwgroup.net/opapm/"
eupreprod: #eupreprod:
- name: "eupreprod" # - name: "eupreprod"
- env-url: "https://qqk70169.live.dynatrace.com" # - env-url: "https://qqk70169.live.dynatrace.com"
- env-token-name: "EUPREPROD_TOKEN_VAR" # - env-token-name: "EUPREPROD_TOKEN_VAR"
- jenkins: "https://jaws.bmwgroup.net/opapm/" # - jenkins: "https://jaws.bmwgroup.net/opapm/"
napreprod: #napreprod:
- name: "napreprod" # - name: "napreprod"
- env-url: "https://onb44935.live.dynatrace.com" # - env-url: "https://onb44935.live.dynatrace.com"
- env-token-name: "NAPREPROD_TOKEN_VAR" # - env-token-name: "NAPREPROD_TOKEN_VAR"
- jenkins: "https://jaws.bmwgroup.net/opapm/" # - jenkins: "https://jaws.bmwgroup.net/opapm/"
naprod: #naprod:
- name: "naprod" # - name: "naprod"
- env-url: "https://wgv50241.live.dynatrace.com" # - env-url: "https://wgv50241.live.dynatrace.com"
- env-token-name: "NAPROD_TOKEN_VAR" # - env-token-name: "NAPROD_TOKEN_VAR"
- jenkins: "https://jaws.bmwgroup.net/opapm/" # - jenkins: "https://jaws.bmwgroup.net/opapm/"
cnprod: #cnprod:
- name: "cnprod" # - name: "cnprod"
- env-url: "https://dynatracemgd-tsp.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b" # - env-url: "https://dynatracemgd-cn.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b"
- env-token-name: "CNPROD_TOKEN_VAR" # - env-token-name: "CNPROD_TOKEN_VAR"
- jenkins: "https://jaws-china.bmwgroup.net/opmaas/" # - jenkins: "https://jaws-china.bmwgroup.net/opmaas/"
cnpreprod: cnpreprod:
- name: "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" - env-token-name: "CNPREPROD_TOKEN_VAR"
- jenkins: "https://jaws-china.bmwgroup.net/opmaas/" - jenkins: "https://jaws-china.bmwgroup.net/opmaas/"