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
DTAPIToken = DTAPIToken
if (DTENV.find('dynatracemgd') != -1):
if (DTENV.find('dyna-synth-cn') != -1):
verify=False
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
try:
dashboards = r.json()
count = 0
for dashboard in dashboards['dashboards']:
row={'id':dashboard['id'],'name':dashboard['name'],'owner':dashboard['owner']}
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']})
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'})
count=count+1
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
print (friendlyName + "done: " + str(count) + " dashboards checked.")
# df.to_csv(friendlyName + '_Restart_' + strnow +'.csv')
mgmt.to_csv(friendlyName + '_DashboardsWithWirkkette_' + strnow +'.csv',encoding='utf-8')
mgmt = mgmt.append(row,ignore_index=True)
# df.to_csv(reportingFolder + friendlyName + '_Restart_' + strnow +'.csv')
mgmt.to_csv(friendlyName + '_CalculatedMetrics_' + 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/"
#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-url: "https://dyna-synth-cn.bmwgroup.com.cn/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-token-name: "CNPREPROD_TOKEN_VAR"
- jenkins: "https://jaws-china.bmwgroup.net/opmaas/"
#cnpreprod:
# - name: "cnpreprod"
# - env-url: "https://dyna-synth-cn.bmwgroup.com.cn/e/ab88c03b-b7fc-45f0-9115-9e9ecc0ced35"
# - env-token-name: "CNPREPROD_TOKEN_VAR"
# - jenkins: "https://jaws-china.bmwgroup.net/opmaas/"