Monika is a command line application for synthetic monitoring. The name Monika stands for "Monitoring Berkala", which means "periodic monitoring" in the Indonesian language.
You can find many ways to install Monika and how to start monitoring from the Quick Start page.
Monika is a Node.js application written in TypeScript using the oclif framework.
It was developed on node 20 (LTS), and npm v10.
To start developing, clone this repository, then install the dependencies:
git clone [email protected]:hyperjumptech/monika.git
npm ci
npm run build -w packages/notification
Then, to run Monika from the source,
- on Linux/Unix/Mac
npm start
- on Windows
.\bin\dev.cmd
To keep the formatting consistent, run the following command to format the source code:
npm run format
Finally you can also run npm run test
to prevent regression.
Once you have made the changes, open a Pull Request and explain the issue your change will fix or the feature your change will add.
For contribution details on how to add custom notifications see the New Notifications guide here.
If you are developing feature/fix related to notification by making changes inside the packages/notification
folder, it's easier to temporarily change the dependency source in package.json
to be like this
"@hyperjumptech/monika-notification": "*"
it will sync @hyperjumptech/monika-notification
package node_modules
to any changes in the packages/notification
folder without running build on every code change.
See this docs for further detail
If you need to test a probe locally, there are predefined services in /dev/docker-compose.yaml
. You are encouraged to add other services that can be probed by Monika. Run cd dev && docker compose up
to run those services.
Use the following Monika config to probe the service.
probes:
- id: 'should not follow redirect'
requests:
- url: https://localhost:3000/status/302
followRedirects: 0
alerts:
- assertion: response.status != 302
message: You should not follow the redirect
- id: 'should follow redirect with default config'
requests:
- url: https://localhost:3000/absolute-redirect/20
alerts:
- assertion: response.status == 302
message: You are not following the redirect
- id: 'should follow redirect with customized config'
requests:
- url: https://localhost:3000/status/302
followRedirects: 2
alerts:
- assertion: response.status == 302
message: You are not following the redirect
probes:
- id: mariadb
mariadb:
- host: localhost
port: 3306
username: mariadb_user
password: mariadb_password
database:
probes:
- id: mysql
mysql:
- host: localhost
port: 3307
username: mysql_user
password: mysql_password
database:
probes:
- id: mongo
mongo:
- uri: mongodb:https://mongo_user:mongo_password@localhost:27017
Use the following Monika config to probe the service.
probes:
- id: postgres
postgres:
- uri: postgres:https://postgres_user:postgres_password@localhost:5432/postgres_db
probes:
- id: redis
redis:
- uri: redis:https://:redis_password@localhost:6379
- Run Prometheus. Run
docker compose -f ./dev/prometheus/docker-compose.yaml up
. - Run Monika with the Prometheus flag. Run
npm start -- --prometheus 3001
. - Open Prometheus Expression Browser. Visit
https://localhost:9090/graph
.
The tools and frameworks we used in this project are listed below:
- oclif to scaffold the CLI.
- Prettier to format the code.
- ESLint to statically analyze the code to quickly find problems.
- Mocha for testing.
- Istanbul for code coverage.
If you need help, want to give feedback, or have a great idea to improve Monika, get involved! Let us know in the Github discussions.
Please abide by the Contributor's Code of Conduct
For detailed information, you can click on any of the specific docs below:
MIT License.