From 13110681033f3272774f34bc78be7dd95212232b Mon Sep 17 00:00:00 2001 From: medina5 Date: Tue, 14 Oct 2025 21:11:54 +0200 Subject: [PATCH] postgREST : OK --- .env.example | 15 +- README.md | 2 +- compose.yaml | 62 +- couchdb.http | 41 + data/index.html | 24 +- grafana/dashboards/docker.json | 145 ++ grafana/dashboards/docker_old.json | 1563 +++++++++++++++++ grafana/provisioning/dashboards/providers.yml | 11 + postgis/postgis.sql | 2 + .../11_postgraphile.sql | 3 +- postgresql-entrypoint-initdb.d/1_initdb.sql | 7 +- postgrest.http | 4 + prometheus.yml | 22 + 13 files changed, 1854 insertions(+), 47 deletions(-) create mode 100644 couchdb.http create mode 100644 grafana/dashboards/docker.json create mode 100644 grafana/dashboards/docker_old.json create mode 100644 grafana/provisioning/dashboards/providers.yml create mode 100644 postgrest.http create mode 100644 prometheus.yml diff --git a/.env.example b/.env.example index aa0383b..76098e9 100644 --- a/.env.example +++ b/.env.example @@ -1,9 +1,20 @@ +# PostgreSQL PG_PASSWORD=!ChangeMe! #pgAdmin -ADMIN_EMAIL=user@email.org -ADMIN_PASSWORD=!ChangeMe! +PGADMIN_EMAIL=user@email.org +PGADMIN_PASSWORD=!ChangeMe! # CouchDB COUCHDB_USER=admin COUCHDB_PASSWORD=!ChangeMe! + +# MongoDB +MONGODB_USER=admin +MONGODB_PASSWORD=!ChangeMe! + +# Redis +REDIS_PASSWORD=!ChangeMe! + +# Neo4J +NEO4J_PASSWORD=!ChangeMe! diff --git a/README.md b/README.md index 7c636ed..750f86b 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Les solutions pour réaliser un reverse proxy sont généralement [Traefik](http **Caddy** se démarque par sa grande simplicité : il se configure presque entièrement à partir de labels Docker et gère automatiquement la création de certificat HTTPS, ce qui le rend idéal pour les environnements de développement ou les projets personnels. -**Traefik**, de son côté, est plus complet et mieux adapté aux environnements de production complexes : il offre un tableau de bord intégré, une gestion fine du routage, et s’intègre parfaitement avec des orchestrateurs comme Docker Swarm ou Kubernetes. +**Traefik**, de son côté, est plus complet et mieux adapté aux environnements de production complexes : il offre une gestion fine du routage, et s’intègre parfaitement avec des orchestrateurs comme Docker Swarm ou Kubernetes. **Nginx Proxy Manager** propose une approche visuelle grâce à son interface web d’administration. Il est apprécié des utilisateurs qui préfèrent tout configurer par le navigateur, mais il reste moins automatisé que Caddy et moins flexible que Traefik pour les infrastructures dynamiques. diff --git a/compose.yaml b/compose.yaml index 5370a12..a632b34 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,10 +1,9 @@ services: # ---------------------------------------------------------------------- -# Proxy +# Proxy inverse # # ---------------------------------------------------------------------- - # Caddy # Web server, load balancer, and reverse proxy # https://caddyserver.com/ @@ -27,8 +26,8 @@ services: labels: caddy: "static.localhost" caddy.root: "* /srv/www" - caddy.file_server: "" - caddy.tls: internal + caddy.file_server: "" # Active le serveur de fichiers statiques + caddy.tls: internal # HTTPS auto-signé géré par Caddy whoami: image: traefik/whoami @@ -45,7 +44,6 @@ services: # Base de données relationnelles # # ---------------------------------------------------------------------- - database: image: iut/pgsql:2025-12 environment: @@ -58,6 +56,8 @@ services: - ./data:/tmp:z ports: - "5432:5432" + networks: + - caddy_net healthcheck: test: ["CMD", "pg_isready", "--username", "${COMPOSE_PROJECT_NAME}", "--dbname", "${COMPOSE_PROJECT_NAME}"] interval: 10s @@ -65,15 +65,20 @@ services: retries: 5 start_period: 20s +# ---------------------------------------------------------------------- +# Administration +# +# ---------------------------------------------------------------------- # pgAdmin # Rich administration and development platform for PostgreSQL. # https://www.pgadmin.org/ - pgadmin: image: dpage/pgadmin4:9.8 depends_on: database: condition: service_healthy + caddy: + condition: service_started restart: "no" configs: - source: pgadmin_config @@ -95,7 +100,6 @@ services: # Documents # # ---------------------------------------------------------------------- - # CouchDB # Single-node document database # https://couchdb.apache.org/ @@ -103,11 +107,13 @@ services: image: couchdb:3.5 volumes: - couchdb_data:/opt/couchdb/data - ports: - - "5984:5984" environment: COUCHDB_USER: ${COUCHDB_USER} COUCHDB_PASSWORD: ${COUCHDB_PASSWORD} + labels: + caddy: couchdb.localhost + caddy.reverse_proxy: "{{upstreams 5984}}" + caddy.tls: internal # MongoDB # @@ -152,19 +158,23 @@ services: neo4j: image: neo4j:5.26.12-community ports: - - 7474:7474 - 7687:7687 volumes: - neo4j_data:/data - neo4j_logs:/logs environment: NEO4J_dbms_connector_https_enabled: "false" - NEO4J_AUTH: neo4j/${DB_ROOT_PASSWORD:-!ChangeMe!} + NEO4J_AUTH: neo4j/${NEO4J_PASSWORD:-!ChangeMe!} + networks: + - caddy_net + labels: + caddy: neo4j.localhost + caddy.reverse_proxy: "{{upstreams 7474}}" + caddy.tls: internal # PostGraphile # Instant GraphQL API # https://www.graphile.org/postgraphile/ - postgraphile: image: iut/postgraphile:2025-12 restart: "no" @@ -182,25 +192,23 @@ services: "--append-plugins", "postgraphile-plugin-connection-filter,postgraphile-plugin-fulltext-filter,@graphile/postgis,postgraphile-plugin-connection-filter-postgis" ] - ports: - - 3006:5000 networks: - caddy_net environment: - - PGHOST=${POSTGRAPHILE_HOST:-postgresql} + - PGHOST=${POSTGRAPHILE_HOST:-database} - PGPORT=${POSTGRAPHILE_DB_PORT:-5432} - PGUSER=${POSTGRAPHILE_DB_USER:-postgraphile} - - PGPASSWORD=${DB_PASSWORD:-!ChangeMe!} + - PGPASSWORD=${POSTGRAPHILE_PASSWORD:-9013} - PGDATABASE=${COMPOSE_PROJECT_NAME} labels: caddy: postgraphile.localhost caddy.reverse_proxy: "{{upstreams 5000}}" caddy.tls: internal + # ---------------------------------------------------------------------- # Web API # # ---------------------------------------------------------------------- - # PostgREST # Serve a fully RESTful API from any existing PostgreSQL database. # It provides a cleaner, more standards-compliant, faster API than you are likely to write from scratch. @@ -211,11 +219,13 @@ services: depends_on: database: condition: service_healthy + caddy: + condition: service_started command: postgrest environment: PGRST_DB_URI: postgres://${POSTGREST_USER:-postgrest}:${POSTGREST_PASSWORD}@${POSTGREST_HOST:-database}:${POSTGREST_DB_PORT:-5432}/${COMPOSE_PROJECT_NAME} PGRST_DB_SCHEMAS: ${POSTGREST_DB_SCHEMAS:-public} - PGRST_DB_ANON_ROLE: ${POSTGREST_DB_ANON_ROLE:-role_web} + PGRST_DB_ANON_ROLE: ${POSTGREST_DB_ANON_ROLE:-anonyme} PGRST_JWT_SECRET: ${POSTGREST_JWT_SECRET:-ChangeMeChangeMeChangeMeChangeMe} PGRST_ADMIN_SERVER_PORT: 3055 PGRST_SERVER_PORT: 80 @@ -236,7 +246,7 @@ services: API_REFERENCE_CONFIG: | { "sources":[ - { "url": "https://postgrest/?format=json" } + { "url": "https://postgrest.localhost" } ], "theme": "purple" } @@ -354,11 +364,11 @@ services: caddy: rabbitmq.localhost caddy.reverse_proxy: "{{upstreams 15672}}" caddy.tls: internal + # ---------------------------------------------------------------------- # Observabilité - Télémétrie # # ---------------------------------------------------------------------- - # Grafana # Open source analytics & monitoring solution for every database. # https://grafana.com/ @@ -370,8 +380,8 @@ services: limits: memory: 100M configs: - - source: grafana_datasources - target: /etc/grafana/provisioning/datasources + - source: grafana_provisioning + target: /etc/grafana/provisioning - source: grafana_dashboards target: /etc/grafana/dashboards volumes: @@ -428,12 +438,12 @@ volumes: configs: pgadmin_config: file: ./pgadmin-servers.json - grafana_datasources: - file: ./grafana/provisionning/datasources + grafana_provisioning: + file: ./grafana/provisioning grafana_dashboards: - file: ./grafana/provisionning/dashboards + file: ./grafana/dashboards prometheus_config: - file: ./prometheus + file: ./prometheus.yml networks: caddy_net: diff --git a/couchdb.http b/couchdb.http new file mode 100644 index 0000000..ff2ce40 --- /dev/null +++ b/couchdb.http @@ -0,0 +1,41 @@ +@couchDB = http://{{$dotenv COUCHDB_USER}}:{{$dotenv COUCHDB_PASSWORD}}@couchdb.localhost + +GET {{couchDB}}/_all_dbs + +### Creates a new database. +PUT {{couchDB}}/db + +### Creates a new document in the specified database, using the supplied JSON document structure. +POST {{couchDB}}/db +Accept: application/json +Content-Type: application/json + +{ + "servings": 4, + "subtitle": "Delicious with fresh bread", + "title": "Fish Stew" +} + +### +GET {{couchDB}}/db/_all_docs + +### +GET {{couchDB}}/db/74913d6d85b8af1d174baf3fe5000507 + +### +POST {{couchDB}}/db/_find +Accept: application/json +Content-Type: application/json +Content-Length: 168 +Host: localhost:5984 + +{ + "selector": { + "year": {"$gt": 2010} + }, + "fields": ["_id", "_rev", "year", "title"], + "sort": [{"year": "asc"}], + "limit": 2, + "skip": 0, + "execution_stats": true +} diff --git a/data/index.html b/data/index.html index 6618d8c..361050e 100644 --- a/data/index.html +++ b/data/index.html @@ -1,7 +1,7 @@ - + - Scalar API Reference + Base de données -
+

