|
| 1 | + |
| 2 | +# collector |
| 3 | + |
| 4 | +This is a data collector for gathering statistics from other Arrowwhead systems. |
| 5 | +The collected samples will then be sent to an InfluxDB instance, which can present |
| 6 | +the data as pretty graphs for example. |
| 7 | + |
| 8 | +## Setup |
| 9 | + |
| 10 | +This requires a locally running InfluxDB instance. |
| 11 | + |
| 12 | +The easiest way to run everything is by using the provided `docker-compose.yml` |
| 13 | +file in the root folder of this repository. Copy the file and update the settings |
| 14 | +to your liking. For example, it would be a good idea to change the name and password |
| 15 | +of the InfluxDB administrator. |
| 16 | + |
| 17 | +Next, you have to run the collector system once to generate a new default config |
| 18 | +file and letting InfluxDB run it's setup. |
| 19 | +This can be done by running `docker-compose up`. |
| 20 | + |
| 21 | +*Note that the collector will print an error and quit, which may look confusing but |
| 22 | +it was simply generating a new config.* |
| 23 | + |
| 24 | +Clean up the containers by running `docker-compose down`. |
| 25 | + |
| 26 | +Edit the config file located at `./data/collector/systemconfig.json`. |
| 27 | +The Influx settings should reflect the settings used in `docker-compose.yml`. |
| 28 | +The authorisation token for Influx's API can be found in `./data/influxdb/config/influx-configs`. |
| 29 | +A default set of sampled services has been provided by default, make any required |
| 30 | +changes that reflects your own setup. |
| 31 | + |
| 32 | +## Running |
| 33 | + |
| 34 | +When the setup have been performed, you can run the docker containers again. |
| 35 | +You can browse and login to InfluxDB by visiting `http://localhost:8086/`. |
| 36 | + |
| 37 | +- Running systems in the background: `docker-compose up -d` |
| 38 | +- Stopping all systems: `docker-compose down` |
| 39 | +- Show the system logs: `docker-compose logs` |
| 40 | +- Show live logs: `docker-compose --tail 100 -f` |
| 41 | + |
| 42 | +## Design |
| 43 | + |
| 44 | +The following sequence diagram documents the work flows this system performs |
| 45 | +while running and how it interacts with the other Arrowhead systems and InfluxDB. |
| 46 | + |
| 47 | +```mermaid |
| 48 | +sequenceDiagram |
| 49 | +participant sr as ServiceRegistrar |
| 50 | +participant or as Orchestrator |
| 51 | +participant col as collector |
| 52 | +participant sys as Any Arrowhead System |
| 53 | +participant inf as InfluxDB |
| 54 | +
|
| 55 | +loop Before registration expiration |
| 56 | + activate col |
| 57 | + col->>+sr: Register system |
| 58 | + sr-->>-col: New expiration time |
| 59 | + deactivate col |
| 60 | +end |
| 61 | +
|
| 62 | +loop Every x period |
| 63 | + alt Service location is unknown |
| 64 | + activate col |
| 65 | + col->>+or: Discover service provider |
| 66 | + activate or |
| 67 | + or->>+sr: Query for service |
| 68 | + sr-->>-or: Return service location |
| 69 | + or-->>col: Forward service location |
| 70 | + deactivate or |
| 71 | + deactivate col |
| 72 | + end |
| 73 | +
|
| 74 | + activate col |
| 75 | +
|
| 76 | + loop For each wanted service |
| 77 | + col->>sys: Get statistics from service |
| 78 | + activate sys |
| 79 | + sys-->>col: Return latest data |
| 80 | + deactivate sys |
| 81 | + col->>col: Cache sampled data |
| 82 | + end |
| 83 | +
|
| 84 | + col->>inf: Batch send the cached data |
| 85 | + activate inf |
| 86 | + inf-->>col: ok |
| 87 | + deactivate inf |
| 88 | +
|
| 89 | + deactivate col |
| 90 | +end |
| 91 | +``` |
0 commit comments