Skip to content

Commit

Permalink
modified mounted-file tag
Browse files Browse the repository at this point in the history
Signed-off-by: cw-sakamoto <sakamoto@chatwork.com>
  • Loading branch information
cw-sakamoto committed Aug 29, 2018
1 parent 620ccbf commit 5bce248
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config-reloader/processors/mounted_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (state *mountedFileState) convertToFragement(cf *ContainerFile) fluentd.Fra
dir.SetParam("@type", "tail")

hostPath := state.makeHostPath(cf, hm, mc)
tag := fmt.Sprintf("kube.%s.%s.%s", state.Context.Namepsace, mc.PodName, mc.Name)
tag := fmt.Sprintf("kube.%s.%s.%s", state.Context.Namepsace, mc.PodName, util.Hash(mc.Name,cf.Path))
dir.SetParam("path", hostPath)
dir.SetParam("read_from_head", "true")
dir.SetParam("tag", tag)
Expand Down
4 changes: 2 additions & 2 deletions config-reloader/processors/mounted_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func TestConvertToFragment(t *testing.T) {
assert.Equal(t, "source", dir.Name)
assert.Equal(t, "tail", dir.Type())
assert.Equal(t, "/kubelet-root/pods/123-id/volumes/kubernetes.io~empty-dir/logs/redis.log", dir.Param("path"))
assert.Equal(t, "kube.monitoring.123.container-name", dir.Param("tag"))
assert.Equal(t, "kube.monitoring.123.41f0793839eb8809253430bb00761e56c18cb2fb", dir.Param("tag"))
assert.Equal(t, "parse", dir.Nested[0].Name)
assert.Equal(t, "/var/log/kfotail-b3f8f41cab18c93a7c8057277947de0d1d76d1d6.pos", dir.Param("pos_file"))
assert.Equal(t, "none", dir.Nested[0].Type())
Expand All @@ -226,7 +226,7 @@ func TestConvertToFragment(t *testing.T) {
assert.Equal(t, "source", dir.Name)
assert.Equal(t, "tail", dir.Type())
assert.Equal(t, "/kubelet-root/pods/abc-id/volumes/kubernetes.io~empty-dir/logs/nginx.log", dir.Param("path"))
assert.Equal(t, "kube.monitoring.abc.nginx", dir.Param("tag"))
assert.Equal(t, "kube.monitoring.abc.28db69e95c1cf309041b693ffbc2306df10c9da3", dir.Param("tag"))

mod = result[1]
assert.Equal(t, "filter", mod.Name)
Expand Down

0 comments on commit 5bce248

Please sign in to comment.