Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit11b06ca

Browse files
author
Dementii Priadko
committed
Add k8s support
1 parent422f710 commit11b06ca

File tree

55 files changed

+2070
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2070
-14
lines changed

‎.cursor‎

Submodule.cursor updated from 80f2889 to 735d2bf

‎docker-compose.yml‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ services:
130130
-sink-postgres
131131
-sink-prometheus
132132
restart:unless-stopped
133-
flask-backend:
134-
build:
135-
context:./flask-backend
136-
dockerfile:Dockerfile
133+
monitoring_flask_backend:
134+
image:postgresai/monitoring_flask_backend:latest
137135
container_name:flask-pgss-api
138136
environment:
139137
-FLASK_ENV=production
@@ -143,7 +141,7 @@ services:
143141
restart:unless-stopped
144142
# PostgreSQL Reports Generator - Runs reports after 1 hour
145143
postgres-reports:
146-
image:python:3.11-slim
144+
image:postgresai/reporter:latest
147145
container_name:postgres-reports
148146
working_dir:/app
149147
volumes:

‎flask-backend/Dockerfile‎renamed to ‎monitoring_flask_backend/Dockerfile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ RUN pip install --no-cache-dir -r requirements.txt
1616
COPY app.py .
1717

1818
# Expose port
19-
EXPOSE5000
19+
EXPOSE8000
2020

2121
# Set environment variables
2222
ENV FLASK_APP=app.py
2323
ENV FLASK_ENV=production
2424

2525
# Run the application
26-
CMD ["gunicorn","--bind","0.0.0.0:5000","--workers","4","--timeout","120","app:app"]
26+
CMD ["gunicorn","--bind","0.0.0.0:8000","--workers","4","--timeout","120","app:app"]

‎flask-backend/app.py‎renamed to ‎monitoring_flask_backend/app.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
importio
55
fromdatetimeimportdatetime,timezone,timedelta
66
importlogging
7+
importos
78

89
# Configure logging
910
logging.basicConfig(level=logging.INFO)
1011
logger=logging.getLogger(__name__)
1112

1213
app=Flask(__name__)
1314

14-
# Prometheus connection
15-
PROMETHEUS_URL="http://sink-prometheus:9090"
15+
# Prometheus connection - use environment variable with fallback
16+
PROMETHEUS_URL=os.environ.get('PROMETHEUS_URL','http://localhost:8428')
1617

