Coder Social home page Coder Social logo

k8slogchecker's Introduction

K8sLogChecker

Typically, log collections are collected to a log center.

But if there are abnormal characters in the logs of the log collection pod that cause log collection exceptions, the abnormal characters will be generated cyclically.

Therefore, there must be an independent component to monitor the pod logs of the log collection component.

So, there is this project.

docker image: lqbing/k8slogchecker

useage

run out of cluster

Create .env with command cp .env.example .env and modify it, and run below command.

docker run --rm -it --env-file .env -v /root/.kube/config:/root/.kube/config lqbing/k8slogchecker

PS: If you do not want send mail, remove environment var KLC_SEND_MAIL from file .env

run in cluster

You will received error message run in a pod in cluster with default config.

Because program in pod have no permission to access cluster resource with default config.

So, you need create ServiceAccount, Role and ClusterRoleBinding for it.

  • gen k8s.yaml

run below command and input values with tips to generate k8s.yaml

sh ./gen_k8s_yaml.sh
  • apply k8s.yaml
kubectl apply -f k8s.yaml
  • try tirgger cronjob
kubectl -n <namespace> create job --from=cronjob/k8slogchecker k8slogchecker-001

environment vars

  • KLC_RESOURCE_TYPE

[required] The resource type(pod/deployment/statfulset)

  • KLC_NAMESPACE

The namespace(default value is 'default')

  • KLC_RESOURCE_NAME

[required] The resource name

  • KLC_SCAN_LOG_COUNT

The log lines you want scan(default value is 20)

  • KLC_ERR_CONTENT

[required] The error strings you want alert in logs(for example 'ElasticsearchError|[error]')

  • KLC_IGNORE_CONTENT

The ignore strings you want alert in logs(for example 'deprecated')

  • KLC_SEND_MAIL

[required] Do you want send email when alert

If exist and error content in logs, will send email.

Otherwise, will not send email and below environment vars will not effect.

  • MAIL_FROM

[required] The email from(for example '[email protected]')

  • MAIL_PASSWORD

[required] The email host(for example 'smtp.office365.com')

  • MAIL_HOST

[required] The email smtp server port (for example 587)

  • MAIL_TO

[required] The email send to (for example [email protected];[email protected])

  • MAIL_ADD_SUBJECT

A string in the end of mail subject

k8slogchecker's People

Contributors

lqbing avatar

Watchers

 avatar

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.