Code Monkey home page Code Monkey logo

zabbix-kubernetes-monitoring's Introduction

Description

zabbix-kubernetes-monitoring is zabbix-agent script and template for zabbix server. It is used for Kubernetes monitoring by Zabbix. Easy to deploy and configure. Auto discovery of pods, deployments, services, etc.

Installation

  1. Copy zabbix_check_kubernetes to /usr/lib/zabbix/externalscripts and k8s-stats.json to /etc/zabbix/ and fix file permissions
cp zabbix_check_kubernetes /usr/lib/zabbix/externalscripts/
cp k8s-stats.json /etc/zabbix/
chmod +x /usr/lib/zabbix/externalscripts/zabbix_check_kubernetes
chown zabbix. /etc/zabbix/k8s-stats.json
chmod 640 /etc/zabbix/k8s-stats.json
  1. Import Zabbix template k8s-zabbix-template.xml to Zabbix server
  2. Create zabbix user in Kubernetes (can use zabbix-user-example.yml) and set it's token and API server url in k8s-stats.json. The root item key names in JSON config refer to
  3. Apply template to host {$K8S_CLUSTER_NAME} macro value in zabbix configuration, see step 5.
  4. Update {$K8S_CLUSTER_NAME} macro value appropriately in host configuration. Example:
{
    "my-cloud-123": {
        "api_url": "https://my_cloud_address:6443",
        "access_token": "my_cloud_token"
    }
}

You then need to use {$K8S_CLUSTER_NAME} => my-cloud-123 on zabbix host you have attached the template to

Multi-Cluster support

Simply add more dicts to k8s_stats.json. Sample config file provided in repo has two clusters added.

How to create zabbix user in Kubernetes

$ kubectl apply -n kube-system -f zabbix-user-example.yml 
serviceaccount/zabbix-user created
clusterrole.rbac.authorization.k8s.io/zabbix-user created
clusterrolebinding.rbac.authorization.k8s.io/zabbix-user created

How to retrieve TOKEN and API SERVER

  1. TOKEN:
$ TOKENNAME=$(kubectl get sa/zabbix-user -n kube-system -o jsonpath='{.secrets[0].name}')
$ TOKEN=$(kubectl -n kube-system get secret $TOKENNAME -o jsonpath='{.data.token}'| base64 --decode)
$ echo $TOKEN
  1. API SERVER:
$ APISERVER=https://$(kubectl -n default get endpoints kubernetes --no-headers | awk '{ print $2 }')
$ echo $APISERVER

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.