Skip to content

Commit ff5f702

Browse files
author
Dementii Priadko
committed
Checkup20
1 parent c5ba166 commit ff5f702

File tree

2 files changed

+93
-70
lines changed

2 files changed

+93
-70
lines changed

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A complete PostgreSQL monitoring solution with automated performance analysis an
77
**Infrastructure:**
88
- **Linux machine** with Docker installed (separate from your database server)
99
- **Docker access** - the user running `postgres_ai` must have Docker permissions
10-
- **Network access** to the PostgreSQL database(s) you want to monitor
10+
- **Access (network and pg_hba)** to the PostgreSQL database(s) you want to monitor
1111

1212
**Database:**
1313
- Supports PostgreSQL versions 14-17
@@ -78,14 +78,18 @@ Now, start it and wait for a few minutes. Two optional adjustments:
7878
- remove `--demo` unless you want to see it in action without monitoring an actual Postgres DB (this option creates a demo DB)
7979
- get an Postgres AI access token for your organization at https://console.postgres.ai (`Your org name → Manage → Access tokens`)
8080

81+
```bash
82+
# Production setup with your Access token
83+
./postgres_ai quickstart --api-key=your_access_token
84+
```
85+
86+
Or if you want to just check out how it works:
8187
```bash
8288
# Complete setup with demo database
8389
./postgres_ai quickstart --demo
84-
85-
# Production setup with your API key
86-
./postgres_ai quickstart --api-key=your_api_key
8790
```
8891

92+
8993
That's it! Everything is installed, configured, and running.
9094

9195
## 📊 What you get
@@ -111,12 +115,6 @@ Get a complete monitoring setup with demo data in under 2 minutes.
111115
./postgres_ai add-instance "postgresql://user:pass@host:port/db"
112116
```
113117

114-
**For CI/CD:**
115-
```bash
116-
./postgres_ai quickstart --demo --api-key=$API_KEY
117-
```
118-
Fully automated setup with no interactive prompts.
119-
120118
## 🔧 Management commands
121119

122120
```bash

postgres_ai

Lines changed: 85 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ show_help() {
8383
echo " --db-url=URL Provide PostgreSQL connection URL for monitoring"
8484
echo " -y, --yes Accept all defaults and skip interactive prompts"
8585
echo ""
86+
echo "RESTRICTIONS:"
87+
echo " --demo and --api-key cannot be used together (demo mode is for testing only)"
88+
echo ""
8689
echo " help Show this help message"
8790
echo
8891
echo "EXAMPLES:"
@@ -91,7 +94,7 @@ show_help() {
9194
echo " $0 quickstart -y # Complete setup with auto-yes (accept all defaults)"
9295
echo " $0 quickstart --api-key=your_api_key # Complete setup with API key for automated reports"
9396
echo " $0 quickstart --db-url=postgresql://user:pass@host:5432/db # Complete setup with database URL"
94-
echo " $0 quickstart --demo --api-key=your_key # Demo mode with API key"
97+
echo " $0 quickstart --demo # Demo mode (testing only, no API key)"
9598
echo " $0 quickstart --db-url=postgresql://user:pass@host:5432/db --api-key=key # Complete with both"
9699
echo " $0 quickstart -y --api-key=key --db-url=postgresql://user:pass@host:5432/db # Fully automated setup"
97100
echo " $0 install # Clone repository and setup for production"
@@ -696,6 +699,14 @@ quickstart_setup() {
696699
db_url=""
697700
fi
698701

702+
if [ "$demo_mode" = true ] && [ -n "$api_key" ]; then
703+
log_error "Cannot use --api-key with --demo mode"
704+
log_error "Demo mode is for testing only and does not support API key integration"
705+
log_info "Use demo mode without API key: $0 quickstart --demo"
706+
log_info "Or use production mode with API key: $0 quickstart --api-key=your_key"
707+
exit 1
708+
fi
709+
699710
# Perform comprehensive prechecks first
700711
log_info "Performing system prechecks..."
701712
precheck_for_install
@@ -704,70 +715,76 @@ quickstart_setup() {
704715
log_info "Step 1: Installing Postgres AI monitoring project..."
705716
CALLED_FROM_QUICKSTART=true install_project "$1"
706717

707-
# Step 2: Add API key (optional)
708-
echo
709-
log_info "Step 2: Postgres AI API Configuration (Optional)"
710-
log_info "An API key enables automatic upload of PostgreSQL reports to Postgres AI"
711-
712-
if [ -n "$api_key" ]; then
713-
# API key provided via command line
714-
log_info "Using API key provided via --api-key parameter"
715-
add_api_key "$api_key"
716-
else
717-
# Interactive API key setup
718-
local proceed_with_api_key=false
718+
# Step 2: Add API key (only in production mode)
719+
if [ "$demo_mode" = false ]; then
720+
echo
721+
log_info "Step 2: Postgres AI API Configuration (Optional)"
722+
log_info "An API key enables automatic upload of PostgreSQL reports to Postgres AI"
719723

720-
if [ "$auto_yes" = true ]; then
721-
# Auto-yes mode: proceed directly to API key entry
722-
log_info "Auto-yes mode: proceeding to API key setup"
723-
proceed_with_api_key=true
724+
if [ -n "$api_key" ]; then
725+
# API key provided via command line
726+
log_info "Using API key provided via --api-key parameter"
727+
add_api_key "$api_key"
724728
else
725-
# Interactive mode: ask user
726-
read -p "Do you have a Postgres AI API key? (Y/n): " -n 1 -r
727-
echo
729+
# Interactive API key setup
730+
local proceed_with_api_key=false
728731

729-
# Default to Y if user just presses Enter or responds with Y/y
730-
if [[ -z $REPLY ]] || [[ $REPLY =~ ^[Yy]$ ]]; then
732+
if [ "$auto_yes" = true ]; then
733+
# Auto-yes mode: proceed directly to API key entry
734+
log_info "Auto-yes mode: proceeding to API key setup"
731735
proceed_with_api_key=true
736+
else
737+
# Interactive mode: ask user
738+
read -p "Do you have a Postgres AI API key? (Y/n): " -n 1 -r
739+
echo
740+
741+
# Default to Y if user just presses Enter or responds with Y/y
742+
if [[ -z $REPLY ]] || [[ $REPLY =~ ^[Yy]$ ]]; then
743+
proceed_with_api_key=true
744+
fi
732745
fi
733-
fi
734-
735-
if [ "$proceed_with_api_key" = true ]; then
736-
while true; do
737-
read -p "Enter your Postgres AI API key: " input_api_key
738-
if [ -n "$input_api_key" ]; then
739-
# Remove any leading/trailing whitespace
740-
input_api_key=$(echo "$input_api_key" | xargs)
746+
747+
if [ "$proceed_with_api_key" = true ]; then
748+
while true; do
749+
read -p "Enter your Postgres AI API key: " input_api_key
741750
if [ -n "$input_api_key" ]; then
742-
add_api_key "$input_api_key"
743-
break
751+
# Remove any leading/trailing whitespace
752+
input_api_key=$(echo "$input_api_key" | xargs)
753+
if [ -n "$input_api_key" ]; then
754+
add_api_key "$input_api_key"
755+
break
756+
fi
744757
fi
745-
fi
746-
747-
log_warning "API key cannot be empty"
748-
749-
if [ "$auto_yes" = true ]; then
750-
# Auto-yes mode: automatically retry
751-
log_info "Auto-yes mode: retrying API key entry"
752-
continue
753-
else
754-
# Interactive mode: ask user
755-
read -p "Try again or skip API key setup, retry? (Y/n): " -n 1 -r
756-
echo
757-
if [[ $REPLY =~ ^[Nn]$ ]]; then
758-
log_info "Skipping API key setup - reports will be generated locally only"
759-
log_info "You can add an API key later with: $0 add-key <api_key>"
760-
break
758+
759+
log_warning "API key cannot be empty"
760+
761+
if [ "$auto_yes" = true ]; then
762+
# Auto-yes mode: automatically retry
763+
log_info "Auto-yes mode: retrying API key entry"
764+
continue
765+
else
766+
# Interactive mode: ask user
767+
read -p "Try again or skip API key setup, retry? (Y/n): " -n 1 -r
768+
echo
769+
if [[ $REPLY =~ ^[Nn]$ ]]; then
770+
log_info "Skipping API key setup - reports will be generated locally only"
771+
log_info "You can add an API key later with: $0 add-key <api_key>"
772+
break
773+
fi
761774
fi
762-
fi
763-
done
764-
else
765-
log_info "Skipping API key setup - reports will be generated locally only"
766-
log_info "You can add an API key later with: $0 add-key <api_key>"
775+
done
776+
else
777+
log_info "Skipping API key setup - reports will be generated locally only"
778+
log_info "You can add an API key later with: $0 add-key <api_key>"
779+
fi
767780
fi
781+
else
782+
echo
783+
log_info "Step 2: Demo mode - API key configuration skipped"
784+
log_info "Demo mode is for testing only and does not support API key integration"
768785
fi
769786

770-
# Step 3: Add PostgreSQL instance (if not demo mode)
787+
# Step 3/2: Add PostgreSQL instance (if not demo mode)
771788
if [ "$demo_mode" = false ]; then
772789
echo
773790
log_info "Step 3: Add PostgreSQL Instance to Monitor"
@@ -843,20 +860,28 @@ quickstart_setup() {
843860
fi
844861
fi
845862
else
846-
log_info "Step 3: Demo mode enabled - using included demo PostgreSQL database"
863+
log_info "Step 2: Demo mode enabled - using included demo PostgreSQL database"
847864
fi
848865

849-
# Step 4: Update configuration
866+
# Step 4/3: Update configuration
850867
echo
851-
log_info "Step 4: Updating configuration..."
868+
if [ "$demo_mode" = true ]; then
869+
log_info "Step 3: Updating configuration..."
870+
else
871+
log_info "Step 4: Updating configuration..."
872+
fi
852873
update_config
853874

854-
# Step 5: Start services
875+
# Step 5/4: Start services
855876
echo
856-
log_info "Step 5: Starting monitoring services..."
877+
if [ "$demo_mode" = true ]; then
878+
log_info "Step 4: Starting monitoring services..."
879+
else
880+
log_info "Step 5: Starting monitoring services..."
881+
fi
857882
start_services
858883

859-
# Step 6: Final summary
884+
# Step 6/5: Final summary
860885
echo
861886
log_success "🎉 Quickstart setup completed successfully!"
862887
echo

0 commit comments

Comments
 (0)