- How do I install and configure google/cloud-monitoring in a Laravel application?
- Install it with Composer by running composer require google/cloud-monitoring. The package is a framework-agnostic Google Cloud PHP client, so you typically register a small service provider that binds AlertPolicyServiceClient, MetricServiceClient, or the V3 clients into Laravel's container. Keep credentials in .env or rely on the GCP metadata server when running on Cloud Run, GKE, or Compute Engine.
- Which Laravel and PHP versions does google/cloud-monitoring support?
- The client requires PHP 8.1 or newer and works with Laravel 9 and 10 in typical setups, since it is a plain PHP library resolved through Composer. Older Laravel versions may work but are not officially tested. Because the package follows Google Cloud PHP release rules, check your Composer constraints if you pin older guzzle or google/common-protos versions.
- How do I authenticate google/cloud-monitoring in Laravel without hardcoding GCP credentials?
- The client uses Google Application Default Credentials. In Laravel, point GOOGLE_APPLICATION_CREDENTIALS at a service account JSON file stored outside the repository, or use workload identity federation or the metadata server when the app runs on GKE, Cloud Run, or App Engine. Avoid committing key files and load secrets from your vault or environment configuration.
- Should I use REST or gRPC with google/cloud-monitoring in Laravel?
- REST works out of the box with no extra PHP extensions and is the safest starting point for most Laravel apps. gRPC requires the grpc and protobuf PHP extensions plus protobuf tooling, but it enables streaming methods and usually lower latency for high-volume metric writes. A common pattern is REST in development and gRPC in production once the extension is baked into your container image.
- How do I send custom business metrics from Laravel to Google Cloud Monitoring?
- Create a custom metric descriptor in Cloud Monitoring, then write time series with MetricServiceClient using createTimeSeries. Attach labels such as tenant_id, environment, or endpoint so you can slice data per client, and emit values from middleware, event listeners, or queued jobs. Batch writes where possible to stay within API quotas.
- Can google/cloud-monitoring monitor Laravel queue jobs and scheduled tasks?
- Yes. Register listeners for Laravel queue events such as JobProcessed, JobFailed, and JobExceptionOccurred, and emit counters or latency distributions to Cloud Monitoring. For scheduled tasks, hook into the scheduler's after and failure callbacks. This gives you job duration, failure rates, and backlog visibility in the same dashboards as your HTTP metrics.
- How do I wire Google Cloud Monitoring alerts into Slack or PagerDuty from Laravel?
- The package itself writes metrics and manages alert policies; notification delivery is handled by Cloud Monitoring notification channels, which support Slack, PagerDuty, webhooks, and email. You create channels in GCP, reference them in your alert policy, and optionally have Cloud Monitoring webhooks hit a Laravel endpoint for custom routing. Keep escalation logic in Laravel if you need per-team or per-tenant routing.
- What are the cost and quota limits of using google/cloud-monitoring with a high-traffic Laravel app?
- Cloud Monitoring charges per metric ingested after the free tier and applies quotas on time series and API requests, so high-cardinality labels like user_id or request_id can get expensive fast. Model your expected series count before launch, aggregate in Laravel where possible, and avoid one time series per request. Use labels such as environment and tenant only when you actually need to filter by them.
- What is the performance overhead of google/cloud-monitoring in a Laravel API?
- Metric writes are network calls, so never call Cloud Monitoring synchronously on the request path for high-traffic endpoints. Dispatch writes to a queued job or buffer them and flush in batches, and review the client's retry and timeout settings. Benchmark REST versus gRPC with your own payload sizes if you emit many series per request.
- What are alternatives to google/cloud-monitoring for Laravel monitoring, and is the package still maintained?
- Open-source options include the Prometheus PHP client, OpenTelemetry, and self-hosted Grafana stacks, while SaaS alternatives include Datadog, New Relic, and Sentry. Choose google/cloud-monitoring if your Laravel app already runs on GCP and you want native alerting and dashboards; otherwise vendor lock-in and credential overhead may outweigh the benefits. The package is GA, part of google-cloud-php, and follows a no-breaking-changes policy for minor and patch releases.