monika icon indicating copy to clipboard operation
monika copied to clipboard

Use fakes in the handlebar template

Open nicnocquee opened this issue 2 years ago • 0 comments

As mentioned in this discussion, it'd be great if we can use some variables in header, url, and body. For example,

probes:
  - id: '1'
    name: 'Example: get Time'
    description: Probe
    interval: 10 # in seconds
    requests:
      - method: POST
        url: https://mybackend.org/user/login?time={{ timestamp() }} # replace timestamp with the actual timestamp when the request is sent
        timeout: 7000 # in milliseconds
        saveBody: true
        headers:
          Authorization: Bearer {{ alphaNumeric(30) }} # generate a random alpha numeric string
        body:
          username: {{ exampleEmail() }} # generate a random email address
          password: {{ {{ words(3) }} }} # generate 3 random words
        alerts:
          - query: response.status != 200
            message: Status not 2xx
    incidentThreshold: 3
    recoveryThreshold: 3
    alerts:
      - query: response.status != 200
        message: HTTP response status is {{ response.status }}, expecting 200

So, we should add the following features:

  • [ ] Allow using timestamp() in the handlebar template. This will be replaced with the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
  • [ ] Allow using any functions from fakerjs. For example, {{ uuid() }} will call faker.datatype.uuid() from fakerjs.
  • [ ] When the function is not recognized (not timestamp() nor any functions from fakerjs, Monika should show error.

nicnocquee avatar Aug 12 '22 09:08 nicnocquee