设为首页 收藏本站
查看: 785|回复: 0

[经验分享] 部署sematext监控docker容器

[复制链接]

尚未签到

发表于 2019-2-20 07:22:51 | 显示全部楼层 |阅读模式
1.创建账号
  https://sematext.com/


2.创建监控的项目名称
  跟着引导进行操作,创建第一个属于你的第一个监控容器的项目


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-docker

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



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-674573-1-1.html 上篇帖子: 自动化部署docker环境 下篇帖子: Docker基础认知
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表