Class: Gcloud::Logging::Sink
- Inherits:
-
Object
- Object
- Gcloud::Logging::Sink
- Defined in:
- lib/gcloud/logging/sink.rb,
lib/gcloud/logging/sink/list.rb
Overview
# Sink
Used to export log entries outside Cloud Logging. When you create a sink, new log entries are exported. Cloud Logging does not send previously-ingested log entries to the sink’s destination.
Before creating the sink, ensure that you have granted ‘[email protected]` permission to write logs to the destination. See [Permissions for writing exported logs](cloud.google.com/logging/docs/export/configure_export#setting_product_name_short_permissions_for_writing_exported_logs).
You can retrieve an existing sink with Project#sink.
Defined Under Namespace
Classes: List
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#delete ⇒ Boolean
Permanently deletes the logs-based sink.
-
#destination ⇒ Object
The export destination.
-
#destination=(destination) ⇒ Object
Updates the export destination.
-
#filter ⇒ Object
An [advanced logs filter](cloud.google.com/logging/docs/view/advanced_filters) that defines the log entries to be exported.
-
#filter=(filter) ⇒ Object
Updates the [advanced logs filter](cloud.google.com/logging/docs/view/advanced_filters) that defines the log entries to be exported.
-
#initialize ⇒ Sink
constructor
A new instance of Sink.
-
#name ⇒ Object
The client-assigned sink identifier.
-
#reload! ⇒ Object
(also: #refresh!)
Reloads the logs-based sink with current data from the Logging service.
-
#save ⇒ Object
Updates the logs-based sink.
-
#unspecified? ⇒ Boolean
Helper to determine if the sink’s version is ‘VERSION_FORMAT_UNSPECIFIED`.
-
#v1? ⇒ Boolean
Helper to determine if the sink’s version is ‘V1`.
-
#v2? ⇒ Boolean
Helper to determine if the sink’s version is ‘V2`.
-
#version ⇒ Object
The log entry version used when exporting log entries from this sink.
-
#version=(version) ⇒ Object
Updates the log entry version used when exporting log entries from this sink.
Constructor Details
#initialize ⇒ Sink
Returns a new instance of Sink.
69 70 71 72 |
# File 'lib/gcloud/logging/sink.rb', line 69 def initialize @service = nil @grpc = Google::Logging::V2::LogSink.new end |
Instance Attribute Details
#grpc ⇒ Object
65 66 67 |
# File 'lib/gcloud/logging/sink.rb', line 65 def grpc @grpc end |
#service ⇒ Object
61 62 63 |
# File 'lib/gcloud/logging/sink.rb', line 61 def service @service end |
Class Method Details
.from_grpc(grpc, service) ⇒ Object
207 208 209 210 211 212 |
# File 'lib/gcloud/logging/sink.rb', line 207 def self.from_grpc grpc, service new.tap do |f| f.grpc = grpc f.service = service end end |
.resolve_version(version) ⇒ Object
216 217 218 219 220 221 |
# File 'lib/gcloud/logging/sink.rb', line 216 def self.resolve_version version ver = version.to_s.upcase.to_sym ver = Google::Logging::V2::LogSink::VersionFormat.resolve ver return ver if ver Google::Logging::V2::LogSink::VersionFormat::VERSION_FORMAT_UNSPECIFIED end |
Instance Method Details
#delete ⇒ Boolean
Permanently deletes the logs-based sink.
197 198 199 200 201 202 203 |
# File 'lib/gcloud/logging/sink.rb', line 197 def delete ensure_service! service.delete_sink name return true rescue GRPC::BadStatus => e raise Gcloud::Error.from_error(e) end |
#destination ⇒ Object
The export destination. See [Exporting Logs With Sinks](cloud.google.com/logging/docs/api/tasks/exporting-logs).
85 86 87 |
# File 'lib/gcloud/logging/sink.rb', line 85 def destination @grpc.destination end |
#destination=(destination) ⇒ Object
Updates the export destination. See [Exporting Logs With Sinks](cloud.google.com/logging/docs/api/tasks/exporting-logs).
92 93 94 |
# File 'lib/gcloud/logging/sink.rb', line 92 def destination= destination @grpc.destination = destination end |
#filter ⇒ Object
An [advanced logs filter](cloud.google.com/logging/docs/view/advanced_filters) that defines the log entries to be exported. The filter must be consistent with the log entry format designed by the ‘version` parameter, regardless of the format of the log entry that was originally written to Cloud Logging.
103 104 105 |
# File 'lib/gcloud/logging/sink.rb', line 103 def filter @grpc.filter end |
#filter=(filter) ⇒ Object
Updates the [advanced logs filter](cloud.google.com/logging/docs/view/advanced_filters) that defines the log entries to be exported. The filter must be consistent with the log entry format designed by the ‘version` parameter, regardless of the format of the log entry that was originally written to Cloud Logging.
114 115 116 |
# File 'lib/gcloud/logging/sink.rb', line 114 def filter= filter @grpc.filter = filter end |
#name ⇒ Object
The client-assigned sink identifier. Sink identifiers are limited to 1000 characters and can include only the following characters: ‘A-Z`, `a-z`, `0-9`, and the special characters `_-.`.
78 79 80 |
# File 'lib/gcloud/logging/sink.rb', line 78 def name @grpc.name end |
#reload! ⇒ Object Also known as: refresh!
Reloads the logs-based sink with current data from the Logging service.
176 177 178 179 180 181 |
# File 'lib/gcloud/logging/sink.rb', line 176 def reload! ensure_service! @grpc = service.get_sink name rescue GRPC::BadStatus => e raise Gcloud::Error.from_error(e) end |
#save ⇒ Object
Updates the logs-based sink.
166 167 168 169 170 171 |
# File 'lib/gcloud/logging/sink.rb', line 166 def save ensure_service! @grpc = service.update_sink name, destination, filter, version rescue GRPC::BadStatus => e raise Gcloud::Error.from_error(e) end |
#unspecified? ⇒ Boolean
Helper to determine if the sink’s version is ‘VERSION_FORMAT_UNSPECIFIED`.
138 139 140 |
# File 'lib/gcloud/logging/sink.rb', line 138 def unspecified? !(v1? || v2?) end |
#v1? ⇒ Boolean
Helper to determine if the sink’s version is ‘V1`.
150 151 152 |
# File 'lib/gcloud/logging/sink.rb', line 150 def v1? version == :V1 end |
#v2? ⇒ Boolean
Helper to determine if the sink’s version is ‘V2`.
144 145 146 |
# File 'lib/gcloud/logging/sink.rb', line 144 def v2? version == :V2 end |
#version ⇒ Object
The log entry version used when exporting log entries from this sink. This version does not have to correspond to the version of the log entry when it was written to Cloud Logging.
122 123 124 |
# File 'lib/gcloud/logging/sink.rb', line 122 def version @grpc.output_version_format end |
#version=(version) ⇒ Object
Updates the log entry version used when exporting log entries from this sink. This version does not have to correspond to the version of the log entry when it was written to Cloud Logging. Accepted values are ‘:VERSION_FORMAT_UNSPECIFIED`, `:V2`, and `:V1`.
131 132 133 |
# File 'lib/gcloud/logging/sink.rb', line 131 def version= version @grpc.output_version_format = self.class.resolve_version(version) end |