Skip to content

Commit 3da6e5a

Browse files
author
Dementii Priadko
committed
Merge branch 'mvp' into 'main'
CLI improvements and report functionality See merge request postgres-ai/postgres_ai!7
2 parents 05d7d18 + 928c9c8 commit 3da6e5a

File tree

6 files changed

+867
-83
lines changed

6 files changed

+867
-83
lines changed

README.md

Lines changed: 60 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,85 @@
1-
# postgres_ai
1+
# Postgres AI
22

3+
A complete PostgreSQL monitoring solution with automated performance analysis and reporting.
34

5+
## 🚀 Quick Start
46

5-
## Getting started
7+
**One command setup:**
68

7-
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
9+
```bash
10+
# Download the CLI
11+
curl -o postgres-ai-cli https://gitlab.com/postgres-ai/postgres_ai/-/raw/main/postgres-ai-cli && chmod +x postgres-ai-cli
812

9-
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
10-
11-
## Add your files
12-
13-
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14-
- [ ] [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
13+
# Complete setup with demo database
14+
./postgres-ai-cli quickstart --demo
1515

16+
# Production setup with your API key
17+
./postgres-ai-cli quickstart --api-key=your_api_key
1618
```
17-
cd existing_repo
18-
git remote add origin https://gitlab.com/postgres-ai/postgres_ai.git
19-
git branch -M main
20-
git push -uf origin main
21-
```
22-
23-
## Integrate with your tools
24-
25-
- [ ] [Set up project integrations](https://gitlab.com/postgres-ai/postgres_ai/-/settings/integrations)
26-
27-
## Collaborate with your team
28-
29-
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30-
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31-
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32-
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33-
- [ ] [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
34-
35-
## Test and Deploy
3619

37-
Use the built-in continuous integration in GitLab.
20+
That's it! Everything is installed, configured, and running.
3821

39-
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
40-
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41-
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42-
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43-
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
22+
## 📊 What You Get
4423

45-
***
24+
- **Grafana Dashboards** - Visual monitoring at http://localhost:3000
25+
- **PostgreSQL Monitoring** - PGWatch with comprehensive metrics
26+
- **Automated Reports** - Daily performance analysis
27+
- **API Integration** - Automatic upload to PostgreSQL AI
28+
- **Demo Database** - Ready-to-use test environment
4629

47-
# Editing this README
30+
## 🎯 Use Cases
4831

49-
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
50-
51-
## Suggestions for a good README
52-
53-
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
54-
55-
## Name
56-
Choose a self-explaining name for your project.
32+
**For Developers:**
33+
```bash
34+
./postgres-ai-cli quickstart --demo
35+
```
36+
Get a complete monitoring setup with demo data in under 2 minutes.
5737

58-
## Description
59-
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
38+
**For Production:**
39+
```bash
40+
./postgres-ai-cli quickstart --api-key=your_key
41+
# Then add your databases
42+
./postgres-ai-cli add-instance "postgresql://user:pass@host:port/db"
43+
```
6044

61-
## Badges
62-
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
45+
**For CI/CD:**
46+
```bash
47+
./postgres-ai-cli quickstart --demo --api-key=$API_KEY
48+
```
49+
Fully automated setup with no interactive prompts.
6350

64-
## Visuals
65-
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
51+
## 🔧 Management Commands
6652

67-
## Installation
68-
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
53+
```bash
54+
# Instance management
55+
./postgres-ai-cli add-instance "postgresql://user:pass@host:port/db"
56+
./postgres-ai-cli list-instances
57+
./postgres-ai-cli test-instance my-db
6958

70-
## Usage
71-
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
59+
# Service management
60+
./postgres-ai-cli status
61+
./postgres-ai-cli logs
62+
./postgres-ai-cli restart
7263

73-
## Support
74-
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
64+
# Health check
65+
./postgres-ai-cli health
66+
```
7567

76-
## Roadmap
77-
If you have ideas for releases in the future, it is a good idea to list them in the README.
68+
## 🌐 Access Points
7869

79-
## Contributing
80-
State if you are open to contributions and what your requirements are for accepting them.
70+
After running quickstart:
8171

82-
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
72+
- **Grafana**: http://localhost:3000 (admin/admin)
73+
- **Demo DB**: postgresql://postgres:postgres@localhost:5432/target_database
74+
- **Monitoring**: http://localhost:8080 (PGWatch)
75+
- **Metrics**: http://localhost:9090 (Prometheus)
8376

84-
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
77+
## 📖 Help
8578

86-
## Authors and acknowledgment
87-
Show your appreciation to those who have contributed to the project.
79+
```bash
80+
./postgres-ai-cli help
81+
```
8882

89-
## License
90-
For open source projects, say how it is licensed.
83+
## 🔑 API Key
9184

92-
## Project status
93-
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
85+
Get your key at [PostgreSQL AI](https://postgres.ai) for automated report uploads and advanced analysis.

docker-compose.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,41 @@ services:
125125
ports:
126126
- "5000:5000"
127127

128+
# PostgreSQL Reports Generator - Runs reports after 1 hour
129+
postgres-reports:
130+
image: python:3.11-slim
131+
container_name: postgres-reports
132+
working_dir: /app
133+
volumes:
134+
- ./reporter/postgres_reports.py:/app/postgres_reports.py
135+
- ./reporter/requirements.txt:/app/requirements.txt
136+
- ./.pgwatch-config:/app/.pgwatch-config:ro
137+
environment:
138+
- PROMETHEUS_URL=http://sink-prometheus:9090
139+
depends_on:
140+
- sink-prometheus
141+
- pgwatch-prometheus
142+
command: >
143+
sh -c "
144+
echo 'Installing Python dependencies...' &&
145+
pip install -r requirements.txt &&
146+
echo 'Waiting 1 hour before generating reports...' &&
147+
sleep 3600 &&
148+
echo 'Starting PostgreSQL reports generation...' &&
149+
while true; do
150+
echo 'Generating PostgreSQL reports...' &&
151+
if [ -f /app/.pgwatch-config ] && grep -q '^api_key=' /app/.pgwatch-config; then
152+
API_KEY=$$(grep '^api_key=' /app/.pgwatch-config | cut -d'=' -f2) &&
153+
python postgres_reports.py --prometheus-url http://sink-prometheus:9090 --output /app/all_reports_$$(date +%Y%m%d_%H%M%S).json --upload --token $$API_KEY --project postgres-ai-monitoring
154+
else
155+
echo 'No API key configured, generating reports without upload...' &&
156+
python postgres_reports.py --prometheus-url http://sink-prometheus:9090 --output /app/all_reports_$$(date +%Y%m%d_%H%M%S).json
157+
fi &&
158+
echo 'Reports generated. Sleeping for 24 hours...' &&
159+
sleep 86400
160+
done
161+
"
162+
128163
volumes:
129164
target_db_data:
130165
sink_postgres_data:

instances.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- unique_name: target-database
1+
- name: target-database
22
conn_str: postgresql://monitor:monitor_pass@target-db:5432/target_database
33
preset_metrics: full
44
custom_metrics:

0 commit comments

Comments
 (0)