Skip to content

Commit

Permalink
Add Yaml example configs (#404)
Browse files Browse the repository at this point in the history
* chore: adding yml sample configs

* fix: revert bin/run to production version. dev version accidentally pushed

* doc: add more yaml samples

* removed debug artifacts

* chore: formatting

* fix: bye config.json! using newere and sexier yaml as default
(this commit needs a meme)

* Update docs/src/pages/guides/alerts.md

Co-authored-by: Armedi <[email protected]>

* Update docs/src/pages/guides/alerts.md

Co-authored-by: Armedi <[email protected]>

* Update docs/src/pages/guides/cli-options.md

Co-authored-by: Armedi <[email protected]>

* Update docs/src/pages/guides/notifications.md

Co-authored-by: Armedi <[email protected]>

* Update docs/src/pages/guides/notifications.md

Co-authored-by: Armedi <[email protected]>

* chore: ran formatter

* chore: improve consistency yaml vs yml

Co-authored-by: Armedi <[email protected]>
Co-authored-by: Nico Prananta <[email protected]>
  • Loading branch information
3 people authored Sep 16, 2021
1 parent 151db77 commit 5bec709
Show file tree
Hide file tree
Showing 20 changed files with 269 additions and 220 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ config.json
docs/out

#ignore personal configs
config.json
monika.json
monika.postman_collection.json
#ignore databasefile
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ docker-rm: docker-stop
-docker rm $(IMAGE_NAME)

docker-run: docker-rm docker
docker run --name $(IMAGE_NAME) -v $(PWD)/monika.example.json:/config/monika.json --detach $(IMAGE_NAMESPACE)/$(IMAGE_NAME):$(COMMIT_ID)
docker run --name $(IMAGE_NAME) -v $(PWD)/monika.example.yml:/config/monika.yml --detach $(IMAGE_NAMESPACE)/$(IMAGE_NAME):$(COMMIT_ID)
7 changes: 7 additions & 0 deletions config_sample/config.desktop.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
probes:
- requests:
- url: http://github.com

notifications:
- id: desktop-notification
type: desktop
11 changes: 11 additions & 0 deletions config_sample/config.mailgun.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
probes:
- requests:
- url: http://github.com

notifications:
- id: unique-id-mailgun
type: mailgun
data:
recipients: [RECIPIENT_EMAIL_ADDRESS]
apiKey: YOUR_API_KEY
domain: YOUR_DOMAIN
9 changes: 9 additions & 0 deletions config_sample/config.monika-whatsapp.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
probes:
- requests:
- url: http://github.com

notifications:
- id: monika-webhook
type: monika-notif
data:
url: YOUR_MONIKA_WHATSAPP_WEBHOOK
11 changes: 11 additions & 0 deletions config_sample/config.sendgrid.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
probes:
- requests:
- url: http://github.com

notifications:
- id: unique-id-mailgun
type: mailgun
data:
recipients: [RECIPIENT_EMAIL_ADDRESS]
apiKey: YOUR_API_KEY
sender: YOUR_VERIFIED_EMAIL_BY_SENDGRID
9 changes: 9 additions & 0 deletions config_sample/config.slack.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
probes:
- requests:
- url: http://github.com

notifications:
- id: unique-id-slack
type: slack
data:
url: https://YOUR_SLACK_INCOMING_WEBHOOK_URL
13 changes: 13 additions & 0 deletions config_sample/config.smtp-gmail.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
probes:
- requests:
- url: http://github.com

notifications:
- id: unique-id-smtp
type: smtp
data:
recipients: [YOUR_EMAIL_ADDRESS_HERE]
hostname: smtp.gmail.com
port: 587
username: YOUR_GMAIL_ACCOUNT
password: YOUR_GMAIL_PASSWORD_OR_APP_PASSWORD
9 changes: 9 additions & 0 deletions config_sample/config.teams.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
probes:
- requests:
- url: http://github.com

notifications:
- id: unique-id-teams
type: type
data:
url: https://YOUR_TEAMS_WEBHOOK_URL
10 changes: 10 additions & 0 deletions config_sample/config.telegram.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
probes:
- requests:
- url: http://github.com

notifications:
- id: unique-id-telegram
type: telegram
data:
group_id: YOUR_GROUP_ID
bot_token: YOUR_BOT_TOKEN
9 changes: 9 additions & 0 deletions config_sample/config.webhook.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
probes:
- requests:
- url: http://github.com

notifications:
- id: unique-id-webhook
type: webhook
data:
url: https://YOUR_WEBHOOK_URL
12 changes: 12 additions & 0 deletions config_sample/config.whatsapp.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
probes:
- requests:
- url: http://github.com

notifications:
- id: unique-id-webhook
type: webhook
data:
recipients: [628123456789]
url: https://yourwhatsappapiserver.com
username: whatsappusername
password: whatsapppassword
10 changes: 10 additions & 0 deletions config_sample/config.workplace.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
probes:
- requests:
- url: http://github.com

notifications:
- id: unique-id-webhook
type: webhook
data:
thread_id: 12345678910
access_token: your_custom_integration_access_token
74 changes: 28 additions & 46 deletions docs/src/pages/guides/alerts.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,24 @@ id: alerts
title: Alerts
---

Alerts are the types of condition that will trigger Monika to send notification. It is an array located on probes defined in the config file `monika.json` like so.

```json
"probes": [
{
"id": "1",
"name": "Name of the probe",
"requests": [
Alerts are the types of condition that will trigger Monika to send notification. It is an array located on probes defined in the config file `monika.yml` like so.

```yml
probes: [
- id: 1
name: Name of the probe
requests: [
...
{
...
"alerts": [
{
"query": "response.size >= 10000",
"message": "Response size is {{ response.size }}, expecting less than 10000"
}
- alerts: [
query: response.size >= 10000
message: Response size is {{ response.size }} expecting less than 10000
]
}
],
"alerts": [
{
"query": "response.status != 200",
"message": "HTTP Status code is {{ response.status }}, expecting 200"
}
]
},
- alerts: [
query: response.status != 200
message: HTTP Status code is {{ response.status }} expecting 200
]
]
```

Expand All @@ -38,13 +30,9 @@ The `alerts` configuration can be put under `probe` or under each `requests` as

Query contains any arbitrary expression that will trigger alert when it returns a truthy value

```json
"alerts" : [
{
"query": "response.status == 500",
...
}
]
```yml
- alerts: [query: response.status == 500
...]
```
Inside the query expression you can get the response object.
Expand All @@ -61,24 +49,20 @@ The `response.headers` and `response.body` can be queried further with object ac

For example, to trigger alert when content-type is not json you may use

```json
"alerts" : [
{
"query": "response.headers['content-type'] != \"application/json\"",
```yml
alerts : [
- query: response.headers['content-type'] != "application/json"
...
}
]
```

Or to query value inside the body

```json
`json
"alerts" : [
{
"query": "response.body.data.todos[0].title != \"Drink water\"",
```yml
alerts : [
- query: response.body.data.todos[0].title != "Drink water"
...
}
]
```

Expand Down Expand Up @@ -147,12 +131,10 @@ There are also several helper functions available:

## Alert Message

```json
"alerts": [
{
"query": "response.status != 200",
"message": "HTTP Status code is {{ response.status }}, expecting 200"
}
```yml
alerts: [
- query: response.status != 200
message: HTTP Status code is different, expecting 200
]
```

Expand Down
18 changes: 9 additions & 9 deletions docs/src/pages/guides/cli-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ monika -h

## Configuration

Monika by default will look for the `monika.json` config file.
Monika by default will look for the `monika.yml` config file.
You may want to store different configurations for different environments or projects. This is straight forward by using the `-c` or `--config` flag followed by the filename.

```bash
monika --config staging-set.json
monika --config staging-set.yml
```

Configuration files may be placed remotely which you can specify using the same flag and using a URI.

```bash
monika -c https://raw.githubusercontent.com/hyperjumptech/monika/main/config_sample/config.desktop.example.json
monika -c https://raw.githubusercontent.com/hyperjumptech/monika/main/config_sample/config.desktop.example.yml
```

A neat feature is that the configuration file will be re-read and monitoring updated if Monika detects any changes to it.
Expand All @@ -36,21 +36,21 @@ Just starting out? Want to make a new configuration? The `--create-config` flag
monika --create-config
```

As an alternative, the generator is able to read HAR or postman files as input to convert into monika.json configuration files.
As an alternative, the generator is able to read HAR or postman files as input to convert into monika.yml configuration files.

Use the `--har` or the `--postman` in combination with `--create-config` on the command line to convert those files.

```bash
monika --create-config --har myfile.har
```

The above example creates a config file from an existing HAR archive. Auto generated files defaults to 'monika.json'. Use the `-o` output flag to specify another name.
The above example creates a config file from an existing HAR archive. Auto generated files defaults to 'monika.yml'. Use the `-o` output flag to specify another name.

```bash
monika --create-config --postman mypostman.json -o new-monika.json
monika --create-config --postman mypostman.json -o new-monika.yml
```

When generating config files, if an existing monika.json file already exist, the user is prompted before overwriting. To bypass the user prompt, use the `--force` flag.
When generating config files, if an existing monika.yml file already exist, the user is prompted before overwriting. To bypass the user prompt, use the `--force` flag.

## Force

Expand All @@ -72,7 +72,7 @@ You use the `-H` or `--har` to specify a HAR file.
monika -H my-file.har
```

You can use the combination of --create-config and --har flags to convert the HAR archive into to a monika.json configuration file.
You can use the combination of --create-config and --har flags to convert the HAR archive into to a monika.yml configuration file.

Please note, HAR files may contain sensitive information, use caution when distributing HAR filles.

Expand Down Expand Up @@ -110,7 +110,7 @@ Have an existing request on postman you want to automate? Monika supports readin
monika -p postman.json
```

You can use the combination of `--create-config` and `--postman` flags to convert the postman files to a monika.json config file.
You can use the combination of `--create-config` and `--postman` flags to convert the postman files to a monika.yml config file.

## Prometheus

Expand Down
Loading

0 comments on commit 5bec709

Please sign in to comment.