Compare commits

...

10 Commits

Author SHA1 Message Date
Rene Forstner (ext.) e997984291 Jenkinsfile edited online with Bitbucket 2022-04-07 09:05:28 +02:00
Rene Forstner (ext.) 150c7e4c70 Jenkinsfile edited online with Bitbucket 2022-04-07 08:32:10 +02:00
Rene Forstner (ext.) f3ea759da7 createReport.py edited online with Bitbucket 2022-04-07 08:31:36 +02:00
rforstner 9a224ecd76 changed timezon 2022-03-28 09:16:14 +02:00
rforstner ca89f2bc8e adding michaela to mails 2022-03-08 09:12:19 +01:00
rforstner 0247b8e69d adding ytd slo 2022-02-25 13:51:12 +01:00
rforstner e1b28373c9 adding ytd slo 2022-02-25 12:55:52 +01:00
rforstner 23a9646263 errors with malloc 2022-02-25 12:44:21 +01:00
rforstner bcba609ffd errors with malloc 2022-02-25 12:41:55 +01:00
rforstner 595d5fb120 added hourly slices 2022-02-21 10:07:14 +01:00
3 changed files with 42 additions and 27 deletions

10
Jenkinsfile vendored
View File

@ -38,7 +38,7 @@
//cron('0 8 * * *') //cron('0 8 * * *')
//every monday at 08:00 //every monday at 08:00
cron('0 8 * * 1') cron('0 6 * * 1')
} }
@ -68,7 +68,7 @@
stage('install required python packages') { stage('install required python packages') {
steps { steps {
sh ''' sh '''
pip install --user -r requirements.txt pip3 install --user -r requirements.txt
''' '''
} }
} }
@ -76,7 +76,7 @@
stage('Execute Reporting Script') { stage('Execute Reporting Script') {
steps { steps {
sh 'python createReport.py -p week' sh 'python3 createReport.py -p week'
//Only required once CN is not reachable from EMEA //Only required once CN is not reachable from EMEA
@ -91,7 +91,7 @@
emailext subject: env.JOB_NAME, emailext subject: env.JOB_NAME,
body: 'Please find the output of the weekly QM-Report attached', body: 'Please find the output of the weekly QM-Report attached',
//to: 'rene.forstner@nttdata.com', //to: 'rene.forstner@nttdata.com',
to: 'rene.forstner@nttdata.com, stephan.oertelt@bmw.de, Mohammed.Abadel@bmw.de, OOC-Support@bmwgroup.com, Sonja.Yildizoglu@bmw.de, Andreas.DA.Danzer@partner.bmw.de', to: 'rene.forstner@nttdata.com, philipp-peter.altmann@bmw.de,Chrisovalantis.Tararas@bmw.de',
replyTo: 'coco-apm@bmw.de', replyTo: 'coco-apm@bmw.de',
attachmentsPattern: '*.xlsx' attachmentsPattern: '*.xlsx'
@ -109,4 +109,4 @@
cleanWs() cleanWs()
} }
} }
} }

View File

