diff --git a/Pulumi.yaml b/Pulumi.yaml index fed8d2a..a414ed1 100644 --- a/Pulumi.yaml +++ b/Pulumi.yaml @@ -1,4 +1,4 @@ -name: last_version_test_1 +name: dev description: A minimal OpenStack Python Pulumi program runtime: name: python diff --git a/config.json b/config.json index 5b77fd9..821df98 100644 --- a/config.json +++ b/config.json @@ -27,6 +27,30 @@ "network_mode": "testNetwork", "ports": [{"internal": 80, "external": 5050}] }, + { + "name": "postgres-exporter", + "image": "wrouesnel/postgres_exporter:latest", + "envs": { + "DATA_SOURCE_NAME": "postgresql://admin:admin@admin:5432/admin?sslmode=disable" + }, + "network_mode": "testNetwork", + "ports": [ + { + "internal": 9187, + "external": 9187 + } + ], + "volumes": [ + { + "host_path": "./queries.yaml", + "container_path": "/etc/postgres_exporter/queries.yaml" + } + ], + "command": [ + "--extend.query-path=/etc/postgres_exporter/queries.yaml", + "--log.level=debug" + ] + }, { "name": "odoo", "image": "odoo_custom", diff --git a/exporter.Dockerfile b/exporter.Dockerfile new file mode 100644 index 0000000..71112a2 --- /dev/null +++ b/exporter.Dockerfile @@ -0,0 +1,14 @@ +# Base image: postgres-exporter +FROM wrouesnel/postgres_exporter:latest as exporter_custom + +# Add your custom queries.yaml to the image +COPY queries.yaml /etc/postgres_exporter/queries.yaml + +# Expose the default port +EXPOSE 9187 + +# Command to run the exporter with the custom query path +CMD [ \ + "--extend.query-path=/etc/postgres_exporter/queries.yaml", \ + "--log.level=debug" \ +] diff --git a/prometheus.yml b/prometheus.yml index 5ebc21e..7f8b54e 100644 --- a/prometheus.yml +++ b/prometheus.yml @@ -1,8 +1,8 @@ scrape_configs: - - job_name: 'postgres' + - job_name: 'postgres-exporter' static_configs: - - targets: ['localhost:8000'] # Le script expose les métriques sur ce port + - targets: ['postgres-exporter:9187'] - job_name: 'odoo' static_configs: - - targets: ['localhost:8000'] # Idem pour Odoo + - targets: ['localhost:8069'] # Idem pour Odoo diff --git a/queries.yaml b/queries.yaml new file mode 100644 index 0000000..3c36386 --- /dev/null +++ b/queries.yaml @@ -0,0 +1,15 @@ +pg_stat_statements: + query: "SELECT query, calls, total_exec_time FROM pg_stat_statements" + metrics: + - name: "pg_stat_statements_total_exec_time" + help: "Total execution time of the query" + type: "counter" + value: "total_exec_time" + labels: + - "query" + - name: "pg_stat_statements_calls" + help: "Total number of calls for the query" + type: "counter" + value: "calls" + labels: + - "query"