Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluentd filter to process Kubernetes logs #51405

Closed
amitkumarj441 opened this issue Aug 26, 2017 · 8 comments
Closed

Fluentd filter to process Kubernetes logs #51405

amitkumarj441 opened this issue Aug 26, 2017 · 8 comments
Labels
area/logging kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@amitkumarj441
Copy link
Contributor

Is this a BUG REPORT or FEATURE REQUEST?:

Uncomment only one, leave it on its own line:

/kind feature

What happened:
I and @mperezco are working on having a Fluentd filter to process kubernetes logs, we created the ConfigMap to add two files (in ingress):
@include configs.d/user/filter-k8s-core-rewrite.conf [First file is to rewrite the logs coming from services "origin-master" and "origin-node"]
@include configs.d/user/filter-k8s-core-data.conf [Second file is to tag all kubernetes namespaces]

We already have a common data model namespace for kubernetes https://github.com/ViaQ/elasticsearch-templates/blob/master/namespaces/kubernetes.yml#L22
So we could do something like this instead:
<record>
kubernetes {"namespace_name":"${record['MESSAGE'].match/.*GET\s\/api.*namespaces\/(\w*)\//}"}
</record>
But the problem is - what if there is no match for /.*GET/ ? What will the namespace name be?

Perhaps record['MESSAGE'] is not coming through as expected?

And we're not getting any logs under Kibana with API tags?

What you expected to happen:
To get Kubernetes components logs (kubeapi, kubelet etc.) in journald

How to reproduce it (as minimally and precisely as possible):
We'll try another way to conditionally add a field:
<record>
unused ${record['MESSAGE'].match(/.*GET\s\/api.*namespaces\/(\w*)\//) do |md| record['kubernetes']=Hash.new; record['kubernetes']['namespace_name']=md[1] end}
</record>
remove_keys unused

We tested the regular expression in Rubular as well as in Fluentular
The intention is that in a line that comes from journald like this:
ago 21 18:19:12 viaq.logging.test origin-master[1194]: I0821 18:19:12.249226 1194 panics.go:76] GET /api/v1/namespaces/logging/endpoints/logging-kibana: (10.89128ms) 200 [[openshift/v1.5.2+43a9be4 (linux/amd64) kubernetes/43a9be4 system:serviceaccount:openshift-infra:endpoint-controller] 192.168.122.5:47476 http://192.168.122.5:47476]`
assigns the record "logging" to "k8s_namespace" ... and shows it in kibana ...
Anything else we need to know?:
We checked our expression according to ruby console which is correct though :

pry(main)> msg = 'ago 21 18:19:12 viaq.logging.test origin-master[1194]: I0821 18:19:12.249226 1194 panics.go:76] GET /api/v1/namespaces/logging/endpoints/logging-kibana: (10.89128ms) 200 [[openshift/v1.5.2+43a9be4 (linux/amd64) kubernetes/43a9be4 system:serviceaccount:openshift-infra:endpoint-controller] 192.168.122.5:47476 http://192.168.122.5:47476]' => "ago 21 18:19:12 viaq.logging.test origin-master[1194]: I0821 18:19:12.249226 1194 panics.go:76] GET /api/v1/namespaces/logging/endpoints/logging-kibana: (10.89128ms) 200 [[openshift/v1.5.2+43a9be4 (linux/amd64) kubernetes/43a9be4 system:serviceaccount:openshift-infra:endpoint-controller] 192.168.122.5:47476 http://192.168.122.5:47476]"`

pry(main)> msg.match(/.*GET\s\/api.*namespaces\/(\w*)\//) do |md| puts md[1] end
logging
=> nil

Other solution could be to add out_stdout in many cases to debug.

Environment:

  • Kubernetes version (use kubectl version):

  • Cloud provider or hardware configuration**:

  • OS (e.g. from /etc/os-release): CentOS 7.3

  • Kernel (e.g. uname -a): Linux ith-ThinkPad-W520 4.10.0-32-generic Expand testing of the util package. Now 70% #36~16.04.1-Ubuntu SMP Wed Aug 9 09:19:02 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

  • Install tools: ViaQ wrapper

  • Others:

@k8s-github-robot k8s-github-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Aug 26, 2017
@amitkumarj441
Copy link
Contributor Author

/area logging
/sig cluster-ops
/kind feature

@k8s-ci-robot k8s-ci-robot added area/logging sig/cluster-ops kind/feature Categorizes issue or PR as related to a new feature. labels Aug 26, 2017
@k8s-github-robot k8s-github-robot removed the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Aug 26, 2017
@crassirostris
Copy link

@amitkumarj441 Sorry, I don't understand the question/ask :(

@amitkumarj441
Copy link
Contributor Author

amitkumarj441 commented Sep 4, 2017

@crassirostris I want kubernetes components logs like kube-apiserver, kube-proxy, kube-dns, kubelet, kube-controller-manager, or kube-scheduler in journald basically I have to find where are getting their logs sent (at least some to journald) and to structure Kubernetes logs .
Please have a look in Kibana (on the sidebar), here I'm not getting any API tags(for kube-apiserver).

P.S.: You can find further explanation in description above in the issue itself.
63

@crassirostris
Copy link

See #39800 for details why it's not currently possible in some setups

You can always configure system components to log to stdout in your setup and configure the container runtime to send logs from containers to journald

@mmmmmmpc
Copy link

mmmmmmpc commented Sep 4, 2017

In the current deployment the services are started by systemd as "origin-node" and "origin-master".
The logs can be seen in journald, as for example all access to API to kubernetes master.
Please note that in this case we are not looking for any log coming from a container, but from a service, and that they are all delivered via journald.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or @fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 11, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 11, 2018
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/logging kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

6 participants