Pull request #1: OPMAAS-3581

Merge in OPAPM/coco_apm_reporting_dashboards from OPMAAS-3581 to master

* commit '3a7760396d39b918575e60189fe62359f02e38f4':
  OPMAAS-3581 add CN environments
  OPMAAS-3581 report dashboards with Wirkkette
master
Doris Ruppert (ext.) 2023-03-13 13:48:30 +00:00 committed by Arnel Arnautovic (ext.)
commit 1a1abb28d9
2 changed files with 48 additions and 56 deletions

View File

@ -25,12 +25,12 @@ def GatherReportingInfo(DTAPIToken, DTENV,friendlyName):
env = DTENV env = DTENV
DTAPIToken = DTAPIToken DTAPIToken = DTAPIToken
if (DTENV.find('dynatracemgd') != -1): if (DTENV.find('dyna-synth-cn') != -1):
verify=False verify=False
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://dyna-synth-cn.bmwgroup.com.cn/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://dyna-synth-cn.bmwgroup.com.cn/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/"