{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls/comments/41567850","id":41567850,"diff_hunk":"@@ -664,13 +665,21 @@ def set_payload(record, entry)\n       end\n     end\n \n-    def log_name(tag)\n+    def log_name(tag, commonLabels)\n       if @service_name == CLOUDFUNCTIONS_SERVICE\n         return 'cloud-functions'\n-      else\n-        # Add a prefix to VMEngines logs to prevent namespace collisions.\n-        return @running_on_managed_vm ? \"#{APPENGINE_SERVICE}/#{tag}\" : tag\n+      elsif @running_on_managed_vm\n+        # Add a prefix to Managed VM logs to prevent namespace collisions.\n+        return \"#{APPENGINE_SERVICE}/#{tag}\"\n+      elsif @service_name == CONTAINER_SERVICE\n+        # For Kubernetes logs, use just the container name as the log name\n+        # if we have it.\n+        container_name_key = \"#{CONTAINER_SERVICE}/container_name\"\n+        if commonLabels && commonLabels.key?(container_name_key)\n+          return commonLabels[container_name_key]\n+        end\n       end\n+      tag","path":"lib/fluent/plugin/out_google_cloud.rb","position":32,"original_position":32,"commit_id":"3691264140c9407ed9fd5b34831325d286ecfc7b","original_commit_id":"3691264140c9407ed9fd5b34831325d286ecfc7b","user":{"login":"a-robinson","id":7085343,"avatar_url":"https://avatars.githubusercontent.com/u/7085343?v=3","gravatar_id":"","url":"https://api.github.com/users/a-robinson","html_url":"https://github.com/a-robinson","followers_url":"https://api.github.com/users/a-robinson/followers","following_url":"https://api.github.com/users/a-robinson/following{/other_user}","gists_url":"https://api.github.com/users/a-robinson/gists{/gist_id}","starred_url":"https://api.github.com/users/a-robinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a-robinson/subscriptions","organizations_url":"https://api.github.com/users/a-robinson/orgs","repos_url":"https://api.github.com/users/a-robinson/repos","events_url":"https://api.github.com/users/a-robinson/events{/privacy}","received_events_url":"https://api.github.com/users/a-robinson/received_events","type":"User","site_admin":false},"body":"sorry :) I forgot to run rubocop before pushing","created_at":"2015-10-08T20:56:46Z","updated_at":"2015-10-08T20:56:46Z","html_url":"https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud/pull/39#discussion_r41567850","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls/39","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls/comments/41567850"},"html":{"href":"https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud/pull/39#discussion_r41567850"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls/39","id":47204402,"html_url":"https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud/pull/39","diff_url":"https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud/pull/39.diff","patch_url":"https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud/pull/39.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/issues/39","number":39,"state":"open","locked":false,"title":"Use the Kubernetes container name as the log name rather than the tag.","user":{"login":"a-robinson","id":7085343,"avatar_url":"https://avatars.githubusercontent.com/u/7085343?v=3","gravatar_id":"","url":"https://api.github.com/users/a-robinson","html_url":"https://github.com/a-robinson","followers_url":"https://api.github.com/users/a-robinson/followers","following_url":"https://api.github.com/users/a-robinson/following{/other_user}","gists_url":"https://api.github.com/users/a-robinson/gists{/gist_id}","starred_url":"https://api.github.com/users/a-robinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a-robinson/subscriptions","organizations_url":"https://api.github.com/users/a-robinson/orgs","repos_url":"https://api.github.com/users/a-robinson/repos","events_url":"https://api.github.com/users/a-robinson/events{/privacy}","received_events_url":"https://api.github.com/users/a-robinson/received_events","type":"User","site_admin":false},"body":"This prevents too many different log streams from being created for pods\r\nin a replication controller, and allows for much better aggregation.\r\n\r\nIt could be confusing if people don't name their containers well, but in our experience most people tend to just name their container the same as the pod that it's in, and don't use meaningless names for them.\r\n\r\nIf it's alright, I'm going to be shortly following this up by also including whether it's stdout or stderr in the log name as well, making for names like \"redis.stdout\" and \"redis.stderr\" coming from a redis container. This'll also make it such that the payload can be just the log message, with no unnecessary json boilerplate. That'll take a little more surgery, though, since each batch of logs for the tag might have to be split into two different streams, which isn't supported at the moment.\r\n\r\n@mr-salty ","created_at":"2015-10-08T20:48:27Z","updated_at":"2015-10-08T20:56:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9159dd2e9291b32a919aabce70d59c7b33dbe6d0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls/39/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls/39/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/issues/39/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/statuses/3691264140c9407ed9fd5b34831325d286ecfc7b","head":{"label":"a-robinson:container","ref":"container","sha":"3691264140c9407ed9fd5b34831325d286ecfc7b","user":{"login":"a-robinson","id":7085343,"avatar_url":"https://avatars.githubusercontent.com/u/7085343?v=3","gravatar_id":"","url":"https://api.github.com/users/a-robinson","html_url":"https://github.com/a-robinson","followers_url":"https://api.github.com/users/a-robinson/followers","following_url":"https://api.github.com/users/a-robinson/following{/other_user}","gists_url":"https://api.github.com/users/a-robinson/gists{/gist_id}","starred_url":"https://api.github.com/users/a-robinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a-robinson/subscriptions","organizations_url":"https://api.github.com/users/a-robinson/orgs","repos_url":"https://api.github.com/users/a-robinson/repos","events_url":"https://api.github.com/users/a-robinson/events{/privacy}","received_events_url":"https://api.github.com/users/a-robinson/received_events","type":"User","site_admin":false},"repo":{"id":40383892,"name":"fluent-plugin-google-cloud","full_name":"a-robinson/fluent-plugin-google-cloud","owner":{"login":"a-robinson","id":7085343,"avatar_url":"https://avatars.githubusercontent.com/u/7085343?v=3","gravatar_id":"","url":"https://api.github.com/users/a-robinson","html_url":"https://github.com/a-robinson","followers_url":"https://api.github.com/users/a-robinson/followers","following_url":"https://api.github.com/users/a-robinson/following{/other_user}","gists_url":"https://api.github.com/users/a-robinson/gists{/gist_id}","starred_url":"https://api.github.com/users/a-robinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a-robinson/subscriptions","organizations_url":"https://api.github.com/users/a-robinson/orgs","repos_url":"https://api.github.com/users/a-robinson/repos","events_url":"https://api.github.com/users/a-robinson/events{/privacy}","received_events_url":"https://api.github.com/users/a-robinson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/a-robinson/fluent-plugin-google-cloud","description":"Plugin for Fluentd that sends logs to the Google Cloud Platform's log ingestion API.","fork":true,"url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud","forks_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/forks","keys_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/teams","hooks_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/hooks","issue_events_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/issues/events{/number}","events_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/events","assignees_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/assignees{/user}","branches_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/branches{/branch}","tags_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/tags","blobs_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/git/refs{/sha}","trees_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/statuses/{sha}","languages_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/languages","stargazers_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/stargazers","contributors_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/contributors","subscribers_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/subscribers","subscription_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/subscription","commits_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/commits{/sha}","git_commits_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/git/commits{/sha}","comments_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/comments{/number}","issue_comment_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/issues/comments{/number}","contents_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/contents/{+path}","compare_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/merges","archive_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/downloads","issues_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/issues{/number}","pulls_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/pulls{/number}","milestones_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/milestones{/number}","notifications_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/labels{/name}","releases_url":"https://api.github.com/repos/a-robinson/fluent-plugin-google-cloud/releases{/id}","created_at":"2015-08-07T22:45:09Z","updated_at":"2015-08-07T22:45:10Z","pushed_at":"2015-10-08T20:54:35Z","git_url":"git://github.com/a-robinson/fluent-plugin-google-cloud.git","ssh_url":"git@github.com:a-robinson/fluent-plugin-google-cloud.git","clone_url":"https://github.com/a-robinson/fluent-plugin-google-cloud.git","svn_url":"https://github.com/a-robinson/fluent-plugin-google-cloud","homepage":null,"size":340,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"852e36ff2a32766012ca57973c3049a38996d1d0","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":19799990,"name":"fluent-plugin-google-cloud","full_name":"GoogleCloudPlatform/fluent-plugin-google-cloud","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud","description":"Plugin for Fluentd that sends logs to the Google Cloud Platform's log ingestion API.","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/releases{/id}","created_at":"2014-05-14T23:46:51Z","updated_at":"2015-09-16T02:30:25Z","pushed_at":"2015-10-08T20:54:36Z","git_url":"git://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud.git","ssh_url":"git@github.com:GoogleCloudPlatform/fluent-plugin-google-cloud.git","clone_url":"https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud.git","svn_url":"https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud","homepage":null,"size":619,"stargazers_count":30,"watchers_count":30,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":5,"forks":9,"open_issues":5,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls/39"},"html":{"href":"https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud/pull/39"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/issues/39"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/fluent-plugin-google-cloud/statuses/3691264140c9407ed9fd5b34831325d286ecfc7b"}}}}