Giter Club home page Giter Club logo

fluentd-deployment's Introduction

fluentd-deployment

Fluentd deployment manifests for integration with Loggly and Papertrail.

Description

This repository contains Docker and Kubernetes assets for deploying a combined Fluentd Papertrail & Loggly log-aggregation toolset to your environment.

Kubernetes

The Kubernetes DaemonSet yaml files in this repo are preconfigured to work with Loggly or Papertrail.

By default they will generate log records from all running pods and any journald services running on the host machines.

To deploy this plugin as a DaemonSet to your Kubernetes cluster, simply adjust the FLUENT_* environment variables in kubernetes/fluentd-daemonset-papertrail.yaml or kubernetes/fluentd-daemonset-loggly.yaml and push it to your cluster with:

kubectl apply -f kubernetes/fluentd-daemonset-(papertrail,loggly).yaml

The Docker image that's used in the DaemonSet is buillt from docker/Dockerfile in this repo.

If you're deploying this to a cluster with RBAC and to a namespace where you need to explicitly spell out your RBAC privileges, reference this snippet for a ServiceAccount below. You'll need to explicitly attach this ServiceAccount to the DaemonSet above:

---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: fluentd-logging
rules:
  - apiGroups:
      - ""
    resources:
      - namespaces
      - pods
    verbs:
      - get
      - list
      - watch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: fluentd-logger
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: fluentd-logging
subjects:
- kind: ServiceAccount
  name: fluentd-logging
  namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: fluentd-logging
  namespace: kube-system
---

Advanced Usage

Kubernetes Annotations

Papertrail

Once the DaemonSet is running on your cluster, you can redirect logs to alternate Papertrail destinations by adding annotations to your Pods or Namespaces:

solarwinds.io/papertrail_host: 'logs0.papertrailapp.com'
solarwinds.io/papertrail_port: '12345'

If both the Pod and Namespace have annotations for any running Pod, the Pod's annotation is used.

Loggly

Once the DaemonSet is running on your cluster, you can redirect logs to alternate Loggly destinations by adding annotations to your Pods or Namespaces:

solarwinds.io/loggly_token: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

If both the Pod and Namespace have annotations for any running Pod, the Pod's annotation is used.

Kubernetes Audit Logs

If you'd like to redirect Kubernetes API Server Audit logs to a seperate Papertrail or Loggly destination, add a second match statement to your fluent.conf:

<match kube-apiserver-audit>
    type papertrail
    num_threads 4

    papertrail_host "#{ENV['FLUENT_PAPERTRAIL_AUDIT_HOST']}"
    papertrail_port "#{ENV['FLUENT_PAPERTRAIL_AUDIT_PORT']}"
</match>

This requires you to configure an audit policy file on your cluster.

Docker Details

The fluentd process expects a fluentd configuration file at: /fluentd/etc/fluent.conf

The Docker image bundles a default fluent.conf as well as other import-able fluentd config files.

The Kubernetes assets are a good example of overriding the default fluent.conf and importing configurations for things such as gathering pod logs from kubernetes or journald logs from systemd.

Plugins

This Docker image bundles the following (optional) fluentd plugins:

The papertrail plugin allows us to treat Papertrail accounts as outputs.

The loggly-syslog plugin allows us to treat Loggly accounts as outputs using the syslog protocol.

The systemd plugin allows us to treat a host's journald logs as fluent input. The image is based on Debian, so that we can easily bundle the required systemd libraries.

The kubernetes_metadata_input plugin lets us treat the Kubernetes Event API as fluent input.

The kubernetes_metadata_filter plugin lets us recognize and bind Kubernetes specific metadata to logs from Kubernetes pods.

The detect-exceptions plugin allows us to recognize multi-line error messages, from multiple languages, and combine them into single events. This is disabled by default in all of the included manifests.

Development

We have a Makefile to wrap common functions and make life easier.

Release in Quay.io

make release-docker TAG=$(VERSION)

Contributing

Bug reports and pull requests are welcome on GitHub at: https://github.com/solarwinds/fluentd-deployment

Questions/Comments?

Please open an issue, we'd love to hear from you. As a SolarWinds Innovation Project, this adapter is supported in a best-effort fashion.

fluentd-deployment's People

Contributors

leecalcote avatar parsiuk avatar ramyala avatar trevrosen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fluentd-deployment's Issues

Increase of logs to loggly

I was previously using a daemonset suggested in this blog post on the loggly website. https://www.loggly.com/blog/send-kubernetes-logs-loggly/

I discovered this officially supported fluentd daemonset but when I included this deployment into my cluster the logging increased dramatically. I turned off the systemd.conf which helped quite a bit but I still am seeing a 4x increase in logging. How does the syslog-plugin know where it left off with logging from pods? I am trying to figure out why we are seeing such an increase of logs between the two different ways of implementing loggly into our cluster.

Missing journal mount path

I was getting a lot of errors when deploying your kubernetes template.

2018-11-05 09:50:07 +0000 [warn]: #0 Systemd::JournalError: No such file or directory retrying in 1s

Fixed it with adding missing mount paths

volumeMounts:
        - name: journal
          mountPath: /var/log/journal
          readOnly: true

volumes:
      - name: journal
        hostPath:
          path: /run/log/journal

EKS 1.24

Do you have a configuration which works with EKS 1.24? The upgrade to 1.24 removes the docker shim, which in turn should put logs in /var/log/containers instead of the previously specified docker path.

There's nothing on the papertrail website I could see that mentions how to adapt configs for this logging change. Logspout fails completely, and this fluentd config only captures api logs -- no application logs.

Setup Versioning

We should start a proper versioning scheme for this project and release a corresponding new image.

Implement Liveness Probe

An issue on the fluent-plugin-papertrail repository exposed the need for implementing Liveness Probes here: solarwinds/fluent-plugin-papertrail#27

We've already been using the Liveness Probes referenced in that thread, internally, for our Fluentd Kubernetes DaemonSet manifests for a few months with success.

We should expose this snippet here in the fluentd-deployment README as a recommendation to users who find their fluentd processes frozen up over time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.