google / cloud-monitoring
Stackdriver Monitoring Client for PHP
Requires
- php: ^8.0
- google/gax: ^1.36.0
Requires (Dev)
- google/cloud-core: ^1.52.7
- phpunit/phpunit: ^9.0
Suggests
- ext-protobuf: Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions.
- dev-main
- v1.12.1
- v1.12.0
- v1.11.1
- v1.11.0
- v1.10.3
- v1.10.2
- v1.10.1
- v1.10.0
- v1.9.2
- v1.9.1
- v1.9.0
- v1.8.0
- v1.7.1
- v1.7.0
- v1.6.0
- v1.5.1
- v1.5.0
- v1.4.0
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.21.0
- v0.20.2
- v0.20.1
- v0.20.0
- v0.19.0
- v0.18.0
- v0.17.0
- v0.16.5
- v0.16.4
- v0.16.3
- v0.16.2
- v0.16.1
- v0.16.0
- v0.15.0
- v0.14.2
- v0.14.1
- v0.14.0
- v0.13.0
- v0.12.2
- v0.12.1
- v0.12.0
- v0.11.4
- v0.11.3
- v0.11.2
- v0.11.1
- v0.11.0
- v0.10.1
- v0.10.0
- v0.9.4
- v0.9.3
- v0.9.2
- v0.9.1
- v0.9.0
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.3
- v0.7.2
- v0.7.1
- v0.7.0
- v0.6.1
- v0.6.0
- v0.5.0
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.0
- v0.2.1
- v0.2.0
- v0.1.0
- dev-policy-bot-ba514906-b998-40f5-add3-8bf7ac20aec3
- dev-policy-bot-7f5628cc-a5f9-4ccb-905d-5fa6adb9c952
This package is auto-updated.
Last update: 2024-12-12 23:15:30 UTC
README
NOTE: This repository is part of Google Cloud PHP. Any support requests, bug reports, or development contributions should be directed to that project.
Stackdriver Monitoring provides visibility into the performance, uptime, and overall health of cloud-powered applications.
Installation
To begin, install the preferred dependency manager for PHP, Composer.
Now install this component:
$ composer require google/cloud-monitoring
This component supports both REST over HTTP/1.1 and gRPC. In order to take advantage of the benefits offered by gRPC (such as streaming methods) please see our gRPC installation guide.
Authentication
Please see our Authentication guide for more information on authenticating your client. Once authenticated, you'll be ready to start making requests.
Sample
use Google\Api\Metric; use Google\Api\MonitoredResource; use Google\Cloud\Monitoring\V3\MetricServiceClient; use Google\Cloud\Monitoring\V3\Point; use Google\Cloud\Monitoring\V3\TimeInterval; use Google\Cloud\Monitoring\V3\TimeSeries; use Google\Cloud\Monitoring\V3\TypedValue; use Google\Protobuf\Timestamp; $metricServiceClient = new MetricServiceClient(); $formattedProjectName = $metricServiceClient->projectName($projectId); $labels = [ 'instance_id' => $instanceId, 'zone' => $zone, ]; $m = new Metric(); $m->setType('custom.googleapis.com/my_metric'); $r = new MonitoredResource(); $r->setType('gce_instance'); $r->setLabels($labels); $value = new TypedValue(); $value->setDoubleValue(3.14); $timestamp = new Timestamp(); $timestamp->setSeconds(time()); $interval = new TimeInterval(); $interval->setStartTime($timestamp); $interval->setEndTime($timestamp); $point = new Point(); $point->setValue($value); $point->setInterval($interval); $points = [$point]; $timeSeries = new TimeSeries(); $timeSeries->setMetric($m); $timeSeries->setResource($r); $timeSeries->setPoints($points); try { $metricServiceClient->createTimeSeries($formattedProjectName, [$timeSeries]); print('Successfully submitted a time series' . PHP_EOL); } finally { $metricServiceClient->close(); }
Debugging
Please see our Debugging guide for more information about the debugging tools.
Version
This component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in any minor or patch releases. We will address issues and requests with the highest priority.
Next Steps
- Understand the official documentation.
- Take a look at in-depth usage samples.