After having been using this this CLI project for a while I thought, why not turn it into a function?
The structure of this project is based on [OpenFaaS with MongoDB] (https://github.com/alexellis/mongodb-function) from @alexellisuk
- Clone this repository
$ git clone https://github.com/padiazg/of-fn-calls-per-period.git
-
Replace "padiazg/" prefix from Docker Hub in stack.yml with your own account
-
Build/deploy Create new function, make sure to specify
call-count
as the name of your function.
$ faas-cli new call-count --lang node
Now you can build/deploy
faas-cli build && faas-cli deploy
- Create deploy.yml
provider:
name: faas
gateway: http://127.0.0.1:8080
functions:
calls-per-period:
image: padiazg/of-fn-calls-per-period
environment:
write_timeout: 10s
read_timeout: 10s
prometheus: http://your_prometheus_ip:9090
timezone: America/Asuncion # here you sould put your timezone
- Deploy with faas-cli Deploy your function using faas-cli
faas-cli deploy
Parameters must be passed in JSON format:
Examples:
{"start": "2018-03-30", "end": "2018-07-31"}
{"start": "2018-03-30", "end": "2018-07-31", "format": "json"}
{"start": "2018-03-30", "end": "2018-07-31", "step": "3h", "format": "table"}
- start: Start day for the query (mandatory).
- end: End day for the query (mandatory).
- step: Period of time in wich the results are grouped.
- format: Format of the output. Defaults to 'table'.
Posible values are:- table
- json
Output as ascii-table.
Output as JSON.