Compare commits
10 Commits
eaceaab8d1
...
c31e12637d
| Author | SHA1 | Date |
|---|---|---|
|
|
c31e12637d | |
|
|
7cf31c45d3 | |
|
|
3806037a2c | |
|
|
a002faf913 | |
|
|
6a9c0b1f2b | |
|
|
1527079a85 | |
|
|
a1471efa7a | |
|
|
25065ca24f | |
|
|
372638e9b7 | |
|
|
fe05a3b66b |
|
|
@ -74,9 +74,11 @@
|
|||
def SCRIPT_PARAMETER = ''
|
||||
SCRIPT_PARAMETER = " -mU " + maxUsers.toString()
|
||||
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -ll " + lastLogin.toString()
|
||||
sh '''cd ./src'''
|
||||
|
||||
sh "python3 createReport.py ${SCRIPT_PARAMETER}"
|
||||
sh """cd ./src
|
||||
python3 createReport.py ${SCRIPT_PARAMETER}
|
||||
pwd
|
||||
ls -la
|
||||
"""
|
||||
}
|
||||
//Only required once CN is not reachable from EMEA
|
||||
//loopEnvironments(environments)
|
||||
|
|
@ -89,9 +91,9 @@
|
|||
try {
|
||||
emailext subject: env.JOB_NAME,
|
||||
body: 'Please find the output of your reports attached',
|
||||
to: 'rene.forstner@nttdata.com',
|
||||
to: 'bmw.dynatrace@nttdata.com, coco-apm@bmw.de, ops-xibix@list.bmw.com, omo-xibix@list.bmw.com, omo@bmwgroup.com',
|
||||
replyTo: 'coco-apm@bmw.de',
|
||||
attachmentsPattern: './src/*.csv'
|
||||
attachmentsPattern: '*.xlsx'
|
||||
|
||||
}
|
||||
catch ( mailExc ){
|
||||
|
|
|
|||
143
README.md
143
README.md
|
|
@ -1,134 +1,21 @@
|
|||
# Dynatrace Reporting Pipeline
|
||||
# Dynatrace Account Managment Reporting
|
||||
|
||||
This repository holds the code for creating the following reporting data from the Dynatrace Account Management API
|
||||
- configured User Groups without any users
|
||||
- local User groups including it's users
|
||||
- User groups with identical permissions
|
||||
- Users which have not logged in to Dynatrace since 60 days
|
||||
- Users who never logged in to Dynatrace
|
||||
|
||||
The report is sent monthly via mail to coco-apm@bmw.de and bmw.dynatrace@nttdata.com
|
||||
|
||||
This repository is used as a template to create automated Dynatrace reports through Jenkins (JAWS) which are sent as attachement through mail.
|
||||
***
|
||||
## Jenkins environments
|
||||
EMEA & NA: https://jaws.bmwgroup.net/opapm/
|
||||
|
||||
CN: https://jaws-china.bmwgroup.net/opmaas/
|
||||
## Run the script / parameters
|
||||
The script takes 2 parameters
|
||||
- -mU --> Maximum amount of users within a group to consider this group as empty(default is "2" to catch groups with only one user)
|
||||
- -ll --> Days since the last login to consider an user as inactive
|
||||
|
||||
### Request access
|
||||
Access is granted manually through stephan.oertelt@bmw.de and Mohammed.Abadel@bmw.de
|
||||
|
||||
### Multi-Branch Pipelines
|
||||
- master (=latest) --> for testing and developing stuff
|
||||
- staging --> pre-release branch, if stuff tested successfully here merge it to production
|
||||
- production --> actively used, productive reports
|
||||
|
||||
***
|
||||
## Minimum Content of a Dynatrace Reporting Repo
|
||||
|
||||
### Repository & Pipeline Naming
|
||||
- Repository and Pipelines must have identical names
|
||||
- Naming must start with CoCo_APM_Reporting_**report name here**
|
||||
|
||||
### readme-File
|
||||
|
||||
The readme file must contain a useful description **what** is reported **when** to **whom**
|
||||
|
||||
Example: <br>
|
||||
> This report is reporting all installed OneAgent versions including:
|
||||
> - Hostnames
|
||||
> - Environment Tag
|
||||
> - PaaS Tag
|
||||
>
|
||||
> Sent to: coco-apm@bmw.de
|
||||
>
|
||||
> Executed on each Monday of every week <br>
|
||||
> Executed on every Dynatrace environment
|
||||
|
||||
### requirements.txt
|
||||
The requirements.txt file must contain **all** python packages which are used within the script through ```import``` <br>
|
||||
|
||||
e.g.: <br>
|
||||
``` python-decouple
|
||||
pyyaml
|
||||
pandas
|
||||
decouple
|
||||
requests
|
||||
datetime
|
||||
argparse
|
||||
```
|
||||
### environments.yaml
|
||||
The environments.yaml contains all environments on which the script should be executed, environments which should not be executed may be excluded through ```#```
|
||||
|
||||
**Do NOT change the environments names, the pipeline script is configured to distingue between EMEA/NA and CN as their are different Jenkins environments!**
|
||||
|
||||
The following snipped shows an environment file, which is only executed on Dynatrace prod environments.
|
||||
|
||||
```
|
||||
euprod:
|
||||
- name: "euprod"
|
||||
- env-url: "https://xxu26128.live.dynatrace.com"
|
||||
- env-token-name: "EUPROD_TOKEN_VAR"
|
||||
#eupreprod:
|
||||
- name: "eupreprod"
|
||||
- env-url: "https://qqk70169.live.dynatrace.com"
|
||||
- env-token-name: "EUPREPROD_TOKEN_VAR"
|
||||
#napreprod:
|
||||
- name: "napreprod"
|
||||
- env-url: "https://onb44935.live.dynatrace.com"
|
||||
- env-token-name: "NAPREPROD_TOKEN_VAR"
|
||||
naprod:
|
||||
- name: "naprod"
|
||||
- env-url: "https://wgv50241.live.dynatrace.com"
|
||||
- env-token-name: "NAPROD_TOKEN_VAR"
|
||||
cnprod:
|
||||
- name: "cnprod"
|
||||
- env-url: "https://dynatracemgd-cn.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b"
|
||||
- env-token-name: "CNPROD_TOKEN_VAR"
|
||||
#cnpreprod:
|
||||
- name: "cnpreprod"
|
||||
- env-url: "https://dynatracemgd-cn.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b"
|
||||
- env-token-name: "CNPREPROD_TOKEN_VAR"
|
||||
```
|
||||
|
||||
### Jenkinsfile
|
||||
The Jenkinsfile is the pipeline script itself including:
|
||||
- Time-Trigger
|
||||
- Install package step
|
||||
- Execute script step
|
||||
- Send Mail step
|
||||
|
||||
### Python Script
|
||||
The script itself will gather and aggregate the data from the Dynatrace environments.
|
||||
|
||||
Script output must be a csv or excel file in the **folder where the script is executed**
|
||||
***
|
||||
## First Usage - Create a new Pipeline
|
||||
|
||||
### Fork this repo
|
||||
Do **NOT** clone this repo, create a fork instead.
|
||||
|
||||
1. On the left menue bar click on *Create fork*
|
||||
|
||||

|
||||
|
||||
2. Choose Project *Offboard Platform - APM - Application Performance Monitoring*
|
||||
3. Choose a name starting with *CoCo_APM_Reporting_* and a useful suffix
|
||||
4. Uncheck *Enable fork syncing*
|
||||
|
||||

|
||||
|
||||
5. Edit readme.md and describe your report
|
||||
6. Change/Update the environment, requirements and script according to your needs
|
||||
7. Login to Jenkins and select the folder *Coco APM Reporting*
|
||||
8. Click the *New Item* Button
|
||||
9. Enter the name of your repo (e.g. *CoCo_APM_Reporting_OneAgentVersion*)
|
||||
10. Select *Multibranch Pipeline*
|
||||
11. Click *OK* Button
|
||||
|
||||

|
||||
|
||||
12. On The Pipeline Settings go to *Branch Sources*, click *ADD SOURCE* and select *Bitbucket*
|
||||
- Server: **ATC**
|
||||
- Credentials: **qqjaws7**
|
||||
- Owner: **OPAPM**
|
||||
- Repository Name: **your forked repository**
|
||||
- Behavious: **According to screenshot**
|
||||
<br>
|
||||
|
||||

|
||||
|
||||
<br>
|
||||
Your pipeline will automatically test-run for all 3 branches.
|
||||
> createReport.py -mU 2 -ll 60
|
||||
Binary file not shown.
|
|
@ -71,7 +71,7 @@ def createReportData(client_id, client_secret, account_id, scope, maxUser, lastL
|
|||
neverLoggedInUsers[user.email]["surname"] = user.surname
|
||||
neverLoggedInUsers[user.email]["status"] = user.userStatus
|
||||
|
||||
writer = pd.ExcelWriter("./AccountReport.xlsx")
|
||||
writer = pd.ExcelWriter("../AccountReport.xlsx")
|
||||
df_emptyGroups = pd.DataFrame.from_dict(emptyGroups,orient="index")
|
||||
df_emptyGroups.to_excel(writer,sheet_name="EmptyGroups")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue