Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/filter_kubernetes/kube_regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "kube_conf.h"

#define KUBE_TAG_TO_REGEX "(?<pod_name>[a-z0-9](?:[-a-z0-9]*[a-z0-9])?(?:\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)_(?<namespace_name>[^_]+)_(?<container_name>.+)-(?<docker_id>[a-z0-9]{64})\\.log$"
#define KUBE_TAG_TO_REGEX "(?<pod_name>[a-z0-9](?:[-a-z0-9]*[a-z0-9])?(?:\\.[a-z0-9](?:[-a-z0-9]*[a-z0-9])?)*)_(?<namespace_name>[^_]+)_(?<container_name>.+)-(?<docker_id>[a-z0-9]{64})\\.log$"

#define KUBE_JOURNAL_TO_REGEX "^(?<name_prefix>[^_]+)_(?<container_name>[^\\._]+)(\\.(?<container_hash>[^_]+))?_(?<pod_name>[^_]+)_(?<namespace_name>[^_]+)_[^_]+_[^_]+$"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"log":"hello from uat pod","stream":"stdout","time":"2019-04-01T17:58:33.598656444Z"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "uat-myapp-12345",
"namespace": "core",
"uid": "00000000-0000-0000-0000-000000000000"
},
"spec": {
"containers": [
{
"name": "container"
}
]
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[1554141513.598656,{"log":"hello from uat pod","stream":"stdout","kubernetes":{"pod_name":"uat-myapp-12345","namespace_name":"core","container_name":"fluent-bit"}}]
15 changes: 14 additions & 1 deletion tests/runtime/filter_kubernetes.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static int file_to_buf(const char *path, char **out_buf, size_t *out_size)
return -1;
}

buf = flb_malloc(st.st_size);
buf = flb_malloc(st.st_size + 1);
if (!buf) {
flb_errno();
fclose(fp);
Expand All @@ -100,6 +100,7 @@ static int file_to_buf(const char *path, char **out_buf, size_t *out_size)
fclose(fp);
return -1;
}
buf[st.st_size] = '\0';

fclose(fp);
*out_buf = buf;
Expand Down Expand Up @@ -411,6 +412,17 @@ static void flb_test_core_base_with_namespace_labels_and_annotations()
flb_test_namespace_labels_and_annotations("core_base-with-namespace-labels-and-annotations_fluent-bit", NULL, 1);
}

static void flb_test_kube_short_prefix_uat_podname()
{
kube_test("core/core_uat-myapp-12345_fluent-bit",
KUBE_TAIL,
NULL,
1,
"Use_Tag_For_Meta", "On",
NULL);
}


#define flb_test_owner_references(target, suffix, nExpected) \
kube_test("core/" target, KUBE_TAIL, suffix, nExpected, \
"Labels", "Off", \
Expand Down Expand Up @@ -1113,5 +1125,6 @@ TEST_LIST = {
#ifdef FLB_HAVE_SYSTEMD
{"kube_systemd_logs", flb_test_systemd_logs},
#endif
{"kube_short_prefix_uat_podname", flb_test_kube_short_prefix_uat_podname},
{NULL, NULL}
};
Loading