1718
# Metric name mapping for cleaner CSV output
1819
METRIC_NAME_MAPPING= {
File renamed without changes.

‎postgres_ai‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ start_services() {
11041104
log_info"Starting Postgres AI monitoring services (production mode)..."
11051105
log_info"Target demo database not included - add your own PostgreSQL instances to monitor"
11061106
# Start all services except target-db, including host stats monitoring
1107-
$compose_cmd -f"$COMPOSE_FILE" up -d sources-generator sink-postgres sink-prometheus pgwatch-postgres pgwatch-prometheus grafanaflask-backend postgres-reports cadvisor node-exporter postgres-exporter
1107+
$compose_cmd -f"$COMPOSE_FILE" up -d sources-generator sink-postgres sink-prometheus pgwatch-postgres pgwatch-prometheus grafanamonitoring_flask_backend postgres-reports cadvisor node-exporter postgres-exporter
11081108
fi
11091109

11101110
log_success"Services started!"

‎postgres_ai_helm/.helmignore‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Patterns to ignore when building packages
2+
.DS_Store
3+
.git/
4+
.gitignore
5+
.bzr/
6+
.bzrignore
7+
.hg/
8+
.hgignore
9+
.svn/
10+
*.swp
11+
*.bak
12+
*.tmp
13+
*.orig
14+
*~
15+
.project
16+
.idea/
17+
*.tmproj
18+
.vscode/
19+
*.code-workspace
20+
*.md

‎postgres_ai_helm/Chart.lock‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: grafana
3+
repository: https://grafana.github.io/helm-charts
4+
version: 10.1.4
5+
digest: sha256:0071bd9cc7eb403a2a58b7b0cd92eedbecafda51588ebd6a18c45dbb12416f79
6+
generated: "2025-11-13T12:20:55.238834+02:00"

‎postgres_ai_helm/Chart.yaml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion:v2
2+
appVersion:1.0.0
3+
dependencies:
4+
-condition:grafana.enabled
5+
name:grafana
6+
repository:https://grafana.github.io/helm-charts
7+
version:10.1.4
8+
description:PostgresAI monitoring stack with PGWatch, VictoriaMetrics, and Grafana
9+
for Kubernetes
10+
home:https://postgres.ai
11+
keywords:
12+
-postgresql
13+
-monitoring
14+
-pgwatch
15+
-victoriametrics
16+
-grafana
17+
-observability
18+
maintainers:
19+
-name:PostgresAI
20+
url:https://postgres.ai
21+
name:postgres-ai-monitoring
22+
sources:
23+
-https://github.com/PostgresAI/double-pgwatch-poc
24+
type:application
25+
version:0.12
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
#Postgres AI monitoring - Helm chart installation guide
2+
3+
##Installation
4+
5+
###1. Download Helm chart
6+
7+
###2. Create namespace
8+
9+
```bash
10+
kubectl create namespace postgres-ai-mon
11+
```
12+
13+
###3. Create custom-values.yaml
14+
15+
```yaml
16+
existingSecret:
17+
name:postgres-ai-monitoring-secrets
18+
19+
global:
20+
clusterName:my-cluster
21+
nodeName:my-node
22+
customTags:
23+
env:production
24+
25+
monitoredDatabases:
26+
-name:my-db
27+
host:db-host.example.com
28+
port:5432
29+
database:postgres
30+
user:postgres_ai_mon
31+
passwordSecretKey:my-db-password
32+
presetMetrics:full
33+
isEnabled:true
34+
group:production
35+
36+
grafana:
37+
enabled:true
38+
admin:
39+
existingSecret:postgres-ai-monitoring-secrets
40+
userKey:grafana-admin-user
41+
passwordKey:grafana-admin-password
42+
service:
43+
type:ClusterIP
44+
45+
ingress:
46+
enabled:true
47+
className:nginx
48+
hosts:
49+
grafana:monitoring.example.com
50+
51+
storage:
52+
postgresSize:100Gi
53+
victoriaMetricsSize:200Gi
54+
storageClassName:standard
55+
```
56+
57+
**Customize**:`clusterName`, `monitoredDatabases`, `ingress.hosts`, and `storageClassName`.
58+
59+
### 4. Create secret
60+
61+
```bash
62+
kubectl create secret generic postgres-ai-monitoring-secrets \
63+
--namespace postgres-ai-mon \
64+
--from-literal=postgres-password='SINK_POSTGRES_PASSWORD' \
65+
--from-literal=grafana-admin-user='monitor' \
66+
--from-literal=grafana-admin-password='GRAFANA_PASSWORD' \
67+
--from-literal=pgai-api-key='POSTGRES_AI_API_KEY' \
68+
--from-literal=db-password-my-db-password='DB_PASSWORD'
69+
```
70+
71+
**Notes:**
72+
73+
-`SINK_POSTGRES_PASSWORD`should be generated by you and will be used to connect to the internal database for storing metrics
74+
-`GRAFANA_PASSWORD`should be generated by you and will be used to access grafana
75+
-`POSTGRES_AI_API_KEY`should be attained from PostgresAI platform and will be used to connect to the PostgresAI platform
76+
-Add `--from-literal` for each database that you want to monitor
77+
-Key must match `passwordSecretKey` in custom-values.yaml
78+
-Key name must be `db-password-<passwordSecretKey>` and value must be the password for monitoring user in the database
79+
80+
### 5. Install helm chart
81+
82+
```bash
83+
helm install postgres-ai-monitoring ./postgres-ai-monitoring-0.12.tgz \
84+
--namespace postgres-ai-mon \
85+
--values custom-values.yaml
86+
```
87+
88+
### 6. Verify installation
89+
90+
```bash
91+
kubectl get pods -n postgres-ai-mon
92+
```
93+
94+
## Access grafana
95+
96+
**Port Forward** (quick access):
97+
98+
```bash
99+
kubectl port-forward -n postgres-ai-mon svc/postgres-ai-monitoring-grafana 3000:80
100+
```
101+
102+
Open:`http://localhost:3000`
103+
104+
**Ingress**: Access via configured domain (e.g., `http://monitoring.example.com`)
105+
106+
**Login**: Username and password from the secret (`grafana-admin-user` / `grafana-admin-password`)
107+
108+
## Common tasks
109+
110+
### Update configuration
111+
112+
```bash
113+
helm upgrade postgres-ai-monitoring ./postgres-ai-monitoring-0.12.tgz \
114+
--namespace postgres-ai-mon \
115+
--values custom-values.yaml
116+
```
117+
118+
### Add database
119+
120+
1. Add entry to `monitoredDatabases` in custom-values.yaml
121+
122+
2. Add password to secret:
123+
124+
```bash
125+
kubectl create secret generic postgres-ai-monitoring-secrets \
126+
--namespace postgres-ai-mon \
127+
--from-literal=new-db-password='password' \
128+
--dry-run=client -o yaml | kubectl apply -f -
129+
```
130+
131+
3. Run `helm upgrade`
132+
133+
### Check logs
134+
135+
```bash
136+
kubectl logs -n postgres-ai-mon <pod-name>
137+
```
138+
139+
## Uninstall
140+
141+
### 1. Uninstall Helm release
142+
143+
```bash
144+
helm uninstall postgres-ai-monitoring --namespace postgres-ai-mon
145+
```
146+
147+
This removes all resources created by the Helm chart, but preserves PersistentVolumeClaims and secrets.
148+
149+
### 2. Delete PersistentVolumeClaims (optional)
150+
151+
**Warning**: This will permanently delete all stored metrics and Grafana data.
152+
153+
```bash
154+
kubectl delete pvc -n postgres-ai-mon --all
155+
```
156+
157+
Or delete specific PVCs:
158+
159+
```bash
160+
kubectl delete pvc -n postgres-ai-mon data-postgres-ai-monitoring-sink-postgres-0
161+
kubectl delete pvc -n postgres-ai-mon data-postgres-ai-monitoring-victoriametrics-0
162+
```
163+
164+
### 3. Delete secrets (optional)
165+
166+
```bash
167+
kubectl delete secret -n postgres-ai-mon postgres-ai-monitoring-secrets
168+
```
169+
170+
### 4. Delete namespace (optional)
171+
172+
**Warning**: This will delete all resources in the namespace, including any data stored in PersistentVolumes.
173+
174+
```bash
175+
kubectl delete namespace postgres-ai-mon
176+
```
177+
178+
**Note**: Before deleting the namespace, ensure no other applications are using it.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp