Skip to content

Usage Guide

nyounan edited this page May 20, 2025 · 2 revisions

💬 Usage Guide

Once you've installed and authenticated gcp-ops-bot, you're ready to start using it.

The bot uses natural language prompts and GCP APIs (optionally enhanced with GenAI) to respond with helpful insights about your cloud infrastructure.


▶️ Start the Bot

Run the following command in your terminal:

python main.py

You’ll see:

GCP Monitoring Bot started. Type 'q', 'quit', or 'exit' to stop.
--------------------------------------------------
User :>

You’re now in an interactive prompt. Type your questions and the bot will respond!


How It Works

  • Your question is passed to Google GenAI (if enabled), along with relevant GCP data.
  • The bot fetches info using the Google Cloud APIs (Monitoring, Logging, Compute, etc.).
  • It formats a human-readable answer back to you.

Example Prompts

Here are some example questions you can try out immediately:


List Custom Service Accounts

List all custom service accounts in my project

Expected Output:
A list of non-default service accounts, including email and description.


Get Virtual Machines Info

What virtual machines are running in us-central1-a?

Expected Output:
A table or list of VM names, zones, machine types, and statuses.


Check CPU Usage

Show CPU usage for the past 30 minutes

Expected Output:
A summary or graph data of recent CPU metrics for one or more instances.


Fetch Recent Logs

Give me logs from the last hour for compute instances

Expected Output:
Structured logs or summarized insights from Cloud Logging.


(Optional) Ask GenAI for Help

If you’ve added your GENAI_API_KEY in .env, try this:

What could explain the spike in CPU usage yesterday?

Expected Output:
An AI-generated interpretation of possible causes using both logs and metrics.


Exit the Bot

Type:

exit

or

quit

🛠️ Troubleshooting

  • Nothing happens when I type: Make sure you're in the venv and .env is properly configured.
  • Permission denied or not found errors: Ensure you've authenticated with gcloud auth application-default login or set a service account key.
  • "API not enabled" errors: Enable required APIs like:
    • Cloud Logging API
    • Cloud Monitoring API
    • Compute Engine API

📚 Want to Go Further?

  • Use project-specific prompts:

    Show VMs running in project `my-project-id`
    
  • Narrow logs by resource type or label:

    Get logs for VM `instance-1` in zone `us-central1-a`
    

If you'd like to contribute your own examples, please check the Contributing Guide and submit a PR!

Need help? Open an issue — we’re happy to help.