fluent-plugin-google-cloud 0.6.4.pre.1 → 0.6.4.pre.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8b2b5d197dc8da098e69040d3c1e33cf1d13390
4
- data.tar.gz: d01388ebf1188dcd27061bdc3466a65be62856e9
3
+ metadata.gz: e87c18a3faae1b0b748c947487bac806f9af22ff
4
+ data.tar.gz: 7aa3fb16a6625f55e86dd7a1b2b983ce090b0803
5
5
  SHA512:
6
- metadata.gz: b6720df5c417423746b423fd34cebbcb3d417cdbc1cdfe91307970841661cf8d18edd987e0f622680bcc51b4503b5e3458c3029774362396eea769f2a2378dc5
7
- data.tar.gz: 0ebf298b06bc970370d4a7640096f2fd14a2646339c9db6e93f29dacbf640140e52d1016c89cc63811b8248c314e945e54f8e47088b58a4384cd6082da233d59
6
+ metadata.gz: 16e3e4c2db4dc5dccc26c403bd1a64802afa7fd97fa0a9bdc3109a583d865c594958efeb7e769a7aa45987d237f4842ecadb18280c6c6adc87ee6bee2a1a34b6
7
+ data.tar.gz: 07a36c3637028e394f84f01baa05650f6d8db4260db6b64dae92ff7d1f4b6af6bca3173162bcbb588dffbc765e9426c24588ef30523d1dd29e0f6f1ca13d502c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-google-cloud (0.6.4.pre.1)
4
+ fluent-plugin-google-cloud (0.6.4.pre.2)
5
5
  excon (~> 0.56.0)
6
6
  fluentd (~> 0.10)
7
7
  google-api-client (~> 0.9.0)
@@ -25,7 +25,7 @@ GEM
25
25
  excon (0.56.0)
26
26
  faraday (0.12.1)
27
27
  multipart-post (>= 1.2, < 3)
28
- fluentd (0.14.18)
28
+ fluentd (0.14.19)
29
29
  cool.io (>= 1.4.5, < 2.0.0)
30
30
  http_parser.rb (>= 0.5.1, < 0.7.0)
31
31
  msgpack (>= 0.7.0, < 2.0.0)
@@ -127,7 +127,7 @@ GEM
127
127
  multi_json (~> 1.10)
128
128
  stackdriver-core (0.21.0)
129
129
  strptime (0.1.9)
130
- test-unit (3.2.4)
130
+ test-unit (3.2.5)
131
131
  power_assert
132
132
  thread_safe (0.3.6)
133
133
  tins (1.6.0)
@@ -154,4 +154,4 @@ DEPENDENCIES
154
154
  webmock (~> 1.17)
155
155
 
156
156
  BUNDLED WITH
157
- 1.15.1
157
+ 1.15.2
@@ -10,7 +10,7 @@ eos
10
10
  gem.homepage = \
11
11
  'https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud'
12
12
  gem.license = 'Apache-2.0'
13
- gem.version = '0.6.4.pre.1'
13
+ gem.version = '0.6.4.pre.2'
14
14
  gem.authors = ['Todd Derr', 'Alex Robinson']
15
15
  gem.email = ['salty@google.com']
16
16
  gem.required_ruby_version = Gem::Requirement.new('>= 2.0')
@@ -79,7 +79,7 @@ module Fluent
79
79
  resource_type: 'ml_job'
80
80
  }
81
81
 
82
- # Metadata agent support.
82
+ # Metadata Agent support.
83
83
 
84
84
  # Use empty string as request path when locally-unique key of monitored
85
85
  # resource can be implicitly inferred by Metadata Agent.
@@ -94,7 +94,7 @@ module Fluent
94
94
  Fluent::Plugin.register_output('google_cloud', self)
95
95
 
96
96
  PLUGIN_NAME = 'Fluentd Google Cloud Logging plugin'
97
- PLUGIN_VERSION = '0.6.4.pre.1'
97
+ PLUGIN_VERSION = '0.6.4.pre.2'
98
98
 
99
99
  # Name of the the Google cloud logging write scope.
100
100
  LOGGING_SCOPE = 'https://www.googleapis.com/auth/logging.write'
