< Back

New-GcLogSink

Mon Jan 13, 2020 11:29 pm

NAME New-GcLogSink



SYNOPSIS

Creates a new log sink.





SYNTAX

New-GcLogSink [-Project <string>] [-SinkName] <string> -GcsBucketDestination <string> [-UniqueWriterIdentity

<SwitchParameter>] [-LogName <string>] [-Severity {Default | Debug | Info | Notice | Warning | Error | Critical |

Alert | Emergency}] [-Before <DateTime>] [-After <DateTime>] [-Filter <string>] [<CommonParameters>]



New-GcLogSink [-Project <string>] [-SinkName] <string> -BigQueryDataSetDestination <string> [-UniqueWriterIdentity

<SwitchParameter>] [-LogName <string>] [-Severity {Default | Debug | Info | Notice | Warning | Error | Critical |

Alert | Emergency}] [-Before <DateTime>] [-After <DateTime>] [-Filter <string>] [<CommonParameters>]



New-GcLogSink [-Project <string>] [-SinkName] <string> -PubSubTopicDestination <string> [-UniqueWriterIdentity

<SwitchParameter>] [-LogName <string>] [-Severity {Default | Debug | Info | Notice | Warning | Error | Critical |

Alert | Emergency}] [-Before <DateTime>] [-After <DateTime>] [-Filter <string>] [<CommonParameters>]





DESCRIPTION

Creates a new log sink to export log entries. The sink will be created in the default project if -Project is not

used. Will raise an error if the sink already exists. There are 3 possible destinations for the sink: Google Cloud

Storage bucket, Google BigQuery dataset and Google Cloud PubSub topic. The destinations must be created and given

appropriate permissions for log exporting (see

https://cloud.google.com/logging/docs/e ... horization) The cmdlet will not

create the destinations. The identity of the writer of the logs will be cloud-logs@system.gserviceaccount.com by

default if -UniqueWriterIdentity is not used.





PARAMETERS

-Project <string>

The project to create the sink in. If not set via PowerShell parameter processing, will default to the Cloud

SDK's DefaultProject property.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SinkName <string>

The name of the sink to be created. This name must be unique within the project.



Required? true

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-GcsBucketDestination <string>

The name of the Google Cloud Storage bucket that the sink will export the log entries to.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-BigQueryDataSetDestination <string>

The name of the Google BigQuery dataset that the the sink will export the log entries to.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-PubSubTopicDestination <string>

The name of the Google PubSub topic that the the sink will export the log entries to.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-UniqueWriterIdentity <SwitchParameter>

Determines the kind of IAM identity returned as writerIdentity in the new sink. If this value is not provided,

then the value returned as writerIdentity is cloud-logs@google.com. Otherwise, it will be a unique service

account.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-LogName <string>

If specified, the cmdlet will filter out log entries that are in the log LogName.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Severity <LogSeverity>

If specified, the cmdlet will filter out log entries with the specified severity.



Possible values: Default, Debug, Info, Notice, Warning, Error, Critical, Alert, Emergency



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Before <DateTime>

If specified, the cmdlet will filter out log entries that occur before this datetime.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-After <DateTime>

If specified, the cmdlet will filter out log entries that occur after this datetime.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Filter <string>

If specified, the cmdlet will filter out log entries that satisfy the filter.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



---------- EXAMPLE 1 ----------



PS C:\\> New-GcLogSink -SinkName "my-sink" -GcsBucketDestination "my-bucket"



This command creates a sink name "my-sink" that exports every log entry in the default project to the Google Cloud

Storage bucket "my-bucket". The identity of the writer of the logs will be cloud-logs@system.gserviceaccount.com.

---------- EXAMPLE 2 ----------



PS C:\\> New-GcLogSink -SinkName "my-sink" -BigQueryDataSetDestination "my_dataset" -LogName "my-log" -Project

"my-project"



This command creates a sink name "my-sink" that exports every log entry in the log "my-log" in the project

"my-project" to the Google Cloud BigQuery dataset "my_dataset" (also in the project "my-project"). The identity of

the writer of the logs will be cloud-logs@system.gserviceaccount.com.

---------- EXAMPLE 3 ----------



PS C:\\> New-GcLogSink -SinkName "my-sink" -PubSubTopicDestination "my_dataset" -Filter 'textPayload =

"textPayload"' -UniqueWriterIdentity



This command creates a sink name "my-sink" that exports every log entry that matches the provided filter to the

Google Cloud PubSub topic "my-topic". The identity of the writer of the logs will be a unique service account.



RELATED LINKS

[Log Sinks] (https://cloud.google.com/logging/docs/b ... epts#sinks)

[Exporting Logs] (https://cloud.google.com/logging/docs/e ... orted_logs)