Compare commits

..

No commits in common. "e9979842911ab4f7e34504696e719cef74661b13" and "feb2935a9caa92203778ba9b932d52a0b6d18cd9" have entirely different histories.

3 changed files with 27 additions and 42 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 6 * * 1') cron('0 8 * * 1')
} }
@ -68,7 +68,7 @@
stage('install required python packages') { stage('install required python packages') {
steps { steps {
sh ''' sh '''
pip3 install --user -r requirements.txt pip install --user -r requirements.txt
''' '''
} }
} }
@ -76,7 +76,7 @@
stage('Execute Reporting Script') { stage('Execute Reporting Script') {
steps { steps {
sh 'python3 createReport.py -p week' sh 'python 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, philipp-peter.altmann@bmw.de,Chrisovalantis.Tararas@bmw.de', 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',
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(\"Continuous Testing Platform 2.0 by Valantis\")" "sloSelector": "text(\"CoCo-QM-Report\")"
} }
r = make_request(DTAPIURL,headers=headers,parameters=parameters,verify=verify) r = make_request(DTAPIURL,headers=headers,parameters=parameters,verify=verify)
try: try:
@ -210,7 +210,6 @@ 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])
@ -233,54 +232,38 @@ 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', 'evaluatedPercentage', 'errorBudget', 'status', 'error', 'target','warning', 'evaluationType', 'timeframe', 'metricExpression', 'filter']] df = df[['Date', 'HUB', 'id', 'enabled', 'name', 'description', 'Touchpoint', '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
if (args.preSelect == "week"): df = pd.DataFrame()
df = pd.DataFrame() for index, row in hours.iterrows():
for index, row in hours.iterrows(): temp_df = getSLO(DTTOKEN,DTURL,row['startTime'],row['endTime'])
temp_df = getSLO(DTTOKEN,DTURL,row['startTime'],row['endTime']) temp_df['Date'] = row['Date']
temp_df['Date'] = row['Date'] temp_df['HUB'] = item
temp_df['HUB'] = item df = pd.concat([df,temp_df],ignore_index=True)
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)
###Calc Overall YTD SLO #sort columns in a try block - if API is returning columns which are non exist, this will not fail the script
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[['Year', 'HUB', 'id', 'enabled', 'name', 'description','evaluatedPercentage', 'errorBudget', 'status', 'error', 'target','warning', 'evaluationType', 'timeframe', 'metricExpression', 'filter']] df = df[['Date', 'HUB', 'id', 'enabled', 'name', 'description', 'Touchpoint', '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', 'evaluatedPercentage', 'errorBudget', 'status', 'error', 'target','warning', 'evaluationType', 'timeframe', 'metricExpression', 'filter']] df = df[['CW', 'HUB', 'id', 'enabled', 'name', 'description','Touchpoint', '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))
@ -289,15 +272,18 @@ 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')
if (args.preSelect == "week"): hourlyall.to_excel(writer, sheet_name='hourly')
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,4 +1,3 @@
---
euprod: euprod:
- name: "EUprod" - name: "EUprod"
- env-url: "https://xxu26128.live.dynatrace.com" - env-url: "https://xxu26128.live.dynatrace.com"