Skip to content

Commit

Permalink
doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Awaragi committed Mar 20, 2022
1 parent bd13b41 commit 562b406
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
42 changes: 24 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,24 @@ It is **_required_** that the specified user has the following permissions
Development
-----------

### Launch a mock mssql server
## Launch a test mssql server

To launch a local mssql instance to test against

```shell
npm run test:mssql:2019
# or
npm run test:mssql:2017
```

which will launch a docker instance equivalent to

```shell
docker run --rm -e ACCEPT_EULA=Y -e SA_PASSWORD=qkD4x3yy -p 1433:1433 --name mssql mcr.microsoft.com/mssql/server:2019-latest
```

To use a persistent storage include `-v /mypath:/var/opt/mssql/data`
To use a persistent storage add `-v /mypath:/var/opt/mssql/data` to your version of package.json

### List all available metrics
## List all available metrics
```shell
node metrics.js
```

### Environment variables
## Environment variables

- SERVER: sqlserver
- PORT: sql server port (defaults to 1433)
Expand All @@ -81,22 +77,32 @@ node metrics.js
- db for database connection logging
- queries for database queries and results logging

### Launch via command line
## Launch via command line

### Using NodeJS

To execute and the application using locally running mssql (see above for how to launch a docker instance of mssql),
use the following command which will generate all very detailed logs
use the following command which will generate all a detailed logs

```shell
DEBUG=app,metrics,db,queries SERVER=localhost USERNAME=SA PASSWORD=qkD4x3yy node ./index.js
npm run test:serve
```

A less verbose execution
A more verbose execution with all queries and their results printed out

```shell
npm run test:serve:verbose
```

### Using Docker

To build and launch your docker image use the following command

```shell
DEBUG=app,metrics,db SERVER=localhost USERNAME=SA PASSWORD=qkD4x3yy node ./index.js
npm run docker:run
```

### Testing
## Testing

Use curl or wget to fetch the metrics from launched web application.

Expand All @@ -107,14 +113,14 @@ curl http://localhost:4000/metrics
E2E test is available to execute against MSSQL 2017 or 2019 docker instances.
Any added metrics must get added to the e2e tests.

### Metric listing
## Metric listing

Call metrics.js file directly to generate documentation of available metrics and to update this README file.

```shell
node metrics.js
```

### building and pushing image to dockerhub
## building and pushing image to dockerhub

Use docker push or the bundled Github Workflows/Actions (see .github/workflows)
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
"scripts": {
"docker:build": "docker build . -t awaragi/prometheus-mssql-exporter",
"docker:run": "docker run --name prometheus-mssql-exporter --rm -it -p 4000:4000 -e SERVER=$(docker inspect mssql | jq -r '.[].NetworkSettings.Networks.bridge.IPAddress') -e USERNAME=SA -e PASSWORD=qkD4x3yy -e DEBUG=app,db,metrics $(docker build -q .)",

"test:serve": "DEBUG=app,db,metrics SERVER=localhost USERNAME=SA PASSWORD=qkD4x3yy node ./index.js",
"test:serve:verbose": "DEBUG=app,db,metrics,metrics SERVER=localhost USERNAME=SA PASSWORD=qkD4x3yy node ./index.js",

"test:mssql:2019": "docker run --name mssql --rm -e ACCEPT_EULA=Y -e SA_PASSWORD=qkD4x3yy -p 1433:1433 --name mssql mcr.microsoft.com/mssql/server:2019-latest",
"test:mssql:2017": "docker run --name mssql --rm -e ACCEPT_EULA=Y -e SA_PASSWORD=qkD4x3yy -p 1433:1433 --name mssql mcr.microsoft.com/mssql/server:2017-latest",

"test:fetch": "curl http://localhost:4000/metrics",
"test": "jest test"
},
Expand Down

0 comments on commit 562b406

Please sign in to comment.