@ -58,7 +58,7 @@ def getSLO(DTAPIToken, DTENV, fromDate, toDate):
"to": int(toDate), "to": int(toDate),
"timeFrame": "GTF", "timeFrame": "GTF",
"evaluate": True, "evaluate": True,
"sloSelector": "text(\"CoCo-QM-Report\")" "sloSelector": "text(\"Continuous Testing Platform 2.0 by Valantis\")"
} }
r = make_request(DTAPIURL,headers=headers,parameters=parameters,verify=verify) r = make_request(DTAPIURL,headers=headers,parameters=parameters,verify=verify)
try: try:
@ -210,6 +210,7 @@ def main():
hourlyall = pd.DataFrame() hourlyall = pd.DataFrame()
dailyall = pd.DataFrame() dailyall = pd.DataFrame()
totalall = pd.DataFrame() totalall = pd.DataFrame()
ytd = pd.DataFrame()
for item, doc in doc.items(): for item, doc in doc.items():
token = dict(doc[2]) token = dict(doc[2])
@ -232,38 +233,54 @@ def main():
#sort columns in a try block - if API is returning columns which are non exist, this will not fail the script #sort columns in a try block - if API is returning columns which are non exist, this will not fail the script
df[['description','Touchpoint']] = df['description'].str.split('_',expand=True)
try: try:
df = df[['Date', 'HUB', 'id', 'enabled', 'name', 'description', 'Touchpoint', 'evaluatedPercentage', 'errorBudget', 'status', 'error', 'target','warning', 'evaluationType', 'timeframe', 'metricExpression', 'filter']] df = df[['Date', 'HUB', 'id', 'enabled', 'name', 'description', 'evaluatedPercentage', 'errorBudget', 'status', 'error', 'target','warning', 'evaluationType', 'timeframe', 'metricExpression', 'filter']]
except Exception as e: except Exception as e:
print("Could not rearrange columns: " + str(e)) print("Could not rearrange columns: " + str(e))
dailyall = pd.concat([dailyall,df],ignore_index=True) dailyall = pd.concat([dailyall,df],ignore_index=True)
#Calc hourly SLO #Calc hourly SLO
df = pd.DataFrame() if (args.preSelect == "week"):
for index, row in hours.iterrows(): df = pd.DataFrame()
temp_df = getSLO(DTTOKEN,DTURL,row['startTime'],row['endTime']) for index, row in hours.iterrows():
temp_df['Date'] = row['Date'] temp_df = getSLO(DTTOKEN,DTURL,row['startTime'],row['endTime'])
temp_df['HUB'] = item temp_df['Date'] = row['Date']
df = pd.concat([df,temp_df],ignore_index=True) temp_df['HUB'] = item
df = pd.concat([df,temp_df],ignore_index=True)
#sort columns in a try block - if API is returning columns which are non exist, this will not fail the script
try:
df = df[['Date', 'HUB', 'id', 'enabled', 'name', 'description', 'evaluatedPercentage', 'errorBudget', 'status', 'error', 'target','warning', 'evaluationType', 'timeframe', 'metricExpression', 'filter']]
except Exception as e:
print("Could not rearrange columns: " + str(e))
hourlyall = pd.concat([hourlyall,df],ignore_index=True)
#sort columns in a try block - if API is returning columns which are non exist, this will not fail the script ###Calc Overall YTD SLO
yearstart = toDate.replace(month=2,day=28)
yearstart = datetime.datetime(yearstart.year, yearstart.month, yearstart.day)
yearstart = time.mktime(yearstart.timetuple()) * 1000
df = getSLO(DTTOKEN,DTURL,yearstart,days['endTime'].max())
df['Year'] = fromDate.year
df['HUB'] = item
df[['description','Touchpoint']] = df['description'].str.split('_',expand=True)
try: try:
df = df[['Date', 'HUB', 'id', 'enabled', 'name', 'description', 'Touchpoint', 'evaluatedPercentage', 'errorBudget', 'status', 'error', 'target','warning', 'evaluationType', 'timeframe', 'metricExpression', 'filter']] df = df[['Year', 'HUB', 'id', 'enabled', 'name', 'description','evaluatedPercentage', 'errorBudget', 'status', 'error', 'target','warning', 'evaluationType', 'timeframe', 'metricExpression', 'filter']]
except Exception as e: except Exception as e:
print("Could not rearrange columns: " + str(e)) print("Could not rearrange columns: " + str(e))
hourlyall = pd.concat([hourlyall,df],ignore_index=True)
ytd = pd.concat([ytd,df],ignore_index=True)
###Calc Overall SLO ###Calc Overall SLO
df = getSLO(DTTOKEN,DTURL,days['startTime'].min(),days['endTime'].max()) df = getSLO(DTTOKEN,DTURL,days['startTime'].min(),days['endTime'].max())
df['CW'] = fromDate.isocalendar()[1] df['CW'] = fromDate.isocalendar()[1]
df['HUB'] = item df['HUB'] = item
df[['description','Touchpoint']] = df['description'].str.split('_',expand=True)
try: try:
df = df[['CW', 'HUB', 'id', 'enabled', 'name', 'description','Touchpoint', 'evaluatedPercentage', 'errorBudget', 'status', 'error', 'target','warning', 'evaluationType', 'timeframe', 'metricExpression', 'filter']] df = df[['CW', 'HUB', 'id', 'enabled', 'name', 'description', 'evaluatedPercentage', 'errorBudget', 'status', 'error', 'target','warning', 'evaluationType', 'timeframe', 'metricExpression', 'filter']]
except Exception as e: except Exception as e:
print("Could not rearrange columns: " + str(e)) print("Could not rearrange columns: " + str(e))
@ -272,18 +289,15 @@ def main():
else: else:
print("token not found, skipping " + item) print("token not found, skipping " + item)
touchpoints = ['Vehicle' , 'Mobile']
hourlyall = hourlyall[hourlyall['Touchpoint'].isin(touchpoints)]
dailyall = dailyall[dailyall['Touchpoint'].isin(touchpoints)]
totalall = totalall[totalall['Touchpoint'].isin(touchpoints)]
writer = pd.ExcelWriter("./QM_Report_" + str(fromDate.isocalendar()[1]) + ".xlsx") writer = pd.ExcelWriter("./QM_Report_" + str(fromDate.isocalendar()[1]) + ".xlsx")
totalall.to_excel(writer, sheet_name='total') totalall.to_excel(writer, sheet_name='total')
dailyall.to_excel(writer, sheet_name='daily') dailyall.to_excel(writer, sheet_name='daily')
hourlyall.to_excel(writer, sheet_name='hourly') if (args.preSelect == "week"):
hourlyall.to_excel(writer, sheet_name='hourly')
ytd.to_excel(writer, sheet_name='YTD')
writer.save() writer.save()
writer.close() writer.close()
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -1,3 +1,4 @@
---
euprod: euprod:
- name: "EUprod" - name: "EUprod"
- env-url: "https://xxu26128.live.dynatrace.com" - env-url: "https://xxu26128.live.dynatrace.com"