User manual for DBoT project
- authenticator: PasswordAuthenticator
- roles_validity_in_ms: 0
- roles_update_interval_in_ms: 0
- credentials_validity_in_ms: 0
- credentials_update_interval_in_ms: 0
- authorizer: CassandraAuthorizer
- git clone this repository
- go to /PI2021Django/
- run $ docker-compose up --force-recreate --build
- go to /PI2021Django/Project/settings.py and change "ALLOWED_HOSTS = ['127.0.0.1']"
- Also in settings.py, in "DATABASES" change 'HOST': '127.0.0.1'
- In /PI2021Django/docker-compose.yml change "127.0.0.1:8000"
-
Go to port 3000 (http://localhost:3000/ or http://10.0.12.65:3000/)
-
Login (if asked to) with username: "admin", password: "admin"
-
Go to "Configuration" -> "Data Sources"
-
Click "Add data source" and search for "JSON"
-
In "url" put http://10.0.12.65:3000/str:user_token/grafana where "str:user_token" is the current token you have when you logged in the application
-
Click "Save & Test", a message should appear saying "Data source is working"
-
Go to "Create" -> "Dashboard" and click "Add an empty panel"
-
Click in "Metric" and choose your metric (example: "1.temperature")
-
Above the graphic, choose your time range
-
On the top right corner click "Apply"
-
Create or edit a dashboard
-
On the top right corner click on the icon to open dashboard settings
-
Go to "Variables" and click "Add variable"
-
In "Type" instead of query choose "Ad hoc filters"
-
Click "update" and go back to the dashboard edit panel
-
On the top left corner click on the "+" icon and choose an attribute (ex: "temperature")
-
Choose an operator (ex: "=") and type a select value (ex: "10")
-
The graphic should now only show values within the conditions of that new ad hoc filter added
Register new user (POST): {"name","email","password"}
/register_user
POST data example:
{"name":"test","email":"[email protected]","password":"randpassword"}
Authenticate user (POST): {"email","password"}
/authenticate_user
POST data example:
{"email":"[email protected]","password":"randpassword"}
Logout user (GET) where str:user_token is the token given upon login
/logout_user/<str:user_token>
Insert data into user database (POST) where str:user_token is the token given upon login and str:sensorid is the sensorid where the data will be bound to
/insert_into_db/<str:user_token>/<str:sensorid>
POST data example:
{"sensorid":"0001","temperature":"10","timestamp":"2020-06-01 00:02:10"}
or
[{"sensorid":"0001","temperature":"10","timestamp":"2020-06-01 00:02:10"},{"sensorid":"0001","temperature":"20","timestamp":"2020-06-02 00:02:10"}]
Query data from user database (POST) where str:user_token is the token given upon login and str:sensorid is the sensorid where the data will be queried from. If the sensorid given is "all" then the query will target all the sensor ids from the user database: {"conditions","attributes","from_ts","to_ts"}
/query_db/<str:user_token>/<str:sensorid>
POST data example:
- Multiple conditions can be given
- "attributes" is the values the query will return
- If from_ts is empty, then it will query data from all timestamps
{"conditions":[["temperature",">","5"]],"attributes":["temperature"],"from_ts":"","to_ts":""}
or
{"conditions":[["temperature",">","5"],["temperature","<=","10"]],"attributes":["temperature"],"from_ts":"2020-05-31","to_ts":"2020-06-02"}
Get all attributes from user database (GET) where str:user_token is the token given upon login
/get_all_attributes/<str:user_token>
Test connection where str:user_token is the token given upon login
/<str:user_token>/grafana
Return available metrics when invoked (Dropdown Metrics when editing a dashboard) where str:user_token is the token given upon login
/<str:user_token>/grafana/search
Return data based on input (data showed in graphic based on metric chosen, date range and ad hoc filters) where str:user_token is the token given upon login
/<str:user_token>/grafana/query
Return annotations where str:user_token is the token given upon login
/<str:user_token>/grafana/annotations
Return tag keys for ad hoc filters where str:user_token is the token given upon login
/<str:user_token>/grafana/tag-keys
Return tag vaues for ad hoc filters where str:user_token is the token given upon login
/<str:user_token>/grafana/tag-values