Initial commit
parent
589d0ce28a
commit
3aa602d7fc
|
|
@ -28,13 +28,13 @@
|
||||||
//here comes the trigger according to crontabs - jenkins is in UTC
|
//here comes the trigger according to crontabs - jenkins is in UTC
|
||||||
triggers {
|
triggers {
|
||||||
//every 1st of every month at 00:00
|
//every 1st of every month at 00:00
|
||||||
cron('0 0 1 * *')
|
//cron('0 0 1 * *')
|
||||||
|
|
||||||
//every day at 08:00
|
//every day at 08:00
|
||||||
//cron('0 8 * * *')
|
//cron('0 8 * * *')
|
||||||
|
|
||||||
//every monday at 08:00
|
//every monday at 08:00
|
||||||
//cron('0 8 * * MON')
|
cron('0 8 * * MON')
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -85,8 +85,8 @@
|
||||||
try {
|
try {
|
||||||
emailext subject: env.JOB_NAME,
|
emailext subject: env.JOB_NAME,
|
||||||
body: 'Please find the output of your reports attached',
|
body: 'Please find the output of your reports attached',
|
||||||
to: 'rene.forstner@nttdata.com',
|
to: 'patryk.gudalewicz.bp@nttdata.com',
|
||||||
replyTo: 'coco-apm@bmw.de',
|
replyTo: 'patryk.gudalewicz.bp@nttdata.com',
|
||||||
attachmentsPattern: '*.csv'
|
attachmentsPattern: '*.csv'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
from html import entities
|
||||||
from decouple import config
|
from decouple import config
|
||||||
import yaml
|
import yaml
|
||||||
import requests
|
import requests
|
||||||
|
|
@ -30,7 +31,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/v2/entities?entitySelector=type(\"SERVICE\"),fromRelationships.runsOn(type(\"PROCESS_GROUP\"),tag(\"compass-id\"))&fields=tags&pageSize=499"
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': 'Api-Token ' + DTAPIToken
|
'Authorization': 'Api-Token ' + DTAPIToken
|
||||||
|
|
@ -41,39 +42,25 @@ def GatherReportingInfo(DTAPIToken, DTENV,friendlyName):
|
||||||
|
|
||||||
df = pd.DataFrame()
|
df = pd.DataFrame()
|
||||||
mgmt = pd.DataFrame()
|
mgmt = pd.DataFrame()
|
||||||
|
entityResponse = r.json()
|
||||||
|
entityList = entityResponse["entities"]
|
||||||
|
print("Got {} results from API: ".format(len(entityList)))
|
||||||
|
while "nextPageKey" in entityResponse:
|
||||||
|
print("Getting next page: " + entityResponse["nextPageKey"])
|
||||||
|
nextKey = entityResponse["nextPageKey"]
|
||||||
|
DTAPIURL= env + "/api/v2/entities?nextPageKey={}".format(nextKey)
|
||||||
|
print("Got {} results from API: ".format(len(entityList)))
|
||||||
|
r = make_request(DTAPIURL,headers,verify)
|
||||||
|
entityResponse = r.json()
|
||||||
|
entityList.extend(entityResponse["entities"])
|
||||||
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()
|
for entity in entityList:
|
||||||
for metric in metrics['metrics']:
|
if any(tag["stringRepresentation"].startswith('[Kubernetes]app.bmwgroup.com/') for tag in entity["tags"]):
|
||||||
row={'metricID':metric['metricId'],'created':metric['created'],'lastWritten':metric['lastWritten']}
|
tagval = next((tag for tag in entity["tags"] if tag["stringRepresentation"].startswith('[Kubernetes]app.bmwgroup.com/')), None)
|
||||||
print(metric['metricId'])
|
row={'Tag':tagval["stringRepresentation"],'ServiceName':entity['displayName'],'ServiceId':entity['entityId']}
|
||||||
cleanedMetric = metric['metricId'].replace('\"','')
|
mgmt = mgmt.append(row,ignore_index=True)
|
||||||
cleanedMetric = cleanedMetric.replace('"','')
|
mgmt.to_csv("C:/Users/patry/OneDrive/Dokumenty/NTT/" + friendlyName + '_TaggedEntities_' + strnow +'.csv')
|
||||||
DTAPIURL= env + "/api/config/v1/calculatedMetrics/service/" + cleanedMetric
|
|
||||||
|
|
||||||
response = make_request(DTAPIURL,headers,verify)
|
|
||||||
|
|
||||||
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'})
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
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')
|
|
||||||
|
|
||||||
with open('./environment.yaml') as file:
|
with open('./environment.yaml') as file:
|
||||||
doc = yaml.safe_load(file)
|
doc = yaml.safe_load(file)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue