Module: Fluent::GoogleCloudOutput::Constants

Defined in:
lib/fluent/plugin/out_google_cloud.rb

Overview

Constants for service names and resource types.

Constant Summary collapse

APPENGINE_CONSTANTS =
{
  service: 'appengine.googleapis.com',
  resource_type: 'gae_app',
  metadata_attributes: %w(gae_backend_name gae_backend_version).to_set
}
CLOUDFUNCTIONS_CONSTANTS =
{
  service: 'cloudfunctions.googleapis.com',
  resource_type: 'cloud_function'
}
COMPUTE_CONSTANTS =
{
  service: 'compute.googleapis.com',
  resource_type: 'gce_instance'
}
CONTAINER_CONSTANTS =
{
  service: 'container.googleapis.com',
  resource_type: 'container',
  extra_resource_labels: %w(namespace_id pod_id container_name),
  extra_common_labels: %w(namespace_name pod_name),
  metadata_attributes: %w(kube-env).to_set
}
DATAFLOW_CONSTANTS =
{
  service: 'dataflow.googleapis.com',
  resource_type: 'dataflow_step',
  extra_common_labels: %w(region job_name job_id step_id)
}
DATAPROC_CONSTANTS =
{
  service: 'cluster.dataproc.googleapis.com',
  resource_type: 'cloud_dataproc_cluster',
  metadata_attributes:
    %w(dataproc-cluster-uuid dataproc-cluster-name).to_set
}
EC2_CONSTANTS =
{
  service: 'ec2.amazonaws.com',
  resource_type: 'aws_ec2_instance'
}
ML_CONSTANTS =
{
  service: 'ml.googleapis.com',
  resource_type: 'ml_job',
  extra_common_labels: %w(job_id task_name)
}
SUBSERVICE_MAP =

The map between a subservice name and a resource type.

[APPENGINE_CONSTANTS, CONTAINER_CONSTANTS, DATAFLOW_CONSTANTS,
 DATAPROC_CONSTANTS, ML_CONSTANTS]
.map { |consts| [consts[:service], consts[:resource_type]] }.to_h
SUBSERVICE_METADATA_ATTRIBUTES =

The map between a resource type and expected subservice attributes.

[APPENGINE_CONSTANTS, CONTAINER_CONSTANTS, DATAPROC_CONSTANTS]
.map { |consts| [consts[:resource_type], consts[:metadata_attributes]] }
.to_h
DEFAULT_PAYLOAD_KEY_PREFIX =

Default values for JSON payload keys to set the "trace", "sourceLocation", "operation" and "labels" fields in the LogEntry.

'logging.googleapis.com'
DEFAULT_LABELS_KEY =
"#{DEFAULT_PAYLOAD_KEY_PREFIX}/labels"
DEFAULT_HTTP_REQUEST_KEY =
'httpRequest'
DEFAULT_OPERATION_KEY =
"#{DEFAULT_PAYLOAD_KEY_PREFIX}/operation"
DEFAULT_SOURCE_LOCATION_KEY =
"#{DEFAULT_PAYLOAD_KEY_PREFIX}/sourceLocation"
DEFAULT_TRACE_KEY =
"#{DEFAULT_PAYLOAD_KEY_PREFIX}/trace"
LOG_ENTRY_FIELDS_MAP =

Map from each field name under LogEntry to corresponding variables required to perform field value extraction from the log record.

{
  'http_request' => [
    # The config to specify label name for field extraction from record.
    '@http_request_key',
    # Map from subfields' names to their types.
    [
      # subfield key in the payload, destination key, cast lambda (opt)
      %w(requestMethod request_method parse_string),
      %w(requestUrl request_url parse_string),
      %w(requestSize request_size parse_int),
      %w(status status parse_int),
      %w(responseSize response_size parse_int),
      %w(userAgent user_agent parse_string),
      %w(remoteIp remote_ip parse_string),
      %w(referer referer parse_string),
      %w(cacheHit cache_hit parse_bool),
      %w(cacheValidatedWithOriginServer
         cache_validated_with_origin_server parse_bool),
      %w(latency latency parse_latency)
    ],
    # The grpc version class name.
    'Google::Logging::Type::HttpRequest',
    # The non-grpc version class name.
    'Google::Apis::LoggingV2beta1::HttpRequest'
  ],
  'source_location' => [
    '@source_location_key',
    [
      %w(file file parse_string),
      %w(function function parse_string),
      %w(line line parse_int)
    ],
    'Google::Logging::V2::LogEntrySourceLocation',
    'Google::Apis::LoggingV2beta1::LogEntrySourceLocation'
  ],
  'operation' => [
    '@operation_key',
    [
      %w(id id parse_string),
      %w(producer producer parse_string),
      %w(first first parse_bool),
      %w(last last parse_bool)
    ],
    'Google::Logging::V2::LogEntryOperation',
    'Google::Apis::LoggingV2beta1::LogEntryOperation'
  ]
}