部署sematext監控docker容器

1.建立帳號

https://sematext.com/
部署sematext監控docker容器node

2.建立監控的項目名稱

跟着引導進行操做,建立第一個屬於你的第一個監控容器的項目
部署sematext監控docker容器docker

3.在docker環境運行

3.1 docker run方式

sudo docker run -d --name sematext-agent --restart=always -e SPM_TOKEN=f31a28dc-d452-4da7-b704-51ac94*** -v /:/rootfs:ro -v /var/run/docker.sock:/var/run/docker.sock sematext/sematext-agent-dockerjson

3.2 docker-compose 方式

# docker-compose.yml
sematext-agent:
  image: 'sematext/sematext-agent-docker:latest'
  environment:
    #- LOGSENE_TOKEN=YOUR_LOGSENE_TOKEN # create a Logsene app if you don't have one yet, then use its token here and uncomment the line
    - SPM_TOKEN=f31a28dc-d452-4da7-b704-51ac94eb7fd4
    - affinity:container!=*sematext-agent*
  cap_add:
    - SYS_ADMIN
  restart: always
  volumes:
    - '/var/run/docker.sock:/var/run/docker.sock'
    - '/:/rootfs:ro'

3.3 k8s方式:kubectl

建立文件名爲  sematext-agent.yml

# Kubernetes < v1.9
# apiVersion: extensions/v1beta1
# Kubernetes >= v1.9
apiVersion: extensions/v1beta2
kind: DaemonSet
metadata:
name: sematext-agent
spec:
template:
   metadata:
     labels:
       app: sematext-agent
   spec:
     nodeSelector: {}
     hostNetwork: true
     dnsPolicy: "ClusterFirst"
     restartPolicy: "Always"
     containers:
     - name: sematext-agent
       image: sematext/sematext-agent-docker:latest
       imagePullPolicy: "Always"
       env:
       - name: SPM_TOKEN
         value: "f31a28dc-d452-4da7-b704-51ac94eb7fd4"
       #- name: LOGSENE_TOKEN
       #  value: "LOGSENE_TOKEN" # create a Logsene app if you don't have one yet, then use its token here and uncomment these two lines
       volumeMounts:
         - mountPath: /var/run/docker.sock
           name: docker-sock
         - mountPath: /etc/localtime
           name: localtime
         - mountPath: /rootfs
           name: rootfs
           readOnly: true
       securityContext:
         privileged: true
     volumes:
       - name: docker-sock
         hostPath:
           path: /var/run/docker.sock
       - name: localtime
         hostPath:
           path: /etc/localtime
       - name: rootfs
         hostPath:
           path: /

在k8s集羣中建立sematext

kubectl create -f sematext-agent.yml

3.4 k8s:helm

直接執行建立命令

helm install --name release_name \
  --set sematext.spmToken=f31a28dc-d452-4da7-b704-51ac94eb7fd4 \
  --set sematext.logseneToken=YOUR_LOGS_TOKEN \
  stable/sematext-docker-agent

刪除命令

helm delete release_name

或者,能夠指定YAML文件來安裝

helm install --name release_name -f custom-vars.yaml stable/sematext-docker-agent

3.5 rancher方式

# sematext/docker-compose.yml
sematext-docker-agent:
  image: 'sematext/sematext-agent-docker:latest'
  environment:
    - SPM_TOKEN=f31a28dc-d452-4da7-b704-51ac94eb7fd4
  restart: always
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - /:/rootfs:ro
  labels:
    io.rancher.scheduler.global: 'true'
將配置存儲在  sematext/docker-compose.yml 文件中

cd sematext
rancher-compose up -d

3.6 Mesos方式

curl -XPOST -H "Content-type: application/json" http://your_marathon_server:8080/v2/apps -d '
{
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "sematext/sematext-agent-docker",
      "privileged": "true"
    },
    "volumes": [
      {
        "containerPath": "/var/run/docker.sock",
        "hostPath": "/var/run/docker.sock",
        "mode": "RW"
      },
      {
        "containerPath": "/rootfs",
        "hostPath": "/",
        "mode": "RO"
      }
    ],
    "network": "BRIDGE"
  },
  "env": {
        "_LOGSENE_TOKEN": "Remove leading _ in the key and replace this text with your Logsene token",
        "SPM_TOKEN": "dd1d20ce-8e03-41a4-9d1e-30076e424e23",
  },
  "id": "sematext-agent-docker",
  "instances": 1,
  "cpus": 0.5,
  "mem": 300,
  "constraints": [
    [
      "hostname",
      "UNIQUE"
    ]
  ]
}

3.7docker swarm

docker service create --mode global \
--restart-condition any \
--name sematext-agent-docker \
--mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
--mount type=bind,src=/,dst=/rootfs,readonly=true \
-e SPM_TOKEN=dd1d20ce-8e03-41a4-9d1e-30076e424e23  sematext/sematext-agent-docker

更多的博客轉移到我的博客上了,請點擊如下連接:
我的博客api

相關文章
相關標籤/搜索