Stackdriver Logging Client - Class Metric (1.26.0)

Reference documentation and code samples for the Stackdriver Logging Client class Metric.

A metric counts the number of log entries that match a given filter. You can use these metrics to create charts and alerting policies in Stackdriver Monitoring .

Example:

 use Google\Cloud\Logging\LoggingClient;

$logging = new LoggingClient();

$metric = $logging->metric('my-metric'); 

Methods

__construct

Parameters
Name
Description
connection
Google\Cloud\Logging\Connection\ConnectionInterface

Represents a connection to Cloud Logging.

name
string

The metric's name.

projectId
string

The project's ID.

info
array

[optional] The metric's metadata.

exists

Check whether or not the metric exists.

Example:

 if ($metric->exists()) {
    echo 'Metric exists!';
} 
Parameter
Name
Description
options
array

[optional] Configuration Options

Returns
Type
Description
bool

delete

Delete the metric.

Example:

 $metric->delete(); 
Parameter
Name
Description
options
array

[optional] Configuration Options.

update

Update the metric. Please note this will trigger a network request if cached data is not available to perform the update with.

Example:

 $metric->update([
    'description' => 'A description for my metric.'
]); 
Parameters
Name
Description
metadata
array

The data to update.

↳ description
string

A description of the metric.

↳ filter
string

An advanced logs filter .

options
array

[optional] Configuration Options.

Returns
Type
Description
array

info

Retrieves the metric's details. If no metric data is cached a network request will be made to retrieve it.

Example:

 $info = $metric->info();
echo $info['description']; 
Parameter
Name
Description
options
array

[optional] Configuration Options.

Returns
Type
Description
array

reload

Triggers a network request to reload the metric's details.

Example:

 $metric->reload();
$info = $metric->info();
echo $info['description']; 
Parameter
Name
Description
options
array

[optional] Configuration Options.

Returns
Type
Description
array

name

Returns the metric's name.

Example:

 echo $metric->name(); 
Returns
Type
Description
string
Design a Mobile Site
View Site in Mobile | Classic
Share by: