GithubHelp home page GithubHelp logo

zebrium / ze-kubernetes-collector Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 3.0 136 KB

DEPRICATED: Zebrium's log collector for Kubernetes environments

Shell 16.31% Mustache 83.69%
anomaly-detection structured-data log-analytics log-collector log-management deprecated

ze-kubernetes-collector's Introduction

DEPRECATED: This is repo is currently depricated in the helm chart has been moved here

No Maintenance Intended

KUBERNETES COLLECTOR DETAILS

Zebrium's Kubernetes collector sends logs to Zebrium for automated Anomaly detection. Our github repository is located here.

ze-kubernetes-collector

Features

  • Two step deployment using Kubernetes commands
  • Sends logs from all Pods/Containers in a Kubernetes clusters
  • Runs a single instance of the collector per node in a Kubernetes cluster

Getting Started

Installing via helm

helm version 3

  1. helm upgrade -i zlog-collector zlog-collector --namespace zebrium --create-namespace --repo https://raw.githubusercontent.com/zebrium/ze-kubernetes-collector/master/charts --set zebrium.collectorUrl=YOUR_ZE_API_URL,zebrium.authToken=YOUR_ZE_API_AUTH_TOKEN,zebrium.deployment=YOUR_DEPLOYMENT_NAME,zebrium.timezone=KUBERNETES_HOST_TIMEZONE

KUBERNETES_HOST_TIMEZONE is the timezone setting on kubernetes host, for example, "UTC" or "America/Los_Angeles". If this option is not provided, default value UTC will be used.

helm version 2

  1. helm install --namespace zebrium --name zlog-collector --repo https://raw.githubusercontent.com/zebrium/ze-kubernetes-collector/master/charts zlog-collector --set zebrium.collectorUrl=YOUR_ZE_API_URL,zebrium.authToken=YOUR_ZE_API_AUTH_TOKEN,zebrium.deployment=YOUR_DEPLOYMENT_NAME,zebrium.timezone=KUBERNETES_HOST_TIMEZONE

KUBERNETES_HOST_TIMEZONE is the timezone setting on kubernetes host, for example, "UTC" or "America/Los_Angeles". If this option is not provided, default value UTC will be used.

Uninstalling via helm

If you used the "helm install" command to install zlog-collector chart, you should use the following command to delete:

helm version 3

helm delete zlog-collector -n zebrium

helm version 2

helm delete --purge zlog-collector -n zebrium

Installing via kubectl

The commands below install the Zebrium log collector as a Kubernetes DaemonSet. It runs one collector instance on each node in a Kubernetes cluster.

  1. kubectl create secret generic zlog-collector-config --from-literal=log-collector-url=YOUR_ZE_API_URL --from-literal=auth-token=YOUR_ZE_API_AUTH_TOKEN
  2. kubectl create -f https://raw.githubusercontent.com/zebrium/ze-kubernetes-collector/master/templates/zlog-collector.yaml

After a few minutes, logs should be viewable on Zebrium web UI.

The commands above install zlog-collector in default namespace. To install it in a separate namespace, follow the folowing instructions:

  1. kubectl create namespace <new_namespace_name>. Replace <new_namespace_name> with your real namespace name.
  2. kubectl create secret generic zlog-collector-config --from-literal=log-collector-url=YOUR_ZE_API_URL --from-literal=auth-token=YOUR_ZE_API_AUTH_TOKEN --namespace <new_namespace_name>
  3. wget https://raw.githubusercontent.com/zebrium/ze-kubernetes-collector/master/templates/zlog-collector.yaml
  4. Edit the downloaded zlog-collector.yaml, change namespace: default in the file to namespace: <new_namespace_name> (on one line).
  5. kubectl create -f zlog-collector.yaml --namespace <new_namespace_name>

Uninstalling via kubectl

The commands below will uninstall the Zebrium log collector. This would typically be done prior to installing a newer version of the collector.

kubectl delete -f https://raw.githubusercontent.com/zebrium/ze-kubernetes-collector/master/templates/zlog-collector.yaml
kubectl delete secret zlog-collector-config

Note: You do not have to delete the secret if there is no change in URL and token when installing an upgraded collector.

Configuration

No special configuration is required

Tunable Parameters

Parameter Description Default Value Note
zebrium.bufferTotalLimitSize Total disk buffer to use on node 8GB Use helm command line option "--set zebrium.bufferTotalLimitSize=BUFFER_SIZE" to set. BUFFER_SIZE is either in MB or GB. For example, "256MB" or "1GB"
zebrium.flushThreadCount The number of threads to flush the buffer. 4 If the destination of your logs is remote storage or service, adding a flush_thread_count option will parallelize your outputs (the default is 4). Using multiple threads can hide the IO/network latency
zebrium.nodeLogsPath A list of log files to process. /var/log/*.log, /var/log/syslog, /var/log/messages, /var/log/secure List must not have spaces.
zebrium.deployment Identifies the environment or deployment. E.g. "production", "qa", "dev". default Default value allows the logs to be treated as a shared service and to span multiple Environments or Deployments
zebrium.collectorUrl Url of the Zebrium Log Collector Endpoint
zebrium.authToken Zebrium Authentication Token needed to interact with the Collection API
zebrium.verifySSL Boolean flag to enable or disables SSL verification on connection with the collectors. true
zebrium.timezone Time Zone of the Collector UTC You can use the ENV Variable KUBERNETES_HOST_TIMEZONE to use the Timezone of the k8s cluster
zebrium.excludePodRegex Regex to exlude pods from collection EX. "^fluentbit.*" would exclude all fluentbit pods from collection
zebrium.excludePath Excludes Path of Logs from collection if they reside in the directories specified in zebrium.nodeLogsPath [\"/var/log/boot.log\",\"/var/log/lastlog\"]
zebrium.tailFromHead Boolean to enable the tailing of logs from the head of the file. If false, logs will only be streamed from the current point of time. true

Log Path Mapping

Log path mapping is the process of detecting semantic items in log file paths (ids, configs and tags) then including them in the Zebrium log data. This is enabled by providing a JSON mapping file to the log collector, as described in the repo at https://www.github.com/zebrium/ze-fluentd-plugin. To use this functionality with the supplied helm chart a customValues.yaml file should be completed and supplied to the helm install command line with:

helm install ... -f customValues.yaml ...

A prototype example_logPathMappings.yaml file is provided in the repo under the example directory, with format:

overridePMFConfig: true
zebrium:
  pathMapFile: "pathMapFile.json"
customPMFConfig: {
  "mappings": {
    "patterns":["/var/log/remote_logs/(?<host>[^/]+)/.*"],
    "tags": [],
    "ids" : [
        "host"],
    "configs": []
  }
}

Custom Namespace to Service Group Mapping

Custom Namespace to Service Group Matching is the process of dynamically assigning a service group to a log stream based on the resources namesapce. This is enabled by providing a JSON mapping file to the log collector. To use this functionality with the supplied helm chart a customValues.yaml file should be completed and supplied to the helm install command line with:

helm install ... -f customValues.yaml ...

A prototype example_ns_svcgrp.yaml file is provided in the repo under the example directory, with format:

overrideSVCGRPConfig: true
zebrium:
  svcgrpMapFile: "svcgrpMapFile.json"
customSVCGRPConfig: {
  "mynamespace1" : "svcgrp1", 
  "mynamespace2" : "svcgrp1", 
  "mynamespace3" : "svcgrp3"
}

Setup

By default, Zebrium's kubernetes log collector will be deployed to all Nodes in your cluster and collect logs from each container.

Additionally, each log line will have associated meta data from your Kubernetes deployment viewable in the Zebrium UI. This meta data will include:

  1. All Kubernetes Identifier tags such as Node, Pod Name and Id, Container Name and Id, Namespace, etc.
  2. All Kubernetes Labels
  3. All Kubernetes Annotations

Testing your installation

Once the collector has been deployed in your Kubernetes environment, your logs and anomaly detection will be available in the Zebrium UI.

Troubleshooting

In the event that Zebrium requires the ze_collector logs for troubleshooting, you can use these commands:

  1. Use: kubectl get pods --namespace zebrium to get the zlog-collector pod names first.
  2. Use: kubectl logs <pod_name> --namespace zebrium to get logs. Note: There may be multiple pods containing logs.

Contributors

  • Brady Zuo (Zebrium)
  • Braeden Earp (Zebrium)
  • Rob Fair (Zebrium)

ze-kubernetes-collector's People

Contributors

b3arp avatar bradyzebrium avatar robf17 avatar rodbagg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ze-kubernetes-collector's Issues

zlog-collector requires /etc/localtime

Well, I have some machines running RancherOS, and they don't have /etc/localtime as shown:

Events:
  Type     Reason     Age                  From                    Message
  ----     ------     ----                 ----                    -------
  Normal   Scheduled  <unknown>            default-scheduler       Successfully assigned zebrium/zlog-collector-4hs64 to docker-vmss-1
  Warning  Failed     2m21s                kubelet, docker-vmss-1  Error: failed to start container "zlog-collector": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/etc/localtime\\\" to rootfs \\\"/var/lib/docker/overlay2/2087d8e3a8d2db5dcc669407a2879c028c83157b0875ff88d7d9feb66626ff82/merged\\\" at \\\"/var/lib/docker/overlay2/2087d8e3a8d2db5dcc669407a2879c028c83157b0875ff88d7d9feb66626ff82/merged/usr/share/zoneinfo/America/Los_Angeles\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
  Warning  Failed     2m21s                kubelet, docker-vmss-1  Error: failed to start container "zlog-collector": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/etc/localtime\\\" to rootfs \\\"/var/lib/docker/overlay2/8e48fe511efa2e4ed858e3457865f2a0d60e15101ba6d416da69f08b383fd4c8/merged\\\" at \\\"/var/lib/docker/overlay2/8e48fe511efa2e4ed858e3457865f2a0d60e15101ba6d416da69f08b383fd4c8/merged/usr/share/zoneinfo/America/Los_Angeles\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
  Warning  Failed     2m5s                 kubelet, docker-vmss-1  Error: failed to start container "zlog-collector": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/etc/localtime\\\" to rootfs \\\"/var/lib/docker/overlay2/1d3cb742ce8715861be2649fab32730508ff658c0829bc7446da53e6b1a697be/merged\\\" at \\\"/var/lib/docker/overlay2/1d3cb742ce8715861be2649fab32730508ff658c0829bc7446da53e6b1a697be/merged/usr/share/zoneinfo/America/Los_Angeles\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
  Warning  Failed     98s                  kubelet, docker-vmss-1  Error: failed to start container "zlog-collector": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/etc/localtime\\\" to rootfs \\\"/var/lib/docker/overlay2/c99a4e457ebe5fdebb108441220a14676976444624fbe94dc13e663fb24f4af3/merged\\\" at \\\"/var/lib/docker/overlay2/c99a4e457ebe5fdebb108441220a14676976444624fbe94dc13e663fb24f4af3/merged/usr/share/zoneinfo/America/Los_Angeles\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
  Normal   Created    52s (x5 over 2m22s)  kubelet, docker-vmss-1  Created container zlog-collector
  Normal   Pulled     52s (x5 over 2m22s)  kubelet, docker-vmss-1  Container image "zebrium/zlog-collector:latest" already present on machine
  Warning  Failed     52s                  kubelet, docker-vmss-1  Error: failed to start container "zlog-collector": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/etc/localtime\\\" to rootfs \\\"/var/lib/docker/overlay2/74e0367cc231875c78b83c77a31895dc0cb48a18fe6730a20dc40e2e8d9d0f1f/merged\\\" at \\\"/var/lib/docker/overlay2/74e0367cc231875c78b83c77a31895dc0cb48a18fe6730a20dc40e2e8d9d0f1f/merged/usr/share/zoneinfo/America/Los_Angeles\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
  Warning  BackOff    11s (x9 over 2m20s)  kubelet, docker-vmss-1  Back-off restarting failed container

trying to mount directly my timezone also won't work:

Events:
  Type     Reason     Age                   From                    Message
  ----     ------     ----                  ----                    -------
  Normal   Scheduled  <unknown>             default-scheduler       Successfully assigned zebrium/zlog-collector-l5qt4 to docker-vmss-1
  Warning  Failed     14m                   kubelet, docker-vmss-1  Error: failed to start container "zlog-collector": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/usr/share/zoneinfo/Europe/Lisbon\\\" to rootfs \\\"/var/lib/docker/overlay2/dbd01800fd4de6382c806dc1c950cc0c99cbfa9085822a61fc8b8c984390bd0d/merged\\\" at \\\"/var/lib/docker/overlay2/dbd01800fd4de6382c806dc1c950cc0c99cbfa9085822a61fc8b8c984390bd0d/merged/usr/share/zoneinfo/America/Los_Angeles\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
  Warning  Failed     14m                   kubelet, docker-vmss-1  Error: failed to start container "zlog-collector": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/usr/share/zoneinfo/Europe/Lisbon\\\" to rootfs \\\"/var/lib/docker/overlay2/a9906d9d3957a8f653ac97a92173f10a8c3bb5fcd02eb3b2bed8f5cb657a79b6/merged\\\" at \\\"/var/lib/docker/overlay2/a9906d9d3957a8f653ac97a92173f10a8c3bb5fcd02eb3b2bed8f5cb657a79b6/merged/usr/share/zoneinfo/America/Los_Angeles\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
  Warning  Failed     14m                   kubelet, docker-vmss-1  Error: failed to start container "zlog-collector": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/usr/share/zoneinfo/Europe/Lisbon\\\" to rootfs \\\"/var/lib/docker/overlay2/3a772d8cb92cedde9c6594dbb0f8a2242b42b37f10253087f762a075eb8d19f2/merged\\\" at \\\"/var/lib/docker/overlay2/3a772d8cb92cedde9c6594dbb0f8a2242b42b37f10253087f762a075eb8d19f2/merged/usr/share/zoneinfo/America/Los_Angeles\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
  Warning  Failed     14m                   kubelet, docker-vmss-1  Error: failed to start container "zlog-collector": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/usr/share/zoneinfo/Europe/Lisbon\\\" to rootfs \\\"/var/lib/docker/overlay2/ac9e09ba373401fedd924586fd9fd5ae9a47bc93790057f6d7b47dd36635fcad/merged\\\" at \\\"/var/lib/docker/overlay2/ac9e09ba373401fedd924586fd9fd5ae9a47bc93790057f6d7b47dd36635fcad/merged/usr/share/zoneinfo/America/Los_Angeles\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
  Normal   Created    13m (x5 over 14m)     kubelet, docker-vmss-1  Created container zlog-collector
  Normal   Pulled     13m (x5 over 14m)     kubelet, docker-vmss-1  Container image "zebrium/zlog-collector:latest" already present on machine
  Warning  Failed     13m                   kubelet, docker-vmss-1  Error: failed to start container "zlog-collector": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/usr/share/zoneinfo/Europe/Lisbon\\\" to rootfs \\\"/var/lib/docker/overlay2/00dbf0e393b4c806d0a70f28bfeeed209817a7a7a73ebdecf15e5ec3d666efd9/merged\\\" at \\\"/var/lib/docker/overlay2/00dbf0e393b4c806d0a70f28bfeeed209817a7a7a73ebdecf15e5ec3d666efd9/merged/usr/share/zoneinfo/America/Los_Angeles\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
  Warning  BackOff    4m49s (x45 over 14m)  kubelet, docker-vmss-1  Back-off restarting failed container

I think there might be no tzdata on this OS, so it might be helpful to have a way to select it by env var or something.

My solution ATM was to add an initContainer linking the expected timezone:

      initContainers:
      - name: tzdata-fixer
        image: busybox
        imagePullPolicy: IfNotPresent
        args:
        - ln
        - -fs
        - /usr/share/zoneinfo/Europe/Lisbon
        - /etc/localtime

Support configurable docker root directory

I tried to use ze-kubernetes-collector and found a issue.

We are using /path/to/docker as a docker-root-directory.
It is not mounted as default and cannot be added through custom values file.
So log-collector cannot access to our container's stdout/err logs.

So I added volumeMounts and volumes in Daemonset spec.
I think it is not just our special case.
It will be nice to be able to configure root directory in values file

container "zlog-collector" requires resource limits

We have an OPA agent running and, as everyone should, we have a requirement that all containers must specify resource limits. This is more than necessary to keep a cluster healthy. While installing the log collector, I got denied:

Error: admission webhook "validating-webhook.openpolicyagent.org" denied the request: container "zlog-collector" requires resource limits

You guys should really set this up. Any idea what good values would be for these limits?

unable to disable secret creation

Currently the chart always creates the secret and there is no way to disable it.

having a secret.enabled option would be very useful.

unable to configure daemonset

There are several configuration options that require manual edits of the templates to change

            - name: EXCLUDE_POD_REGEX
              value: ""
            - name: TAIL_FROM_HEAD
              value: "true"
            - name: FLUENTD_LOG_FILE
              value: ""
            - name: ZE_LOG_LEVEL
              value: "info"
            - name: NODE_LOGS_PATH
              value: "/var/log/*.log,/var/log/syslog,/var/log/messages,/var/log/secure"
            - name: EXCLUDE_PATH
              value: "[\"/var/log/boot.log\",\"/var/log/lastlog\"]"
            - name: FLUSH_INTERVAL
              value: "30s"
            - name: VERIFY_SSL
              value: "false"

A nice to have would be to allow overriding this by putting it in the values.yaml

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.