@@ -213,7 +213,7 @@ module Fluent
213
213
  config_param :call_docker_api_locally, :bool, :default => true
214
214
  # Docker Remote API unix socket path.
215
215
  config_param :docker_remote_api_socket_path, :string,
216
- :default => '/var/run/docker.sock'
216
+ :default => DEFAULT_DOCKER_API_SOCKET_PATH
217
217
 
218
218
  # rubocop:enable Style/HashSyntax
219
219
 
@@ -379,9 +379,10 @@ module Fluent
379
379
  arr.each do |time, record|
380
380
  next unless record.is_a?(Hash)
381
381
 
382
- extracted_resource_labels, extracted_common_labels = \
382
+ resource_type, extracted_resource_labels, extracted_common_labels = \
383
383
  determine_entry_level_labels(group_resource, record)
384
384
  entry_resource = group_resource.dup
385
+ entry_resource.type = resource_type
385
386
  entry_resource.labels.merge!(extracted_resource_labels)
386
387
  entry_common_labels = \
387
388
  group_common_labels.merge(extracted_common_labels)
@@ -746,7 +747,7 @@ module Fluent
746
747
  # Retrieve monitored resource via the legacy way.
747
748
  #
748
749
  # Note: This is just a failover plan if we fail to get metadata from
749
- # Metadata agent. Thus it should be equivalent to what Metadata Agent
750
+ # Metadata Agent. Thus it should be equivalent to what Metadata Agent
750
751
  # returns.
751
752
  def determine_agent_level_monitored_resource_via_legacy
752
753
  resource = Google::Apis::LoggingV2beta1::MonitoredResource.new(
@@ -1041,22 +1042,22 @@ module Fluent
1041
1042
  locally_unique_id)
1042
1043
  end
1043
1044
 
1044
- if @enable_metadata_agent && !retrieved_resource.nil?
1045
+ if !retrieved_resource.nil?
1045
1046
  # If we successfully get a monitored resource from Metadata Agent,
1046
- # use this one instead of the original VM-level monitored resource.
1047
+ # use this one instead of the original instance monitored resource.
1047
1048
  group_resource_labels = retrieved_resource.labels.dup
1048
1049
  @log.debug 'Retrieved monitored resource from Metadata Agent: ' \
1049
1050
  "#{retrieved_resource.inspect}."
1050
1051
  else
1051
1052
  # If Metadata Agent is not enabled, or we failed to get a monitored
1052
1053
  # resource, we need to have some backup plan.
1053
- @log.debug 'Metadata agent not enabled or failed to retrieve ' \
1054
+ @log.debug 'Metadata Agent not enabled or failed to retrieve ' \
1054
1055
  'docker container monitored resource from Metadata ' \
1055
1056
  'Agent.'
1056
1057
 
1057
1058
  # 1. Check if 'container_id' is set already. It should be available
1058
1059
  # for stdout / stderr). If so, use that.
1059
- # 2. If not, call Docker Remote API to calculate container id from
1060
+ # 2. If not, call Docker Remote API to retrieve the container ID from
1060
1061
  # container name, but only if @call_docker_api_locally is true.
1061
1062
  container_id ||= retrieve_container_id_by_name_locally(
1062
1063
  container_name) if @call_docker_api_locally
@@ -1094,11 +1095,45 @@ module Fluent
1094
1095
  # Extract entry resource and common labels that should be applied to
1095
1096
  # individual entries from the group resource.
1096
1097
  def determine_entry_level_labels(group_resource, record)
1098
+ resource_type = group_resource.type
1097
1099
  resource_labels = {}
1098
1100
  common_labels = {}
1099
1101
 
1102
+ if record.key?("#{CONTAINER_CONSTANTS[:service]}/namespace_id") &&
1103
+ record.key?("#{CONTAINER_CONSTANTS[:service]}/pod_name") &&
1104
+ record.key?("#{CONTAINER_CONSTANTS[:service]}/container_name")
1105
+ if @enable_metadata_agent
1106
+ # Call Metadata Agent with "gke_containerName.<namespace_id>.
1107
+ # <pod_name>.<container_name>" as the locally-unique key to retrieve
1108
+ # monitored resource.
1109
+ locally_unique_id = 'gke_containerName.' \
1110
+ "#{record["#{CONTAINER_CONSTANTS[:service]}/namespace_id"]}." \
1111
+ "#{record["#{CONTAINER_CONSTANTS[:service]}/pod_name"]}." \
1112
+ "#{record["#{CONTAINER_CONSTANTS[:service]}/container_name"]}"
1113
+ @log.debug 'Calling metadata agent with locally unique id: ' \
1114
+ "#{locally_unique_id}."
1115
+ retrieved_resource = call_metadata_agent_for_monitored_resource(
1116
+ locally_unique_id)
1117
+ @log.debug 'Retrieved monitored resource from metadata agent: ' \
1118
+ "#{retrieved_resource.inspect}."
1119
+ unless retrieved_resource.nil?
1120
+ # Temporarily renaming 'gke_container' to 'container'.
1121
+ # resource_type = retrieved_resource.type
1122
+ resource_type = 'container'
1123
+ # If we successfully get a monitored resource from Metadata Agent,
1124
+ # use this one instead of the original VM-level monitored resource.
1125
+ resource_labels = retrieved_resource.labels.dup
1126
+ record.delete("#{CONTAINER_CONSTANTS[:service]}/namespace_id")
1127
+ record.delete("#{CONTAINER_CONSTANTS[:service]}/pod_name")
1128
+ record.delete("#{CONTAINER_CONSTANTS[:service]}/container_name")
1129
+ @log.debug 'Retrieved gke monitored resource from Metadata ' \
1130
+ "Agent: ' #{retrieved_resource.inspect}."
1131
+ end
1132
+ end
1133
+ end
1134
+
1100
1135
  # Cloud Functions.
1101
- if group_resource.type == CLOUDFUNCTIONS_CONSTANTS[:resource_type] &&
1136
+ if resource_type == CLOUDFUNCTIONS_CONSTANTS[:resource_type] &&
1102
1137
  record.key?('log')
1103
1138
  @cloudfunctions_log_match =
1104
1139
  @cloudfunctions_log_regexp.match(record['log'])
@@ -1109,7 +1144,7 @@ module Fluent
1109
1144
  end
1110
1145
 
1111
1146
  # GKE containers.
1112
- if group_resource.type == CONTAINER_CONSTANTS[:resource_type]
1147
+ if resource_type == CONTAINER_CONSTANTS[:resource_type]
1113
1148
  # Move the stdout/stderr annotation from the record into a label.
1114
1149
  common_labels.merge!(
1115
1150
  fields_to_labels(
@@ -1127,7 +1162,7 @@ module Fluent
1127
1162
  end
1128
1163
 
1129
1164
  # Docker containers.
1130
- if group_resource.type == DOCKER_CONSTANTS[:resource_type]
1165
+ if resource_type == DOCKER_CONSTANTS[:resource_type]
1131
1166
  # For logs coming from Docker Fluentd Logging Driver, the log record
1132
1167
  # has 4 fields: 'container_id', 'container_name', 'source' and 'log'.
1133
1168
  # Extract 'container_id', 'container_name' and 'source' from json
@@ -1153,9 +1188,9 @@ module Fluent
1153
1188
  common_labels.merge!(fields_to_labels(record, @label_map))
1154
1189
 
1155
1190
  resource_labels.merge!(
1156
- extract_resource_labels(group_resource.type, common_labels))
1191
+ extract_resource_labels(resource_type, common_labels))
1157
1192
 
1158
- [resource_labels, common_labels]
1193
+ [resource_type, resource_labels, common_labels]
1159
1194
  end
1160
1195
 
1161
1196
  # Call Metadata Agent to get monitored resource information and parse
@@ -1171,7 +1206,7 @@ module Fluent
1171
1206
  return nil
1172
1207
  end
1173
1208
 
1174
- # TODO(lingshi): Use Google::Api::MonitoredResource directly after we
1209
+ # TODO(qingling128): Use Google::Api::MonitoredResource directly after we
1175
1210
  # upgrade gRPC version to include the fix for the protobuf map
1176
1211
  # corruption issue.
1177
1212
  Google::Apis::LoggingV2beta1::MonitoredResource.new(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-google-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4.pre.1
4
+ version: 0.6.4.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Derr
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-06-22 00:00:00.000000000 Z
12
+ date: 2017-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: excon