Skip to content

Commit

Permalink
Updated readme and help info
Browse files Browse the repository at this point in the history
  • Loading branch information
doughon committed Sep 18, 2024
1 parent d97d8e9 commit ed9d937
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
19 changes: 8 additions & 11 deletions operations/auditing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ The script *createAuditReport.py* in this folder generates an auditing report ab
## Prerequisites
* The process [Copy Looker SQL query Logs](../../maintenance/copySqlQuery) is in place
* The machine running the script must have
* Python 2.7
* Python 3.8
* [pipenv](https://github.com/pypa/pipenv)
* access to Redshift
* access to Looker API endpoint
* You need to have
* Redshift login credentials
* Looker API3 keys
* Looker API4 keys

## Setup
Download the git repo to host machine, change *`pwd`* to repo root folder, and run
Expand All @@ -30,15 +30,13 @@ Optionally, set following environment variables if you don't want to supply the
* PGHOST - Redshift host
* PGUSER - Redshift user name
* PGPASSWORD - Redshift user password
* lookerUrlPrefix - Looker url prefix such as https://looker.local:19999/api/3.1
* lookerUrlPrefix - Looker url prefix such as https://looker.local:19999/api/4.0

## Usage

```
$ pipenv run python createAuditReport.py -h
usage: createAuditReport.py [-h] [-s LOOKERCLIENTSECRET] [-H PGHOST]
[-u PGUSER] [-p PGPASSWORD] [-l LOOKERURLPREFIX]
siteHost lookerClientId
usage: createAuditReport.py [-h] [-s LOOKERCLIENTSECRET] [-H PGHOST] [-u PGUSER] [-p PGPASSWORD] [-l LOOKERURLPREFIX] [-f FILE] siteHost lookerClientId
Generate auditing report for a given site host.
Expand All @@ -57,21 +55,20 @@ optional arguments:
-p PGPASSWORD, --pgPassword PGPASSWORD
Redshift user password overriding env var PGPASSWORD
-l LOOKERURLPREFIX, --lookerUrlPrefix LOOKERURLPREFIX
Looker url prefix such as
https://looker.local:19999/api/3.1 overriding env var
lookerUrlPrefix
Looker url prefix such as https://looker.local:19999/api/3.1 overriding env var lookerUrlPrefix
-f FILE, --file FILE Write results to a csv file at the specified path
```
If any required information is neither supplied in env var nor cmd arg, you will be prompted to enter it.

Examples

```
$ pipenv run python createAuditReport.py foo.com myLookerClientId -s myLookerClientSecret > report.csv
$ pipenv run python createAuditReport.py foo.com myLookerClientId -s myLookerClientSecret -f report.csv
Enter your looker client secret:
```
Generate report for site *foo.com* into file *report.csv* if PGHOST, PGUSER, PGPASSWORD and lookerUrlPrefix have been supplied via environment variables.
```
$ pipenv run python createAuditReport.py -H redshift.host -u reshift_user -p reshift_user_password -l https://looker.local:19999/api/3.1 -s myLookerClientSecret foo.com myLookerClientId > report.csv
$ pipenv run python createAuditReport.py -H redshift.host -u reshift_user -p reshift_user_password -l https://looker.local:19999/api/4.0 -s myLookerClientSecret www.foo.com myLookerClientId -f report.csv
```
Generate report for site *foo.com* into file *report.csv*, supplying all required information via command arguments.

Expand Down
4 changes: 2 additions & 2 deletions operations/auditing/createAuditReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# parse cmd arguments
parser = argparse.ArgumentParser(
description='Generate auditing report for a given site host.')
parser.add_argument('siteHost', help='site host such as my-site.gov.bc.ca')
parser.add_argument('siteHost', help='site host such as www.my-site.gov.bc.ca')
parser.add_argument('lookerClientId', help='your looker client id')
parser.add_argument('-s',
'--lookerClientSecret',
Expand All @@ -35,7 +35,7 @@
parser.add_argument('-l',
'--lookerUrlPrefix',
help='Looker url prefix such as https://looker.local:19999'
'/api/3.1 overriding env var lookerUrlPrefix')
'/api/4.0 overriding env var lookerUrlPrefix')
parser.add_argument('-f',
'--file',
help='Write results to a csv file at the specified path')
Expand Down

0 comments on commit ed9d937

Please sign in to comment.