Commit 7213416c authored by Combava Orange's avatar Combava Orange
Browse files

[clea]docker-compose with grafana

parent 806a55c1
version: "3.8"
services:
grafana:
image: grafana/grafana:7.5.0
ports:
- "3000:3000"
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning
- ./grafana/dashboards:/var/lib/grafana/dashboards
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
# interval: 30s
# timeout: 20s
# retries: 3
networks:
- clea-network
networks:
clea-network:
driver: bridge
name: clea-network
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"iteration": 1618568045661,
"links": [],
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "cleadb",
"description": "",
"fieldConfig": {
"defaults": {},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 0
},
"hiddenSeries": false,
"id": 2,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.5.0",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"format": "time_series",
"group": [
{
"params": [
"$__interval",
"none"
],
"type": "time"
}
],
"metricColumn": "none",
"rawQuery": false,
"rawSql": "SELECT\n $__timeGroupAlias(period,$__interval),\n sum(backward_visits) AS \"backward_visits\",\n sum(forward_visits) AS \"forward_visits\"\nFROM stat_location\nWHERE\n $__timeFilter(period) AND\n venue_type IN ($venueType) AND\n venue_category1 IN ($venueCateg1) AND\n venue_category2 IN ($venueCateg2)\nGROUP BY 1\nORDER BY 1",
"refId": "A",
"select": [
[
{
"params": [
"backward_visits"
],
"type": "column"
},
{
"params": [
"sum"
],
"type": "aggregate"
},
{
"params": [
"backward_visits"
],
"type": "alias"
}
],
[
{
"params": [
"forward_visits"
],
"type": "column"
},
{
"params": [
"sum"
],
"type": "aggregate"
},
{
"params": [
"forward_visits"
],
"type": "alias"
}
]
],
"table": "stat_location",
"timeColumn": "period",
"timeColumnType": "timestamptz",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
},
{
"datatype": "int4",
"name": "",
"params": [
"venue_type",
"IN",
"($venueType)"
],
"type": "expression"
},
{
"datatype": "int4",
"name": "",
"params": [
"venue_category1",
"IN",
"($venueCateg1)"
],
"type": "expression"
},
{
"datatype": "int4",
"name": "",
"params": [
"venue_category2",
"IN",
"($venueCateg2)"
],
"type": "expression"
}
]
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Nombre Visites",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
}
],
"schemaVersion": 27,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
"allValue": null,
"current": {
"selected": true,
"text": "All",
"value": "$__all"
},
"datasource": "cleadb",
"definition": "select distinct venue_type from stat_location order by venue_type",
"description": null,
"error": null,
"hide": 0,
"includeAll": true,
"label": "Type",
"multi": false,
"name": "venueType",
"options": [],
"query": "select distinct venue_type from stat_location order by venue_type",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
"allValue": null,
"current": {
"selected": false,
"text": "All",
"value": "$__all"
},
"datasource": "cleadb",
"definition": "select distinct(venue_category1) from stat_location where venue_type IN($venueType) order by venue_category1",
"description": null,
"error": null,
"hide": 0,
"includeAll": true,
"label": "categ1",
"multi": false,
"name": "venueCateg1",
"options": [],
"query": "select distinct(venue_category1) from stat_location where venue_type IN($venueType) order by venue_category1",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
"allValue": null,
"current": {
"selected": false,
"text": "2",
"value": "2"
},
"datasource": "cleadb",
"definition": "select distinct(venue_category2) from stat_location where venue_type in ($venueType) and venue_category1 in ($venueCateg1) order by venue_category2",
"description": null,
"error": null,
"hide": 0,
"includeAll": true,
"label": "Categ2",
"multi": false,
"name": "venueCateg2",
"options": [],
"query": "select distinct(venue_category2) from stat_location where venue_type in ($venueType) and venue_category1 in ($venueCateg1) order by venue_category2",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
},
"time": {
"from": "now-7d",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Statistiques par type de lieu",
"uid": "agoTj7uGz",
"version": 1
}
\ No newline at end of file
apiVersion: 1
providers:
# <string> an unique provider name. Required
- name: 'imported'
# <int> Org id. Default to 1
orgId: 1
# <string> name of the dashboard folder.
folder: 'General'
# <string> provider type. Default to 'file'
type: file
# <bool> disable dashboard deletion
disableDeletion: false
# <int> how often Grafana will scan for changed dashboards
updateIntervalSeconds: 10
# <bool> allow updating provisioned dashboards from the UI
allowUiUpdates: false
options:
# <string, required> path to dashboard files on disk. Required when using the 'file' type
path: /var/lib/grafana/dashboards
# <bool> use folder names from filesystem to create folders in Grafana
foldersFromFilesStructure: true
# config file version
apiVersion: 1
# list of datasources that should be deleted from the database
deleteDatasources:
- name: cleadb
orgId: 1
# list of datasources to insert/update depending
# what's available in the database
datasources:
- name: cleadb
type: postgres
access: proxy
orgId: 1
url: postgres:5432
user: username
database: cleadb
jsonData:
sslmode: disable
secureJsonData:
password: password
# Grafana overrides for clea
This stack extends the default Clea stack by adding a grafana container configured with:
* a datasource to Postgres cleaDB
* a dashboard for location statistiques.
## launch the stack
Full stack
```bash
$ clea -o grafana up
```
Minimal stack
```bash
$ clea -o grafana up postgres grafana
```
## Accessing grafana
Navigating with a browser to *http://localhost:3000* will open the grafana login page.
The first time the stack is started, the credentials to used are:
* username: admin
* password: admin
Then you are asked to change the default one.
## provisioned objects
The left panel display functionalities : "Search", "Create", "Dashboards", "Explore", "Alerting", "Configuration" and "Server Admin".
Clicking in the "Data-sources" sub-menu of the "Configuration" menu, you should see a "cleadb" datasource.
Clicking in the "Manage" sub-menu of the "Dashboards" menu, you should see a Folder "General" with a dashboard "Statistiques par type de lieu".
You should be able to click on it to open the dashboard and explore datas.
## Mocking Data:
Until the *"stat_location"* table is filled by the component "clea-venue-consumer", the next SQL instruction can be used to fill the table with mock datas from *Exposed_visits* table.
(Nota: 2208988800 is the number of seconds between NTP epoch (1/1/1900) and Unix epoch (1/1/1970))
```bash
TRUNCATE TABLE stat_location;
INSERT INTO stat_location
SELECT to_timestamp(period_start-2208988800) AS periode, venue_type, venue_category1, venue_category2, sum(backward_visits) as backward_visits, sum(forward_visits) as forward_visits
FROM exposed_visits
WHERE timeslot=0 AND (backward_visits>0 OR forward_visits>0)
GROUP BY periode,venue_type, venue_category1, venue_category2
ORDER BY periode
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment