@@ -11,7 +11,9 @@ You can simply run this script after installing requirements (`pip3 install -r r
This bot use a JSON file to get some different configuration variables it needs. An example of this file is provided under `config/config_example.json` and need to be copy (and modified) as `config/config.json`. This file contains InfluxDB connection information and configuration needed for each module (Etherpad, Mattermost, etc. see `Modules` section).
#### InfluxDB
Configuration for InfluxDB is under the `influxdb` key. It is a simple object with following subkeys :
-`url` : complete URL to connect to InfluxDB (eg. `https://my.influxinstance.tld`)
-`user` : A user with write access to InfluxDB
-`password` : Password for the user
...
...
@@ -34,6 +36,7 @@ Etherpad module allow to get the number of pads of your Etherpad instances. It o
#### Configuration
To enable Etherpad module, you need to add an `etherpad` key to the `modules` object inside configuration JSON file. The value should be like this :
```json
"etherpad":[
{
...
...
@@ -48,11 +51,12 @@ Pay attention that it is a **list** of objects (wich contains URL and name of yo
#### Metrics
Etherpad module exports following metrics :
-`etherpad_pads_count` : Number of pads on the instance
-`etherpad_blank_pads_count` : Number of blank pads on the instance
-`etherpad_total_users` : Number of connected users
Each metric have a `name` tag with the name of the instance.
Each metric have a `name` tag with the name of the instance.
### Mattermost
...
...
@@ -61,6 +65,7 @@ Mattermost module collects several metrics from the Mattermost API `/analytics/o
#### Configuration
To enable Mattermost module, you need to add a `mattermost` key to the `modules` object inside configuration JSON file. The value should be like this :
```json
"mattermost":[
{
...
...
@@ -77,6 +82,7 @@ Pay attention that it is a **list** of objects (wich contains URL, credentials a
#### Metrics
Mattermost module exports following metrics :
-`mattermost_public_channels_count` : Number of public channels on the instance
-`mattermost_private_channels_count` : Number of private channels on the instance
-`mattermost_posts_count` : Number of posts on the instance
...
...
@@ -84,6 +90,7 @@ Mattermost module exports following metrics :
-`mattermost_teams_count` : Number of teams created on the instance
-`mattermost_daily_posts` : Number of posts created on a day
-`mattermost_daily_users` : Number of users that write a post on a day
Each metric have a `name` tag with the name of the instance.
### Wekan
...
...
@@ -93,6 +100,7 @@ Wekan module collects several metrics from the [Wekan API](https://wekan.github.
#### Configuration
To enable Wekan module, you need to add a `wekan` key to the `modules` object inside configuration JSON file. The value should be like this :
```json
"wekan":[
{
...
...
@@ -109,11 +117,12 @@ Pay attention that it is a **list** of objects (wich contains URL, credentials a
#### Metrics
Mattermost module exports following metrics :
-`wekan_total_users` : Number of users on the instance
-`wekan_public_boards` : Number of public boards on the instance
-`wekan_private_boards` : Number of private channels on the instance
Each metric have a `name` tag with the name of the instance.
Each metric have a `name` tag with the name of the instance.
## Creating a module
...
...
@@ -126,24 +135,27 @@ Your module should be a, local, Python package with the name of your service. Fo
### Methods
Your module have to export a single Python class (let's say `PeertubeCollector`) that contains at least two methods :
-`init` : The function called during object instanciation. This function will receive the entire configuration for your module from the configuration file.
-`collect` : A function called by the main script that have to return a list of correct InfluxDB metrics
Except of those two methods, you can do whatever you want inside the module.
### Metrics format
The `collect` methods have to return a list of InfluxDB metric. A InfluxDB metric is a dict like this one :
```json
{
"measurement":"name_of_your_metric",
"tags":{
"tag1key":"tag1value",
"tag2key":"tag2value"
},
"time":1537193258183,
"fields":{
"value":15
}
"measurement":"name_of_your_metric",
"tags":{
"tag1key":"tag1value",
"tag2key":"tag2value"
},
"time":1537193258183,
"fields":{
"value":15
}
}
```
...
...
@@ -154,6 +166,7 @@ The `fields.value` value is your metric value. The `time` value **must be** a ti
When your package is ready, you can add it to the `main.py` script. First, import it at the beginning with `from modulename import ModuleCollector` (eg. `from peertube import PeertubeCollector`).
Then add few lines to the `main` function to call your module **only when it is enable in the configuration file**. You should check that there is your module on the `modules` object from configuration file, and give the configuration to your class initializer. For example, you can imagine something like this :
@@ -166,6 +179,7 @@ if 'peertube' in config['modules']:
It is important to add some documentation in order to use your module. First, add a configuration example inside the `config/config_example.json` file.
Then write some documentation inside this README file with at least :
- quick description of your module
- an example of configuration with some explanations
- the list of metrics and associated tags that are collect by the module