Base de données

- - - - - + diff --git a/grafana/dashboards/docker.json b/grafana/dashboards/docker.json new file mode 100644 index 0000000..d869fa1 --- /dev/null +++ b/grafana/dashboards/docker.json @@ -0,0 +1,145 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": 2, + "links": [], + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "rate(process_cpu_seconds_total[$__rate_interval])", + "fullMetaSearch": false, + "includeNullMetadata": false, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Panel Title", + "type": "timeseries" + } + ], + "schemaVersion": 39, + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-15m", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "30s", + "1m", + "5m" + ] + }, + "timezone": "browser", + "title": "Docker", + "uid": "edt08ssgt6v40e", + "version": 4, + "weekStart": "" +} \ No newline at end of file diff --git a/grafana/dashboards/docker_old.json b/grafana/dashboards/docker_old.json new file mode 100644 index 0000000..91b273c --- /dev/null +++ b/grafana/dashboards/docker_old.json @@ -0,0 +1,1563 @@ +{ + "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__requires": [ + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "" + }, + { + "type": "panel", + "id": "table", + "name": "Table", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "3.1.1" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + } + ], + "id": null, + "title": "Docker Host & Container Overview", + "tags": [], + "style": "dark", + "timezone": "browser", + "editable": true, + "hideControls": false, + "sharedCrosshair": true, + "rows": [ + { + "collapse": false, + "editable": true, + "height": 143.625, + "panels": [ + { + "aliasColors": { + "SENT": "#BF1B00" + }, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 5, + "grid": { + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 19, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 1, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 2, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(container_network_receive_bytes_total{id=\"/\"}[$interval])) by (id)", + "intervalFactor": 2, + "legendFormat": "RECEIVED", + "refId": "A", + "step": 4 + }, + { + "expr": "- sum(rate(container_network_transmit_bytes_total{id=\"/\"}[$interval])) by (id)", + "hide": false, + "intervalFactor": 2, + "legendFormat": "SENT", + "refId": "B", + "step": 4 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Network Traffic on Node", + "tooltip": { + "msResolution": true, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "transparent": false, + "type": "graph", + "xaxis": { + "show": false + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + "Ops-Infrastructure": "#447EBC", + "{}": "#DEDAF7" + }, + "bars": true, + "datasource": "${DS_PROMETHEUS}", + "decimals": 0, + "editable": true, + "error": false, + "fill": 3, + "grid": { + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 7, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": false, + "linewidth": 3, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 10, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 1.9899973849372385, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "count(rate(container_last_seen{name=~\".+\",container_group=\"monitoring\"}[$interval]))", + "intervalFactor": 2, + "legendFormat": "Monitoring", + "metric": "container_last_seen", + "refId": "A", + "step": 4 + }, + { + "expr": "count(rate(container_last_seen{name=~\".+\",container_group=\"ops-infrastructure\"}[$interval]))", + "hide": false, + "intervalFactor": 2, + "legendFormat": "Backend-Infrastructure", + "refId": "B", + "step": 4 + }, + { + "expr": "count(rate(container_last_seen{name=~\".+\",container_group=\"backend-infrastructure\"}[$interval]))", + "hide": false, + "interval": "", + "intervalFactor": 2, + "legendFormat": "Backend-Workers", + "refId": "C", + "step": 4 + }, + { + "expr": "count(rate(container_last_seen{name=~\".+\",container_group=\"backend-workers\"}[$interval]))", + "hide": false, + "intervalFactor": 2, + "legendFormat": "Ops-Infrastructure", + "refId": "D", + "step": 4 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Running Containers (by Container Group)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "show": false + }, + "yaxes": [ + { + "format": "none", + "label": "", + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + "{id=\"/\",instance=\"cadvisor:8080\",job=\"prometheus\"}": "#BA43A9" + }, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 3, + "grid": { + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 5, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 2.0707047594142263, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(container_cpu_system_seconds_total[1m]))", + "hide": true, + "intervalFactor": 2, + "legendFormat": "a", + "refId": "B", + "step": 120 + }, + { + "expr": "sum(rate(container_cpu_system_seconds_total{name=~\".+\"}[1m]))", + "hide": true, + "interval": "", + "intervalFactor": 2, + "legendFormat": "nur container", + "refId": "F", + "step": 10 + }, + { + "expr": "sum(rate(container_cpu_system_seconds_total{id=\"/\"}[1m]))", + "hide": true, + "interval": "", + "intervalFactor": 2, + "legendFormat": "nur docker host", + "metric": "", + "refId": "A", + "step": 20 + }, + { + "expr": "sum(rate(process_cpu_seconds_total[$interval])) * 100", + "hide": false, + "interval": "", + "intervalFactor": 2, + "legendFormat": "host", + "metric": "", + "refId": "C", + "step": 4 + }, + { + "expr": "sum(rate(container_cpu_system_seconds_total{name=~\".+\"}[1m])) + sum(rate(container_cpu_system_seconds_total{id=\"/\"}[1m])) + sum(rate(process_cpu_seconds_total[1m]))", + "hide": true, + "intervalFactor": 2, + "legendFormat": "", + "refId": "D", + "step": 120 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "CPU Usage on Node", + "tooltip": { + "msResolution": true, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "show": false + }, + "yaxes": [ + { + "format": "percent", + "label": "", + "logBase": 1, + "max": 120, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + "Belegete Festplatte": "#BF1B00", + "Free Disk Space": "#7EB26D", + "Used Disk Space": "#BF1B00", + "{}": "#BF1B00" + }, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 4, + "grid": { + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 13, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 3, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 2, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "node_filesystem_free{fstype=\"aufs\"}", + "hide": false, + "intervalFactor": 2, + "legendFormat": "Free Disk Space", + "refId": "A", + "step": 4 + }, + { + "expr": "node_filesystem_size{fstype=\"aufs\"} - node_filesystem_free{fstype=\"aufs\"}", + "hide": false, + "intervalFactor": 2, + "legendFormat": "Used Disk Space", + "refId": "B", + "step": 4 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Free and Used Disk Space on Node", + "tooltip": { + "msResolution": true, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "show": false + }, + "yaxes": [ + { + "format": "bytes", + "label": "", + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + "Available Memory": "#7EB26D", + "Unavailable Memory": "#BF1B00" + }, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 4, + "grid": { + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 20, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 3, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 2, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "container_memory_rss{name=~\".+\"}", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{__name__}}", + "refId": "D", + "step": 30 + }, + { + "expr": "sum(container_memory_rss{name=~\".+\"})", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{__name__}}", + "refId": "A", + "step": 20 + }, + { + "expr": "container_memory_usage_bytes{name=~\".+\"}", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{name}}", + "refId": "B", + "step": 20 + }, + { + "expr": "container_memory_rss{id=\"/\"}", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{__name__}}", + "refId": "C", + "step": 30 + }, + { + "expr": "sum(container_memory_rss)", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{__name__}}", + "refId": "E", + "step": 30 + }, + { + "expr": "node_memory_Buffers", + "hide": true, + "intervalFactor": 2, + "legendFormat": "node_memory_Dirty", + "refId": "N", + "step": 30 + }, + { + "expr": "node_memory_MemFree", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{__name__}}", + "refId": "F", + "step": 30 + }, + { + "expr": "node_memory_MemAvailable", + "hide": false, + "intervalFactor": 2, + "legendFormat": "Available Memory", + "refId": "H", + "step": 4 + }, + { + "expr": "node_memory_MemTotal - node_memory_MemAvailable", + "hide": false, + "intervalFactor": 2, + "legendFormat": "Unavailable Memory", + "refId": "G", + "step": 4 + }, + { + "expr": "node_memory_Inactive", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{__name__}}", + "refId": "I", + "step": 30 + }, + { + "expr": "node_memory_KernelStack", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{__name__}}", + "refId": "J", + "step": 30 + }, + { + "expr": "node_memory_Active", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{__name__}}", + "refId": "K", + "step": 30 + }, + { + "expr": "node_memory_MemTotal - (node_memory_Active + node_memory_MemFree + node_memory_Inactive)", + "hide": true, + "intervalFactor": 2, + "legendFormat": "Unknown", + "refId": "L", + "step": 40 + }, + { + "expr": "node_memory_MemFree + node_memory_Inactive ", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{__name__}}", + "refId": "M", + "step": 30 + }, + { + "expr": "container_memory_rss{name=~\".+\"}", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{__name__}}", + "refId": "O", + "step": 30 + }, + { + "expr": "node_memory_Inactive + node_memory_MemFree + node_memory_MemAvailable", + "hide": true, + "intervalFactor": 2, + "legendFormat": "", + "refId": "P", + "step": 40 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Available Memory on Node", + "tooltip": { + "msResolution": true, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "show": false + }, + "yaxes": [ + { + "format": "bytes", + "label": "", + "logBase": 1, + "max": 4200000000, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 1, + "grid": { + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 3, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 1.939297855648535, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(node_disk_bytes_read[$interval])) by (device)", + "intervalFactor": 2, + "legendFormat": "OUT on /{{device}}", + "metric": "node_disk_bytes_read", + "refId": "A", + "step": 4 + }, + { + "expr": "sum(rate(node_disk_bytes_written[$interval])) by (device)", + "intervalFactor": 2, + "legendFormat": "IN on /{{device}}", + "metric": "", + "refId": "B", + "step": 4 + }, + { + "expr": "", + "intervalFactor": 2, + "refId": "C" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Disk I/O on Node", + "tooltip": { + "msResolution": true, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "show": false + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + } + ], + "title": "New row" + }, + { + "collapse": false, + "editable": true, + "height": 284.609375, + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 5, + "grid": { + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 1, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 6.0790694124949285, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(container_cpu_usage_seconds_total{name=~\".+\"}[$interval])) by (name) * 100", + "hide": false, + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{name}}", + "metric": "container_cp", + "refId": "F", + "step": 2 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "CPU Usage per Container (Stacked)", + "tooltip": { + "msResolution": true, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "show": true + }, + "yaxes": [ + { + "format": "percent", + "label": "", + "logBase": 1, + "max": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + "node_load15": "#CCA300" + }, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 0, + "grid": { + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 4, + "isNew": true, + "legend": { + "avg": false, + "current": true, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 5.920930587505071, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "{__name__=~\"^node_load.*\"}", + "intervalFactor": 2, + "legendFormat": "{{__name__}}", + "metric": "node", + "refId": "A", + "step": 2 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "System Load on Node", + "tooltip": { + "msResolution": true, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "show": true + }, + "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 + } + ] + } + ], + "title": "Row" + }, + { + "collapse": false, + "editable": true, + "height": 203.515625, + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 1, + "grid": { + "threshold1": null, + "threshold1Color": "rgba(247, 226, 2, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(244, 0, 0, 0.22)", + "thresholdLine": false + }, + "id": 9, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "hideEmpty": false, + "hideZero": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(container_network_transmit_bytes_total{name=~\".+\"}[$interval])) by (name)", + "intervalFactor": 2, + "legendFormat": "{{name}}", + "refId": "A", + "step": 2 + }, + { + "expr": "rate(container_network_transmit_bytes_total{id=\"/\"}[$interval])", + "hide": true, + "intervalFactor": 2, + "legendFormat": "", + "refId": "B", + "step": 10 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Sent Network Traffic per Container", + "tooltip": { + "msResolution": true, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "transparent": false, + "type": "graph", + "xaxis": { + "show": true + }, + "yaxes": [ + { + "format": "Bps", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": "", + "logBase": 10, + "max": 8, + "min": 0, + "show": false + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 3, + "grid": { + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 10, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 6, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "sum(container_memory_rss{name=~\".+\"}) by (name)", + "hide": false, + "intervalFactor": 2, + "legendFormat": "{{name}}", + "refId": "A", + "step": 2 + }, + { + "expr": "container_memory_usage_bytes{name=~\".+\"}", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{name}}", + "refId": "B", + "step": 240 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Memory Usage per Container (Stacked)", + "tooltip": { + "msResolution": true, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "show": true + }, + "yaxes": [ + { + "format": "bytes", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "title": "New row" + }, + { + "collapse": false, + "editable": true, + "height": 222.703125, + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 1, + "grid": { + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 8, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(container_network_receive_bytes_total{name=~\".+\"}[$interval])) by (name)", + "intervalFactor": 2, + "legendFormat": "{{name}}", + "refId": "A", + "step": 2 + }, + { + "expr": "- rate(container_network_transmit_bytes_total{name=~\".+\"}[$interval])", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{name}}", + "refId": "B", + "step": 10 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Received Network Traffic per Container", + "tooltip": { + "msResolution": true, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "transparent": false, + "type": "graph", + "xaxis": { + "show": true + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 3, + "grid": { + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 11, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 6, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "container_memory_rss{name=~\".+\"}", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{name}}", + "refId": "A", + "step": 20 + }, + { + "expr": "container_memory_usage_bytes{name=~\".+\"}", + "hide": true, + "intervalFactor": 2, + "legendFormat": "{{name}}", + "refId": "B", + "step": 20 + }, + { + "expr": "sum(container_memory_cache{name=~\".+\"}) by (name)", + "hide": false, + "intervalFactor": 2, + "legendFormat": "{{name}}", + "refId": "C", + "step": 2 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Cached Memory per Container (Stacked)", + "tooltip": { + "msResolution": true, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "show": true + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + } + ], + "title": "New row" + }, + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "columns": [ + { + "text": "Avg", + "value": "avg" + } + ], + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fontSize": "100%", + "hideTimeOverride": false, + "id": 18, + "isNew": true, + "links": [], + "pageSize": 100, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "span": 6, + "styles": [ + { + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + }, + { + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "expr": "cadvisor_version_info", + "intervalFactor": 2, + "legendFormat": "cAdvisor Version: {{cadvisorVersion}}", + "refId": "A", + "step": 2 + }, + { + "expr": "prometheus_build_info", + "intervalFactor": 2, + "legendFormat": "Prometheus Version: {{version}}", + "refId": "B", + "step": 2 + }, + { + "expr": "node_exporter_build_info", + "intervalFactor": 2, + "legendFormat": "Node-Exporter Version: {{version}}", + "refId": "C", + "step": 2 + }, + { + "expr": "cadvisor_version_info", + "intervalFactor": 2, + "legendFormat": "Docker Version: {{dockerVersion}}", + "refId": "D", + "step": 2 + }, + { + "expr": "cadvisor_version_info", + "intervalFactor": 2, + "legendFormat": "Host OS Version: {{osVersion}}", + "refId": "E", + "step": 2 + }, + { + "expr": "cadvisor_version_info", + "intervalFactor": 2, + "legendFormat": "Host Kernel Version: {{kernelVersion}}", + "refId": "F", + "step": 2 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "", + "transform": "timeseries_aggregations", + "type": "table" + } + ], + "showTitle": false, + "title": "Check this out" + }, + { + "collapse": false, + "editable": true, + "height": 290.98582985381427, + "panels": [], + "title": "New row" + }, + { + "collapse": false, + "editable": true, + "height": 127, + "panels": [], + "title": "New row" + } + ], + "time": { + "from": "now-15m", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "templating": { + "list": [ + { + "allValue": ".+", + "current": {}, + "datasource": "${DS_PROMETHEUS}", + "hide": 0, + "includeAll": true, + "label": "Container Group", + "multi": true, + "name": "containergroup", + "options": [], + "query": "label_values(container_group)", + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "auto": true, + "auto_count": 50, + "auto_min": "50s", + "current": { + "tags": [], + "text": "auto", + "value": "$__auto_interval" + }, + "datasource": null, + "hide": 0, + "includeAll": false, + "label": "Interval", + "multi": false, + "name": "interval", + "options": [ + { + "selected": true, + "text": "auto", + "value": "$__auto_interval" + }, + { + "selected": false, + "text": "30s", + "value": "30s" + }, + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "2m", + "value": "2m" + }, + { + "selected": false, + "text": "3m", + "value": "3m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "7m", + "value": "7m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + }, + { + "selected": false, + "text": "7d", + "value": "7d" + }, + { + "selected": false, + "text": "14d", + "value": "14d" + }, + { + "selected": false, + "text": "30d", + "value": "30d" + } + ], + "query": "30s,1m,2m,3m,5m,7m,10m,30m,1h,6h,12h,1d,7d,14d,30d", + "refresh": 0, + "type": "interval" + } + ] + }, + "annotations": { + "list": [] + }, + "refresh": "10s", + "schemaVersion": 12, + "version": 0, + "links": [], + "gnetId": 395, + "description": "A simple overview of the most important Docker host and container metrics. (cAdvisor/Prometheus)" +} \ No newline at end of file diff --git a/grafana/provisioning/dashboards/providers.yml b/grafana/provisioning/dashboards/providers.yml new file mode 100644 index 0000000..2818600 --- /dev/null +++ b/grafana/provisioning/dashboards/providers.yml @@ -0,0 +1,11 @@ +apiVersion: 1 + +providers: + - name: dashboards + type: file + disableDeletion: false + updateIntervalSeconds: 3600 + allowUiUpdates: false + options: + path: /etc/grafana/dashboards + foldersFromFilesStructure: true diff --git a/postgis/postgis.sql b/postgis/postgis.sql index 6a00e92..82b215e 100644 --- a/postgis/postgis.sql +++ b/postgis/postgis.sql @@ -1,3 +1,5 @@ +set SEARCH_PATH to postgis,public; + create table point ( id serial primary key, nom text not null, diff --git a/postgresql-entrypoint-initdb.d/11_postgraphile.sql b/postgresql-entrypoint-initdb.d/11_postgraphile.sql index bb6fa7d..5331723 100644 --- a/postgresql-entrypoint-initdb.d/11_postgraphile.sql +++ b/postgresql-entrypoint-initdb.d/11_postgraphile.sql @@ -1 +1,2 @@ -create role postgraphile inherit login password 'motdepasse'; +create role postgraphile nosuperuser nocreatedb nocreaterole noinherit noreplication nobypassrls + login password '9013'; diff --git a/postgresql-entrypoint-initdb.d/1_initdb.sql b/postgresql-entrypoint-initdb.d/1_initdb.sql index 671cb44..da9e5b1 100644 --- a/postgresql-entrypoint-initdb.d/1_initdb.sql +++ b/postgresql-entrypoint-initdb.d/1_initdb.sql @@ -1,9 +1,12 @@ +show server_version; select * from pg_available_extensions; +create schema postgis; +create extension if not exists postgis schema postgis; +create extension if not exists pgrouting schema postgis; + create extension if not exists ltree; create extension if not exists pgtap; -create extension if not exists postgis; -create extension if not exists pgrouting; create extension if not exists pgcrypto; create table adherent ( diff --git a/postgrest.http b/postgrest.http new file mode 100644 index 0000000..3cf58e7 --- /dev/null +++ b/postgrest.http @@ -0,0 +1,4 @@ +GET https://postgrest.localhost + +### +GET https://postgrest.localhost/region diff --git a/prometheus.yml b/prometheus.yml new file mode 100644 index 0000000..cdd59f0 --- /dev/null +++ b/prometheus.yml @@ -0,0 +1,22 @@ +global: + scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. + evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. + scrape_timeout: 10s # scrape_timeout is set to the global default (10s). + +scrape_configs: + - job_name: docker + static_configs: + - targets: + - 'host.docker.internal:9323' + + - job_name: prometheus + static_configs: + - targets: + - '127.0.0.1:9090' + + - job_name: minio + metrics_path: /minio/v2/metrics/bucket + scheme: http + static_configs: + - targets: + - 'minio:9000'