test/plugin/constants.rb in fluent-plugin-google-cloud-0.6.4.pre.3 vs test/plugin/constants.rb in fluent-plugin-google-cloud-0.6.4

- old
+ new

@@ -21,11 +21,10 @@ # TODO(qingling128) Separate constants into different submodules. # Attributes used for the GCE metadata service. PROJECT_ID = 'test-project-id' ZONE = 'us-central1-b' - ZONE2 = 'us-central1-c' FULLY_QUALIFIED_ZONE = 'projects/' + PROJECT_ID + '/zones/' + ZONE VM_ID = '9876543210' # Attributes used for custom (overridden) configs. CUSTOM_PROJECT_ID = 'test-custom-project-id' @@ -50,23 +49,10 @@ # Managed VMs specific labels. MANAGED_VM_BACKEND_NAME = 'default' MANAGED_VM_BACKEND_VERSION = 'guestbook2.0' - # Docker Container labels. - DOCKER_CONTAINER_ID = '0d0f03ff8d3c42688692536d1af77a28cd135c0a5c531f25a31' - DOCKER_CONTAINER_ID2 = '42688692536d1af77a28cd135c0a5c531f25a0317d37da427e3' - DOCKER_CONTAINER_NAME = 'happy_hippo' - DOCKER_CONTAINER_NAME2 = 'sad_panda' - DOCKER_CONTAINER_STREAM_STDOUT = 'stdout' - DOCKER_CONTAINER_STREAM_STDERR = 'stderr' - # Timestamp for 1234567890 seconds and 987654321 nanoseconds since epoch. - DOCKER_CONTAINER_TIMESTAMP = '2009-02-13T23:31:30.987654321Z' - DOCKER_CONTAINER_SECONDS_EPOCH = 1_234_567_890 - DOCKER_CONTAINER_NANOS = 987_654_321 - DOCKER_CONTAINER_APPLICATION_LOG_TAG = 'nginx-access-log' - # Container Engine / Kubernetes specific labels. CONTAINER_CLUSTER_NAME = 'cluster-1' CONTAINER_NAMESPACE_ID = '898268c8-4a36-11e5-9d81-42010af0194c' CONTAINER_NAMESPACE_NAME = 'kube-system' CONTAINER_POD_ID = 'cad3c3c4-4b9c-11e5-9d81-42010af0194c' @@ -152,18 +138,15 @@ NO_DETECT_SUBSERVICE_CONFIG = %( detect_subservice false ) - ENABLE_METADATA_AGENT_CONFIG = %( - enable_metadata_agent true + PROMETHEUS_ENABLE_CONFIG = %( + enable_monitoring true + monitoring_type prometheus ) - DISABLE_METADATA_AGENT_CONFIG = %( - enable_metadata_agent false - ) - CUSTOM_METADATA_CONFIG = %( project_id #{CUSTOM_PROJECT_ID} zone #{CUSTOM_ZONE} vm_id #{CUSTOM_VM_ID} vm_name #{CUSTOM_HOSTNAME} @@ -212,12 +195,10 @@ } label_map { "name": "#{ML_CONSTANTS[:service]}/job_id/log_area" } ) # Service configurations for various services. - - # GCE. COMPUTE_PARAMS = { resource: { type: COMPUTE_CONSTANTS[:resource_type], labels: { 'instance_id' => VM_ID, @@ -229,11 +210,10 @@ labels: { "#{COMPUTE_CONSTANTS[:service]}/resource_name" => HOSTNAME } } - # GAE. VMENGINE_PARAMS = { resource: { type: APPENGINE_CONSTANTS[:resource_type], labels: { 'module_id' => MANAGED_VM_BACKEND_NAME, @@ -247,11 +227,10 @@ "#{COMPUTE_CONSTANTS[:service]}/resource_name" => HOSTNAME, "#{COMPUTE_CONSTANTS[:service]}/zone" => ZONE } } - # GKE Container. CONTAINER_TAG = "kubernetes.#{CONTAINER_POD_NAME}_" \ "#{CONTAINER_NAMESPACE_NAME}_#{CONTAINER_CONTAINER_NAME}" CONTAINER_FROM_METADATA_PARAMS = { resource: { @@ -300,64 +279,10 @@ "#{CONTAINER_CONSTANTS[:service]}/stream" => CONTAINER_STREAM, "#{COMPUTE_CONSTANTS[:service]}/resource_name" => HOSTNAME } } - # Docker Container. - DOCKER_CONTAINER_TAG = "container.#{DOCKER_CONTAINER_ID}." \ - "#{DOCKER_CONTAINER_NAME}" - DOCKER_CONTAINER_TAG_WITH_APPLICATION = - "application-container.#{DOCKER_CONTAINER_NAME}." \ - "#{DOCKER_CONTAINER_APPLICATION_LOG_TAG}" - - DOCKER_CONTAINER_PARAMS = { - resource: { - type: DOCKER_CONSTANTS[:resource_type], - labels: { - 'container_id' => DOCKER_CONTAINER_ID, - 'location' => ZONE - } - }, - log_name: "container.#{DOCKER_CONTAINER_ID}.#{DOCKER_CONTAINER_NAME}", - project_id: PROJECT_ID, - labels: { - "#{COMPUTE_CONSTANTS[:service]}/resource_id" => VM_ID, - "#{COMPUTE_CONSTANTS[:service]}/resource_name" => HOSTNAME, - "#{DOCKER_CONSTANTS[:service]}/container_name" => DOCKER_CONTAINER_NAME - } - } - DOCKER_CONTAINER_PARAMS_WITH_STREAM_STDOUT = DOCKER_CONTAINER_PARAMS.merge( - labels: DOCKER_CONTAINER_PARAMS[:labels].merge( - "#{DOCKER_CONSTANTS[:service]}/stream" => DOCKER_CONTAINER_STREAM_STDOUT - ) - ) - DOCKER_CONTAINER_PARAMS_WITH_METADATA_OVERWRITTEN = \ - DOCKER_CONTAINER_PARAMS.merge( - resource: DOCKER_CONTAINER_PARAMS[:resource].merge( - labels: DOCKER_CONTAINER_PARAMS[:resource][:labels].merge( - 'container_id' => DOCKER_CONTAINER_ID2 - ) - ), - labels: DOCKER_CONTAINER_PARAMS[:labels].merge( - "#{DOCKER_CONSTANTS[:service]}/container_name" => - DOCKER_CONTAINER_NAME2, - "#{DOCKER_CONSTANTS[:service]}/stream" => - DOCKER_CONTAINER_STREAM_STDERR - ) - ) - DOCKER_CONTAINER_PARAMS_WITH_ZONE2 = DOCKER_CONTAINER_PARAMS.merge( - resource: DOCKER_CONTAINER_PARAMS[:resource].merge( - labels: DOCKER_CONTAINER_PARAMS[:resource][:labels].merge( - 'location' => ZONE2 - ) - ) - ) - DOCKER_CONTAINER_WITH_APPLICATION_PARAMS = DOCKER_CONTAINER_PARAMS.merge( - log_name: DOCKER_CONTAINER_TAG_WITH_APPLICATION - ) - - # Cloud Functions. CLOUDFUNCTIONS_TAG = "kubernetes.#{CLOUDFUNCTIONS_POD_NAME}_" \ "#{CLOUDFUNCTIONS_NAMESPACE_NAME}_" \ "#{CLOUDFUNCTIONS_CONTAINER_NAME}" CLOUDFUNCTIONS_PARAMS = { @@ -399,11 +324,10 @@ "#{COMPUTE_CONSTANTS[:service]}/resource_name" => HOSTNAME, "#{COMPUTE_CONSTANTS[:service]}/zone" => ZONE } } - # Cloud Dataflow. DATAFLOW_PARAMS = { resource: { type: DATAFLOW_CONSTANTS[:resource_type], labels: { 'job_name' => DATAFLOW_JOB_NAME, @@ -419,11 +343,10 @@ "#{COMPUTE_CONSTANTS[:service]}/resource_name" => HOSTNAME, "#{COMPUTE_CONSTANTS[:service]}/zone" => ZONE } } - # Cloud Dataproc. DATAPROC_PARAMS = { resource: { type: DATAPROC_CONSTANTS[:resource_type], labels: { 'cluster_name' => DATAPROC_CLUSTER_NAME, @@ -438,11 +361,10 @@ "#{COMPUTE_CONSTANTS[:service]}/resource_id" => VM_ID, "#{COMPUTE_CONSTANTS[:service]}/zone" => ZONE } } - # Cloud ML. ML_PARAMS = { resource: { type: ML_CONSTANTS[:resource_type], labels: { 'job_id' => ML_JOB_ID, @@ -525,43 +447,6 @@ "#{[0x92].pack('C*')}" => '%20', # Empty string tag. '' => '_' } ALL_TAGS = VALID_TAGS.merge(INVALID_TAGS) - - # Stub value for Monitored resources from Metadata Agent. - MONITORED_RESOURCE_STUBS = { - # Implicit GCE instance. - IMPLICIT_MONITORED_RESOURCE_UNIQUE_KEY => { - 'unique_id' => IMPLICIT_MONITORED_RESOURCE_UNIQUE_KEY, - 'monitored_resource' => '{' \ - "\"type\": \"#{COMPUTE_CONSTANTS[:resource_type]}\"," \ - '"labels": {' \ - "\"zone\": \"#{ZONE}\"," \ - "\"instance_id\": \"#{VM_ID}\"" \ - '}' \ - '}' - }, - # Docker container stderr / stdout logs. - DOCKER_CONSTANTS[:resource_type] => { - 'unique_id' => "container.#{DOCKER_CONTAINER_ID}", - 'monitored_resource' => '{' \ - "\"type\": \"#{DOCKER_CONSTANTS[:resource_type]}\"," \ - '"labels": {' \ - "\"location\": \"#{ZONE2}\"," \ - "\"container_id\": \"#{DOCKER_CONTAINER_ID}\"" \ - '}' \ - '}' - }, - # Docker container application logs. - "#{DOCKER_CONSTANTS[:resource_type]}_application" => { - 'unique_id' => "containerName.#{DOCKER_CONTAINER_NAME}", - 'monitored_resource' => '{' \ - "\"type\": \"#{DOCKER_CONSTANTS[:resource_type]}\"," \ - '"labels": {' \ - "\"location\": \"#{ZONE}\"," \ - "\"container_id\": \"#{DOCKER_CONTAINER_ID}\"" \ - '}' \ - '}' - } - } end