Documentation ¶
Overview ¶
Package logging is an auto-generated package for the Cloud Logging API.
Writes log entries and manages your Cloud Logging configuration. The table entries below are presented in alphabetical order, not in order of common use. For explanations of the concepts found in the table entries, read the documentation at https://cloud.google.com/logging/docs.
Use of Context ¶
The ctx passed to NewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
For information about setting deadlines, reusing contexts, and more please visit pkg.go.dev/cloud.google.com/go.
Index ¶
- func ConfigExclusionPath(project, exclusion string) stringdeprecated
- func ConfigProjectPath(project string) stringdeprecated
- func ConfigSinkPath(project, sink string) stringdeprecated
- func DefaultAuthScopes() []string
- func LogPath(project, log string) stringdeprecated
- func MetricsMetricPath(project, metric string) stringdeprecated
- func MetricsProjectPath(project string) stringdeprecated
- func ProjectPath(project string) stringdeprecated
- type CallOptions
- type Client
- func (c *Client) Close() error
- func (c *Client) Connection() *grpc.ClientConn
- func (c *Client) DeleteLog(ctx context.Context, req *loggingpb.DeleteLogRequest, opts ...gax.CallOption) error
- func (c *Client) ListLogEntries(ctx context.Context, req *loggingpb.ListLogEntriesRequest, ...) *LogEntryIterator
- func (c *Client) ListLogs(ctx context.Context, req *loggingpb.ListLogsRequest, opts ...gax.CallOption) *StringIterator
- func (c *Client) ListMonitoredResourceDescriptors(ctx context.Context, req *loggingpb.ListMonitoredResourceDescriptorsRequest, ...) *MonitoredResourceDescriptorIterator
- func (c *Client) SetGoogleClientInfo(keyval ...string)
- func (c *Client) TailLogEntries(ctx context.Context, opts ...gax.CallOption) (loggingpb.LoggingServiceV2_TailLogEntriesClient, error)
- func (c *Client) WriteLogEntries(ctx context.Context, req *loggingpb.WriteLogEntriesRequest, ...) (*loggingpb.WriteLogEntriesResponse, error)
- type ConfigCallOptions
- type ConfigClient
- func (c *ConfigClient) Close() error
- func (c *ConfigClient) Connection() *grpc.ClientConn
- func (c *ConfigClient) CreateBucket(ctx context.Context, req *loggingpb.CreateBucketRequest, ...) (*loggingpb.LogBucket, error)
- func (c *ConfigClient) CreateExclusion(ctx context.Context, req *loggingpb.CreateExclusionRequest, ...) (*loggingpb.LogExclusion, error)
- func (c *ConfigClient) CreateSink(ctx context.Context, req *loggingpb.CreateSinkRequest, opts ...gax.CallOption) (*loggingpb.LogSink, error)
- func (c *ConfigClient) CreateView(ctx context.Context, req *loggingpb.CreateViewRequest, opts ...gax.CallOption) (*loggingpb.LogView, error)
- func (c *ConfigClient) DeleteBucket(ctx context.Context, req *loggingpb.DeleteBucketRequest, ...) error
- func (c *ConfigClient) DeleteExclusion(ctx context.Context, req *loggingpb.DeleteExclusionRequest, ...) error
- func (c *ConfigClient) DeleteSink(ctx context.Context, req *loggingpb.DeleteSinkRequest, opts ...gax.CallOption) error
- func (c *ConfigClient) DeleteView(ctx context.Context, req *loggingpb.DeleteViewRequest, opts ...gax.CallOption) error
- func (c *ConfigClient) GetBucket(ctx context.Context, req *loggingpb.GetBucketRequest, opts ...gax.CallOption) (*loggingpb.LogBucket, error)
- func (c *ConfigClient) GetCmekSettings(ctx context.Context, req *loggingpb.GetCmekSettingsRequest, ...) (*loggingpb.CmekSettings, error)
- func (c *ConfigClient) GetExclusion(ctx context.Context, req *loggingpb.GetExclusionRequest, ...) (*loggingpb.LogExclusion, error)
- func (c *ConfigClient) GetSink(ctx context.Context, req *loggingpb.GetSinkRequest, opts ...gax.CallOption) (*loggingpb.LogSink, error)
- func (c *ConfigClient) GetView(ctx context.Context, req *loggingpb.GetViewRequest, opts ...gax.CallOption) (*loggingpb.LogView, error)
- func (c *ConfigClient) ListBuckets(ctx context.Context, req *loggingpb.ListBucketsRequest, opts ...gax.CallOption) *LogBucketIterator
- func (c *ConfigClient) ListExclusions(ctx context.Context, req *loggingpb.ListExclusionsRequest, ...) *LogExclusionIterator
- func (c *ConfigClient) ListSinks(ctx context.Context, req *loggingpb.ListSinksRequest, opts ...gax.CallOption) *LogSinkIterator
- func (c *ConfigClient) ListViews(ctx context.Context, req *loggingpb.ListViewsRequest, opts ...gax.CallOption) *LogViewIterator
- func (cc *ConfigClient) SetGoogleClientInfo(keyval ...string)
- func (c *ConfigClient) UndeleteBucket(ctx context.Context, req *loggingpb.UndeleteBucketRequest, ...) error
- func (c *ConfigClient) UpdateBucket(ctx context.Context, req *loggingpb.UpdateBucketRequest, ...) (*loggingpb.LogBucket, error)
- func (c *ConfigClient) UpdateCmekSettings(ctx context.Context, req *loggingpb.UpdateCmekSettingsRequest, ...) (*loggingpb.CmekSettings, error)
- func (c *ConfigClient) UpdateExclusion(ctx context.Context, req *loggingpb.UpdateExclusionRequest, ...) (*loggingpb.LogExclusion, error)
- func (c *ConfigClient) UpdateSink(ctx context.Context, req *loggingpb.UpdateSinkRequest, opts ...gax.CallOption) (*loggingpb.LogSink, error)
- func (c *ConfigClient) UpdateView(ctx context.Context, req *loggingpb.UpdateViewRequest, opts ...gax.CallOption) (*loggingpb.LogView, error)
- type LogBucketIterator
- type LogEntryIterator
- type LogExclusionIterator
- type LogMetricIterator
- type LogSinkIterator
- type LogViewIterator
- type MetricsCallOptions
- type MetricsClient
- func (c *MetricsClient) Close() error
- func (c *MetricsClient) Connection() *grpc.ClientConn
- func (c *MetricsClient) CreateLogMetric(ctx context.Context, req *loggingpb.CreateLogMetricRequest, ...) (*loggingpb.LogMetric, error)
- func (c *MetricsClient) DeleteLogMetric(ctx context.Context, req *loggingpb.DeleteLogMetricRequest, ...) error
- func (c *MetricsClient) GetLogMetric(ctx context.Context, req *loggingpb.GetLogMetricRequest, ...) (*loggingpb.LogMetric, error)
- func (c *MetricsClient) ListLogMetrics(ctx context.Context, req *loggingpb.ListLogMetricsRequest, ...) *LogMetricIterator
- func (mc *MetricsClient) SetGoogleClientInfo(keyval ...string)
- func (c *MetricsClient) UpdateLogMetric(ctx context.Context, req *loggingpb.UpdateLogMetricRequest, ...) (*loggingpb.LogMetric, error)
- type MonitoredResourceDescriptorIterator
- type StringIterator
Examples ¶
- Client.DeleteLog
- Client.ListLogEntries
- Client.ListLogs
- Client.ListMonitoredResourceDescriptors
- Client.TailLogEntries
- Client.WriteLogEntries
- ConfigClient.CreateBucket
- ConfigClient.CreateExclusion
- ConfigClient.CreateSink
- ConfigClient.CreateView
- ConfigClient.DeleteBucket
- ConfigClient.DeleteExclusion
- ConfigClient.DeleteSink
- ConfigClient.DeleteView
- ConfigClient.GetBucket
- ConfigClient.GetCmekSettings
- ConfigClient.GetExclusion
- ConfigClient.GetSink
- ConfigClient.GetView
- ConfigClient.ListBuckets
- ConfigClient.ListExclusions
- ConfigClient.ListSinks
- ConfigClient.ListViews
- ConfigClient.UndeleteBucket
- ConfigClient.UpdateBucket
- ConfigClient.UpdateCmekSettings
- ConfigClient.UpdateExclusion
- ConfigClient.UpdateSink
- ConfigClient.UpdateView
- MetricsClient.CreateLogMetric
- MetricsClient.DeleteLogMetric
- MetricsClient.GetLogMetric
- MetricsClient.ListLogMetrics
- MetricsClient.UpdateLogMetric
- NewClient
- NewConfigClient
- NewMetricsClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigExclusionPath
deprecated
func ConfigProjectPath
deprecated
func ConfigSinkPath
deprecated
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
func MetricsMetricPath
deprecated
func MetricsProjectPath
deprecated
func ProjectPath
deprecated
Types ¶
type CallOptions ¶
type CallOptions struct { DeleteLog []gax.CallOption WriteLogEntries []gax.CallOption ListLogEntries []gax.CallOption ListMonitoredResourceDescriptors []gax.CallOption ListLogs []gax.CallOption TailLogEntries []gax.CallOption }
CallOptions contains the retry settings for each method of Client.
type Client ¶
type Client struct { // The call options for this service. CallOptions *CallOptions // contains filtered or unexported fields }
Client is a client for interacting with Cloud Logging API.
Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
func NewClient ¶
NewClient creates a new logging service v2 client.
Service for ingesting and querying logs.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" ) func main() { ctx := context.Background() c, err := logging.NewClient(ctx) if err != nil { // TODO: Handle error. } // TODO: Use client. _ = c }
Output:
func (*Client) Close ¶
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*Client) Connection ¶
func (c *Client) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated.
func (*Client) DeleteLog ¶
func (c *Client) DeleteLog(ctx context.Context, req *loggingpb.DeleteLogRequest, opts ...gax.CallOption) error
DeleteLog deletes all the log entries in a log. The log reappears if it receives new entries. Log entries written shortly before the delete operation might not be deleted. Entries received after the delete operation with a timestamp before the operation will be deleted.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { ctx := context.Background() c, err := logging.NewClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.DeleteLogRequest{ // TODO: Fill request struct fields. } err = c.DeleteLog(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*Client) ListLogEntries ¶
func (c *Client) ListLogEntries(ctx context.Context, req *loggingpb.ListLogEntriesRequest, opts ...gax.CallOption) *LogEntryIterator
ListLogEntries lists log entries. Use this method to retrieve log entries that originated from a project/folder/organization/billing account. For ways to export log entries, see Exporting Logs (at https://cloud.google.com/logging/docs/export).
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" "google.golang.org/api/iterator" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" // import "google.golang.org/api/iterator" ctx := context.Background() c, err := logging.NewClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.ListLogEntriesRequest{ // TODO: Fill request struct fields. } it := c.ListLogEntries(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*Client) ListLogs ¶
func (c *Client) ListLogs(ctx context.Context, req *loggingpb.ListLogsRequest, opts ...gax.CallOption) *StringIterator
ListLogs lists the logs in projects, organizations, folders, or billing accounts. Only logs that have entries are listed.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" "google.golang.org/api/iterator" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" // import "google.golang.org/api/iterator" ctx := context.Background() c, err := logging.NewClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.ListLogsRequest{ // TODO: Fill request struct fields. } it := c.ListLogs(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*Client) ListMonitoredResourceDescriptors ¶
func (c *Client) ListMonitoredResourceDescriptors(ctx context.Context, req *loggingpb.ListMonitoredResourceDescriptorsRequest, opts ...gax.CallOption) *MonitoredResourceDescriptorIterator
ListMonitoredResourceDescriptors lists the descriptors for monitored resource types used by Logging.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" "google.golang.org/api/iterator" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" // import "google.golang.org/api/iterator" ctx := context.Background() c, err := logging.NewClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.ListMonitoredResourceDescriptorsRequest{ // TODO: Fill request struct fields. } it := c.ListMonitoredResourceDescriptors(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*Client) SetGoogleClientInfo ¶
SetGoogleClientInfo sets the name and version of the application in the `x-goog-api-client` header passed on each request. Also passes any provided key-value pairs. Intended for use by Google-written clients.
Internal use only.
func (*Client) TailLogEntries ¶ added in v1.2.0
func (c *Client) TailLogEntries(ctx context.Context, opts ...gax.CallOption) (loggingpb.LoggingServiceV2_TailLogEntriesClient, error)
TailLogEntries streaming read of log entries as they are ingested. Until the stream is terminated, it will continue reading logs.
Example ¶
package main import ( "context" "io" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewClient(ctx) if err != nil { // TODO: Handle error. } stream, err := c.TailLogEntries(ctx) if err != nil { // TODO: Handle error. } go func() { reqs := []*loggingpb.TailLogEntriesRequest{ // TODO: Create requests. } for _, req := range reqs { if err := stream.Send(req); err != nil { // TODO: Handle error. } } stream.CloseSend() }() for { resp, err := stream.Recv() if err == io.EOF { break } if err != nil { // TODO: handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*Client) WriteLogEntries ¶
func (c *Client) WriteLogEntries(ctx context.Context, req *loggingpb.WriteLogEntriesRequest, opts ...gax.CallOption) (*loggingpb.WriteLogEntriesResponse, error)
WriteLogEntries writes log entries to Logging. This API method is the only way to send log entries to Logging. This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging libraries configured to use Logging. A single request may contain log entries for a maximum of 1000 different resources (projects, organizations, billing accounts or folders)
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.WriteLogEntriesRequest{ // TODO: Fill request struct fields. } resp, err := c.WriteLogEntries(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type ConfigCallOptions ¶
type ConfigCallOptions struct { ListBuckets []gax.CallOption GetBucket []gax.CallOption CreateBucket []gax.CallOption UpdateBucket []gax.CallOption DeleteBucket []gax.CallOption UndeleteBucket []gax.CallOption ListViews []gax.CallOption GetView []gax.CallOption CreateView []gax.CallOption UpdateView []gax.CallOption DeleteView []gax.CallOption ListSinks []gax.CallOption GetSink []gax.CallOption CreateSink []gax.CallOption UpdateSink []gax.CallOption DeleteSink []gax.CallOption ListExclusions []gax.CallOption GetExclusion []gax.CallOption CreateExclusion []gax.CallOption UpdateExclusion []gax.CallOption DeleteExclusion []gax.CallOption GetCmekSettings []gax.CallOption UpdateCmekSettings []gax.CallOption }
ConfigCallOptions contains the retry settings for each method of ConfigClient.
type ConfigClient ¶
type ConfigClient struct { // The call options for this service. CallOptions *ConfigCallOptions // contains filtered or unexported fields }
ConfigClient is a client for interacting with Cloud Logging API.
Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
func NewConfigClient ¶
func NewConfigClient(ctx context.Context, opts ...option.ClientOption) (*ConfigClient, error)
NewConfigClient creates a new config service v2 client.
Service for configuring sinks used to route log entries.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" ) func main() { ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } // TODO: Use client. _ = c }
Output:
func (*ConfigClient) Close ¶
func (c *ConfigClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*ConfigClient) Connection ¶
func (c *ConfigClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated.
func (*ConfigClient) CreateBucket ¶ added in v1.2.0
func (c *ConfigClient) CreateBucket(ctx context.Context, req *loggingpb.CreateBucketRequest, opts ...gax.CallOption) (*loggingpb.LogBucket, error)
CreateBucket creates a bucket that can be used to store log entries. Once a bucket has been created, the region cannot be changed.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.CreateBucketRequest{ // TODO: Fill request struct fields. } resp, err := c.CreateBucket(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) CreateExclusion ¶
func (c *ConfigClient) CreateExclusion(ctx context.Context, req *loggingpb.CreateExclusionRequest, opts ...gax.CallOption) (*loggingpb.LogExclusion, error)
CreateExclusion creates a new exclusion in a specified parent resource. Only log entries belonging to that resource can be excluded. You can have up to 10 exclusions in a resource.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.CreateExclusionRequest{ // TODO: Fill request struct fields. } resp, err := c.CreateExclusion(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) CreateSink ¶
func (c *ConfigClient) CreateSink(ctx context.Context, req *loggingpb.CreateSinkRequest, opts ...gax.CallOption) (*loggingpb.LogSink, error)
CreateSink creates a sink that exports specified log entries to a destination. The export of newly-ingested log entries begins immediately, unless the sink’s writer_identity is not permitted to write to the destination. A sink can export log entries only from the resource owning the sink.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.CreateSinkRequest{ // TODO: Fill request struct fields. } resp, err := c.CreateSink(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) CreateView ¶ added in v1.2.0
func (c *ConfigClient) CreateView(ctx context.Context, req *loggingpb.CreateViewRequest, opts ...gax.CallOption) (*loggingpb.LogView, error)
CreateView creates a view over logs in a bucket. A bucket may contain a maximum of 50 views.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.CreateViewRequest{ // TODO: Fill request struct fields. } resp, err := c.CreateView(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) DeleteBucket ¶ added in v1.2.0
func (c *ConfigClient) DeleteBucket(ctx context.Context, req *loggingpb.DeleteBucketRequest, opts ...gax.CallOption) error
DeleteBucket deletes a bucket. Moves the bucket to the DELETE_REQUESTED state. After 7 days, the bucket will be purged and all logs in the bucket will be permanently deleted.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.DeleteBucketRequest{ // TODO: Fill request struct fields. } err = c.DeleteBucket(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*ConfigClient) DeleteExclusion ¶
func (c *ConfigClient) DeleteExclusion(ctx context.Context, req *loggingpb.DeleteExclusionRequest, opts ...gax.CallOption) error
DeleteExclusion deletes an exclusion.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.DeleteExclusionRequest{ // TODO: Fill request struct fields. } err = c.DeleteExclusion(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*ConfigClient) DeleteSink ¶
func (c *ConfigClient) DeleteSink(ctx context.Context, req *loggingpb.DeleteSinkRequest, opts ...gax.CallOption) error
DeleteSink deletes a sink. If the sink has a unique writer_identity, then that service account is also deleted.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.DeleteSinkRequest{ // TODO: Fill request struct fields. } err = c.DeleteSink(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*ConfigClient) DeleteView ¶ added in v1.2.0
func (c *ConfigClient) DeleteView(ctx context.Context, req *loggingpb.DeleteViewRequest, opts ...gax.CallOption) error
DeleteView deletes a view from a bucket.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.DeleteViewRequest{ // TODO: Fill request struct fields. } err = c.DeleteView(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*ConfigClient) GetBucket ¶ added in v1.1.0
func (c *ConfigClient) GetBucket(ctx context.Context, req *loggingpb.GetBucketRequest, opts ...gax.CallOption) (*loggingpb.LogBucket, error)
GetBucket gets a bucket.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.GetBucketRequest{ // TODO: Fill request struct fields. } resp, err := c.GetBucket(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) GetCmekSettings ¶ added in v1.1.0
func (c *ConfigClient) GetCmekSettings(ctx context.Context, req *loggingpb.GetCmekSettingsRequest, opts ...gax.CallOption) (*loggingpb.CmekSettings, error)
GetCmekSettings gets the Logs Router CMEK settings for the given resource.
Note: CMEK for the Logs Router can currently only be configured for GCP organizations. Once configured, it applies to all projects and folders in the GCP organization.
See Enabling CMEK for Logs Router (at https://cloud.google.com/logging/docs/routing/managed-encryption) for more information.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.GetCmekSettingsRequest{ // TODO: Fill request struct fields. } resp, err := c.GetCmekSettings(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) GetExclusion ¶
func (c *ConfigClient) GetExclusion(ctx context.Context, req *loggingpb.GetExclusionRequest, opts ...gax.CallOption) (*loggingpb.LogExclusion, error)
GetExclusion gets the description of an exclusion.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.GetExclusionRequest{ // TODO: Fill request struct fields. } resp, err := c.GetExclusion(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) GetSink ¶
func (c *ConfigClient) GetSink(ctx context.Context, req *loggingpb.GetSinkRequest, opts ...gax.CallOption) (*loggingpb.LogSink, error)
GetSink gets a sink.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.GetSinkRequest{ // TODO: Fill request struct fields. } resp, err := c.GetSink(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) GetView ¶ added in v1.2.0
func (c *ConfigClient) GetView(ctx context.Context, req *loggingpb.GetViewRequest, opts ...gax.CallOption) (*loggingpb.LogView, error)
GetView gets a view.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.GetViewRequest{ // TODO: Fill request struct fields. } resp, err := c.GetView(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) ListBuckets ¶ added in v1.1.0
func (c *ConfigClient) ListBuckets(ctx context.Context, req *loggingpb.ListBucketsRequest, opts ...gax.CallOption) *LogBucketIterator
ListBuckets lists buckets.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" "google.golang.org/api/iterator" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" // import "google.golang.org/api/iterator" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.ListBucketsRequest{ // TODO: Fill request struct fields. } it := c.ListBuckets(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*ConfigClient) ListExclusions ¶
func (c *ConfigClient) ListExclusions(ctx context.Context, req *loggingpb.ListExclusionsRequest, opts ...gax.CallOption) *LogExclusionIterator
ListExclusions lists all the exclusions in a parent resource.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" "google.golang.org/api/iterator" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" // import "google.golang.org/api/iterator" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.ListExclusionsRequest{ // TODO: Fill request struct fields. } it := c.ListExclusions(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*ConfigClient) ListSinks ¶
func (c *ConfigClient) ListSinks(ctx context.Context, req *loggingpb.ListSinksRequest, opts ...gax.CallOption) *LogSinkIterator
ListSinks lists sinks.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" "google.golang.org/api/iterator" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" // import "google.golang.org/api/iterator" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.ListSinksRequest{ // TODO: Fill request struct fields. } it := c.ListSinks(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*ConfigClient) ListViews ¶ added in v1.2.0
func (c *ConfigClient) ListViews(ctx context.Context, req *loggingpb.ListViewsRequest, opts ...gax.CallOption) *LogViewIterator
ListViews lists views on a bucket.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" "google.golang.org/api/iterator" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" // import "google.golang.org/api/iterator" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.ListViewsRequest{ // TODO: Fill request struct fields. } it := c.ListViews(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*ConfigClient) SetGoogleClientInfo ¶
func (cc *ConfigClient) SetGoogleClientInfo(keyval ...string)
SetGoogleClientInfo sets the name and version of the application in the `x-goog-api-client` header passed on each request. Also passes any provided key-value pairs. Intended for use by Google-written clients.
Internal use only.
func (*ConfigClient) UndeleteBucket ¶ added in v1.2.0
func (c *ConfigClient) UndeleteBucket(ctx context.Context, req *loggingpb.UndeleteBucketRequest, opts ...gax.CallOption) error
UndeleteBucket undeletes a bucket. A bucket that has been deleted may be undeleted within the grace period of 7 days.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.UndeleteBucketRequest{ // TODO: Fill request struct fields. } err = c.UndeleteBucket(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*ConfigClient) UpdateBucket ¶ added in v1.1.0
func (c *ConfigClient) UpdateBucket(ctx context.Context, req *loggingpb.UpdateBucketRequest, opts ...gax.CallOption) (*loggingpb.LogBucket, error)
UpdateBucket updates a bucket. This method replaces the following fields in the existing bucket with values from the new bucket: retention_period
If the retention period is decreased and the bucket is locked, FAILED_PRECONDITION will be returned.
If the bucket has a LifecycleState of DELETE_REQUESTED, FAILED_PRECONDITION will be returned.
A buckets region may not be modified after it is created.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.UpdateBucketRequest{ // TODO: Fill request struct fields. } resp, err := c.UpdateBucket(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) UpdateCmekSettings ¶ added in v1.1.0
func (c *ConfigClient) UpdateCmekSettings(ctx context.Context, req *loggingpb.UpdateCmekSettingsRequest, opts ...gax.CallOption) (*loggingpb.CmekSettings, error)
UpdateCmekSettings updates the Logs Router CMEK settings for the given resource.
Note: CMEK for the Logs Router can currently only be configured for GCP organizations. Once configured, it applies to all projects and folders in the GCP organization.
UpdateCmekSettings will fail if 1) kms_key_name is invalid, or 2) the associated service account does not have the required roles/cloudkms.cryptoKeyEncrypterDecrypter role assigned for the key, or 3) access to the key is disabled.
See Enabling CMEK for Logs Router (at https://cloud.google.com/logging/docs/routing/managed-encryption) for more information.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.UpdateCmekSettingsRequest{ // TODO: Fill request struct fields. } resp, err := c.UpdateCmekSettings(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) UpdateExclusion ¶
func (c *ConfigClient) UpdateExclusion(ctx context.Context, req *loggingpb.UpdateExclusionRequest, opts ...gax.CallOption) (*loggingpb.LogExclusion, error)
UpdateExclusion changes one or more properties of an existing exclusion.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.UpdateExclusionRequest{ // TODO: Fill request struct fields. } resp, err := c.UpdateExclusion(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) UpdateSink ¶
func (c *ConfigClient) UpdateSink(ctx context.Context, req *loggingpb.UpdateSinkRequest, opts ...gax.CallOption) (*loggingpb.LogSink, error)
UpdateSink updates a sink. This method replaces the following fields in the existing sink with values from the new sink: destination, and filter.
The updated sink might also have a new writer_identity; see the unique_writer_identity field.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.UpdateSinkRequest{ // TODO: Fill request struct fields. } resp, err := c.UpdateSink(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ConfigClient) UpdateView ¶ added in v1.2.0
func (c *ConfigClient) UpdateView(ctx context.Context, req *loggingpb.UpdateViewRequest, opts ...gax.CallOption) (*loggingpb.LogView, error)
UpdateView updates a view. This method replaces the following fields in the existing view with values from the new view: filter.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewConfigClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.UpdateViewRequest{ // TODO: Fill request struct fields. } resp, err := c.UpdateView(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type LogBucketIterator ¶ added in v1.1.0
type LogBucketIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*loggingpb.LogBucket, nextPageToken string, err error) // contains filtered or unexported fields }
LogBucketIterator manages a stream of *loggingpb.LogBucket.
func (*LogBucketIterator) Next ¶ added in v1.1.0
func (it *LogBucketIterator) Next() (*loggingpb.LogBucket, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*LogBucketIterator) PageInfo ¶ added in v1.1.0
func (it *LogBucketIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type LogEntryIterator ¶
type LogEntryIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*loggingpb.LogEntry, nextPageToken string, err error) // contains filtered or unexported fields }
LogEntryIterator manages a stream of *loggingpb.LogEntry.
func (*LogEntryIterator) Next ¶
func (it *LogEntryIterator) Next() (*loggingpb.LogEntry, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*LogEntryIterator) PageInfo ¶
func (it *LogEntryIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type LogExclusionIterator ¶
type LogExclusionIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*loggingpb.LogExclusion, nextPageToken string, err error) // contains filtered or unexported fields }
LogExclusionIterator manages a stream of *loggingpb.LogExclusion.
func (*LogExclusionIterator) Next ¶
func (it *LogExclusionIterator) Next() (*loggingpb.LogExclusion, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*LogExclusionIterator) PageInfo ¶
func (it *LogExclusionIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type LogMetricIterator ¶
type LogMetricIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*loggingpb.LogMetric, nextPageToken string, err error) // contains filtered or unexported fields }
LogMetricIterator manages a stream of *loggingpb.LogMetric.
func (*LogMetricIterator) Next ¶
func (it *LogMetricIterator) Next() (*loggingpb.LogMetric, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*LogMetricIterator) PageInfo ¶
func (it *LogMetricIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type LogSinkIterator ¶
type LogSinkIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*loggingpb.LogSink, nextPageToken string, err error) // contains filtered or unexported fields }
LogSinkIterator manages a stream of *loggingpb.LogSink.
func (*LogSinkIterator) Next ¶
func (it *LogSinkIterator) Next() (*loggingpb.LogSink, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*LogSinkIterator) PageInfo ¶
func (it *LogSinkIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type LogViewIterator ¶ added in v1.2.0
type LogViewIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*loggingpb.LogView, nextPageToken string, err error) // contains filtered or unexported fields }
LogViewIterator manages a stream of *loggingpb.LogView.
func (*LogViewIterator) Next ¶ added in v1.2.0
func (it *LogViewIterator) Next() (*loggingpb.LogView, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*LogViewIterator) PageInfo ¶ added in v1.2.0
func (it *LogViewIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type MetricsCallOptions ¶
type MetricsCallOptions struct { ListLogMetrics []gax.CallOption GetLogMetric []gax.CallOption CreateLogMetric []gax.CallOption UpdateLogMetric []gax.CallOption DeleteLogMetric []gax.CallOption }
MetricsCallOptions contains the retry settings for each method of MetricsClient.
type MetricsClient ¶
type MetricsClient struct { // The call options for this service. CallOptions *MetricsCallOptions // contains filtered or unexported fields }
MetricsClient is a client for interacting with Cloud Logging API.
Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
func NewMetricsClient ¶
func NewMetricsClient(ctx context.Context, opts ...option.ClientOption) (*MetricsClient, error)
NewMetricsClient creates a new metrics service v2 client.
Service for configuring logs-based metrics.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" ) func main() { ctx := context.Background() c, err := logging.NewMetricsClient(ctx) if err != nil { // TODO: Handle error. } // TODO: Use client. _ = c }
Output:
func (*MetricsClient) Close ¶
func (c *MetricsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*MetricsClient) Connection ¶
func (c *MetricsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated.
func (*MetricsClient) CreateLogMetric ¶
func (c *MetricsClient) CreateLogMetric(ctx context.Context, req *loggingpb.CreateLogMetricRequest, opts ...gax.CallOption) (*loggingpb.LogMetric, error)
CreateLogMetric creates a logs-based metric.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewMetricsClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.CreateLogMetricRequest{ // TODO: Fill request struct fields. } resp, err := c.CreateLogMetric(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*MetricsClient) DeleteLogMetric ¶
func (c *MetricsClient) DeleteLogMetric(ctx context.Context, req *loggingpb.DeleteLogMetricRequest, opts ...gax.CallOption) error
DeleteLogMetric deletes a logs-based metric.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { ctx := context.Background() c, err := logging.NewMetricsClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.DeleteLogMetricRequest{ // TODO: Fill request struct fields. } err = c.DeleteLogMetric(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*MetricsClient) GetLogMetric ¶
func (c *MetricsClient) GetLogMetric(ctx context.Context, req *loggingpb.GetLogMetricRequest, opts ...gax.CallOption) (*loggingpb.LogMetric, error)
GetLogMetric gets a logs-based metric.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewMetricsClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.GetLogMetricRequest{ // TODO: Fill request struct fields. } resp, err := c.GetLogMetric(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*MetricsClient) ListLogMetrics ¶
func (c *MetricsClient) ListLogMetrics(ctx context.Context, req *loggingpb.ListLogMetricsRequest, opts ...gax.CallOption) *LogMetricIterator
ListLogMetrics lists logs-based metrics.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" "google.golang.org/api/iterator" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" // import "google.golang.org/api/iterator" ctx := context.Background() c, err := logging.NewMetricsClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.ListLogMetricsRequest{ // TODO: Fill request struct fields. } it := c.ListLogMetrics(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*MetricsClient) SetGoogleClientInfo ¶
func (mc *MetricsClient) SetGoogleClientInfo(keyval ...string)
SetGoogleClientInfo sets the name and version of the application in the `x-goog-api-client` header passed on each request. Also passes any provided key-value pairs. Intended for use by Google-written clients.
Internal use only.
func (*MetricsClient) UpdateLogMetric ¶
func (c *MetricsClient) UpdateLogMetric(ctx context.Context, req *loggingpb.UpdateLogMetricRequest, opts ...gax.CallOption) (*loggingpb.LogMetric, error)
UpdateLogMetric creates or updates a logs-based metric.
Example ¶
package main import ( "context" logging "cloud.google.com/go/logging/apiv2" loggingpb "google.golang.org/genproto/googleapis/logging/v2" ) func main() { // import loggingpb "google.golang.org/genproto/googleapis/logging/v2" ctx := context.Background() c, err := logging.NewMetricsClient(ctx) if err != nil { // TODO: Handle error. } req := &loggingpb.UpdateLogMetricRequest{ // TODO: Fill request struct fields. } resp, err := c.UpdateLogMetric(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type MonitoredResourceDescriptorIterator ¶
type MonitoredResourceDescriptorIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*monitoredrespb.MonitoredResourceDescriptor, nextPageToken string, err error) // contains filtered or unexported fields }
MonitoredResourceDescriptorIterator manages a stream of *monitoredrespb.MonitoredResourceDescriptor.
func (*MonitoredResourceDescriptorIterator) Next ¶
func (it *MonitoredResourceDescriptorIterator) Next() (*monitoredrespb.MonitoredResourceDescriptor, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*MonitoredResourceDescriptorIterator) PageInfo ¶
func (it *MonitoredResourceDescriptorIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type StringIterator ¶
type StringIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []string, nextPageToken string, err error) // contains filtered or unexported fields }
StringIterator manages a stream of string.
func (*StringIterator) Next ¶
func (it *StringIterator) Next() (string, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*StringIterator) PageInfo ¶
func (it *StringIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.