lib/fluent/plugin/out_google_cloud.rb
# Extract entry level monitored resource and common labels that should be
# applied to individual entries.
Extract entry level monitored resource and common labels that should be
applied to individual entries.
Extract entry level monitored resource and common labels that should be applied to individual entries .
def determine_entry_level_monitored_resource_and_labels(
      group_level_resource, group_level_common_labels, record)
      resource = group_level_resource.dup
      resource.labels = group_level_resource.labels.dup
      common_labels = group_level_common_labels.dup
      case resource.type
      when GKE_CONSTANTS[:resource_type]
        common_labels.merge!(
          delete_and_extract_labels(
            record, 'stream' => "#{GKE_CONSTANTS[:service]}/stream"))
        if record.key?('kubernetes')
          resource.labels.merge!(
            delete_and_extract_labels(
              record['kubernetes'], GKE_CONSTANTS[:extra_resource_labels]
                .map { |l| [l, l] }.to_h))
          common_labels.merge!(
            delete_and_extract_labels(
              record['kubernetes'], GKE_CONSTANTS[:extra_common_labels]
                .map { |l| [l, "#{GKE_CONSTANTS[:service]}/#{l}"] }.to_h))
          if record['kubernetes'].key?('labels')
            common_labels.merge!(
              delete_and_extract_labels(
                record['kubernetes']['labels'], record['kubernetes']['labels']
                  .map { |key, _| [key, "label/#{key}"] }.to_h))
          end
          record.delete('kubernetes')
          record.delete('docker')
        end
      end
      common_labels.merge!(delete_and_extract_labels(record, @label_map))
      [DATAFLOW_CONSTANTS, ML_CONSTANTS].each do |service_constants|
        next unless resource.type == service_constants[:resource_type]
        resource.labels.merge!(
          delete_and_extract_labels(
            common_labels, service_constants[:extra_resource_labels]
              .map { |l| ["#{service_constants[:service]}/#{l}", l] }.to_h))
      end
      [resource, common_labels]
    end
def determine_entry_level_monitored_resource_and_labels ( group_level_resource , group_level_common_labels , record ) resource = group_level_resource . dup resource . labels = group_level_resource . labels . dup common_labels = group_level_common_labels . dup case resource . type when GKE_CONSTANTS [ :resource_type ] common_labels . merge! ( delete_and_extract_labels ( record , 'stream' => "#{GKE_CONSTANTS[:service]}/stream" ) ) if record . key? ( 'kubernetes' ) resource . labels . merge! ( delete_and_extract_labels ( record [ 'kubernetes' ] , GKE_CONSTANTS [ :extra_resource_labels ] . map { | l | [ l , l ] } . to_h ) ) common_labels . merge! ( delete_and_extract_labels ( record [ 'kubernetes' ] , GKE_CONSTANTS [ :extra_common_labels ] . map { | l | [ l , "#{GKE_CONSTANTS[:service]}/#{l}" ] } . to_h ) ) if record [ 'kubernetes' ] . key? ( 'labels' ) common_labels . merge! ( delete_and_extract_labels ( record [ 'kubernetes' ] [ 'labels' ] , record [ 'kubernetes' ] [ 'labels' ] . map { | key , _ | [ key , "label/#{key}" ] } . to_h ) ) end record . delete ( 'kubernetes' ) record . delete ( 'docker' ) end end common_labels . merge! ( delete_and_extract_labels ( record , @label_map ) ) [ DATAFLOW_CONSTANTS , ML_CONSTANTS ] . each do | service_constants | next unless resource . type == service_constants [ :resource_type ] resource . labels . merge! ( delete_and_extract_labels ( common_labels , service_constants [ :extra_resource_labels ] . map { | l | [ "#{service_constants[:service]}/#{l}" , l ] } . to_h ) ) end [ resource , common_labels ] end
Extract entry level monitored resource and common labels that should be
applied to individual entries.
Extract entry level monitored resource and common labels that should be applied to individual entries .
# GKE container. # Move the stdout/stderr annotation from the record into a label. # If the record has been annotated by the kubernetes_metadata_filter # plugin, then use that metadata. Otherwise, rely on commonLabels # populated from the group's tag. # Prepend label/ to all user-defined labels' keys. # We've explicitly consumed all the fields we care about -- don't # litter the log entries with the remaining fields that the kubernetes # metadata filter plugin includes (or an empty 'kubernetes' field). # If the name of a field in the record is present in the @label_map # configured by users, report its value as a label and do not send that # field as part of the payload. # Cloud Dataflow and Cloud ML. # These labels can be set via the 'labels' or 'label_map' options. # Report them as monitored resource labels instead of common labels. # e.g. "dataflow.googleapis.com/job_id" => "job_id"
group_level_resource
<not_specific>
group_level_common_labels
<not_specific>
record
<not_specific>