sstarcher / docker-sensu Goto Github PK
View Code? Open in Web Editor NEWDockerized Sensu - Client, Server, Api
License: MIT License
Dockerized Sensu - Client, Server, Api
License: MIT License
Hi,
First of all, great work Dockerising Sensu in such a friendly & useful way.
I seem to be experiencing an issue wherein the server container is not correctly picking up the transport type, either from ENV vars or from the config.
If I docker exec -it sensu_server_1 bash
and query the env, I get the following:
root@ccb88ba37781:/# env | grep TRANSPORT
TRANSPORT_NAME=redis
And if I cat the /etc/sensu/conf.d/transport.json
, I can see the following config (Host mount):
root@ccb88ba37781:/# cat /etc/sensu/conf.d/transport.json
{
"transport": {
"name": "redis",
"reconnect_on_error": true
}
}
Yet when I run sensu-server -P
, it always returns:
root@ccb88ba37781:/# sensu-server -P
{"timestamp":"2017-04-14T21:49:02.749351+0000","level":"warn","message":"outputting compiled configuration and exiting"}
{
"client":{},
"sensu":{
"spawn":{
"limit":12
}
},
"transport":{
"name":"rabbitmq",
"reconnect_on_error":true
},
"checks":{},
"filters":{},
"mutators":{},
"handlers":{},
"extensions":{}
}
This means that my checks aren't getting scheduled! Any ideas?
Thanks.
Loading a check which intentionally fails yields expected client output, but it doesn't appear that the server container sees the failure or tries to invoke the correct handler.
I have this check:
{
"checks": {
"proc-fail": {
"command": "check-process.rb -p idontexist -W 1",
"subscribers": [
"all"
],
"interval": 60
}
}
}
I see the sensu client log reflect that the check has failed:
{"timestamp":"2017-02-08T16:08:06.439738-0500","level":"info","message":"publishing check result","payload":{"client":"core01.private.prv","check":{"command":"check-process.rb -p idontexist -W 1","name":"proc-fail","issued":1486588086,"executed":1486588086,"duration":0.284,"output":"CheckProcess CRITICAL: Found 0 matching processes; cmd /idontexist/\n","status":2}}}
however the server log never reflects this failure, and doesn't even attempt to invoke the default handler:
{"timestamp":"2017-02-08T16:06:37.900642-0500","level":"warn","message":"loading extension files from directory","directory":"/etc/sensu/extensions"}
{"timestamp":"2017-02-08T16:06:37.900801-0500","level":"warn","message":"loaded extension","type":"filter","name":"occurrences","description":"filter events using event occurrences"}
{"timestamp":"2017-02-08T16:06:37.900888-0500","level":"warn","message":"loaded extension","type":"mutator","name":"json","description":"returns JSON formatted event data"}
{"timestamp":"2017-02-08T16:06:37.900966-0500","level":"warn","message":"loaded extension","type":"mutator","name":"only_check_output","description":"returns check output"}
{"timestamp":"2017-02-08T16:06:37.901048-0500","level":"warn","message":"loaded extension","type":"mutator","name":"ruby_hash","description":"returns ruby hash event data"}
{"timestamp":"2017-02-08T16:06:37.901121-0500","level":"warn","message":"loaded extension","type":"handler","name":"debug","description":"returns raw event data"}
my server block in docker-compose is configured as:
server:
image: sstarcher/sensu:0.26
command: server
links:
- redis
- api
volumes:
- "/opt/sensu/check.d:/etc/sensu/check.d"
- "/opt/sensu/handlers:/etc/sensu/handlers"
- "/etc/localtime:/etc/localtime:ro"
- "/etc/timezone:/etc/timezone:ro"
- "/opt/sensu/logs:/var/log/sensu"
environment:
RUNTIME_INSTALL: mailer
and my default handler is configured as:
{
"handlers": {
"default": {
"type": "pipe",
"command": "/etc/sensu/handlers/mailer.rb -j /etc/sensu/handlers/mailer.json",
"mail_from": "[email protected]",
"mail_to": "[email protected]",
"smtp_address": "192.168.99.99",
"smtp_domain": "private.prv"
}
}
}
the mailer.rb and mailer.json are mapped directly into the handlers directory.
What am I doing wrong? I'd be happy to extend the docker-sensu documentation to cover handlers and handler usage once I figure this out.
Thank you!
Please update to Sensu 1.6.1 which was recently released.
Howdy!!
I'm trying to create a Sensu Stack in order to have a quick way to instantiate a development stage for Sensu related tools. I found your image very convenient. However I'm having some issues starting the sensu client container.
This is my docker-compose.yml
version: "3"
services:
rabbitmq:
image: rabbitmq:3.6-management-alpine
ports:
- 15672:15672
environment:
RABBITMQ_HIPE_COMPILE: 1
RABBITMQ_ERLANG_COOKIE: 'sarasa'
networks:
- my-net
server:
image: sstarcher/sensu
command: server
links:
- api
- rabbitmq
- redis
volumes:
- "./server-conf/server.json:/etc/sensu/config.json"
- "./logs:/var/log/sensu/"
networks:
- my-net
api:
image: sstarcher/sensu
command: api
links:
- redis
ports:
- '4567:4567'
volumes:
- "./api-conf/api.json:/etc/sensu/config.json"
- "./logs:/var/log/sensu/"
networks:
- my-net
client:
image: sstarcher/sensu
command: client
links:
- rabbitmq
volumes:
- "/dev:/host_dev/:ro"
- "/proc:/host_proc/:ro"
- "/sys:/host_sys/:ro"
- "./client-conf/client.json:/etc/sensu/config.json"
- "./logs:/var/log/sensu/"
environment:
HOST_DEV_DIR: /host_dev
HOST_PROC_DIR: /host_proc
HOST_SYS_DIR: /host_sys
networks:
- my-net
uchiwa:
image: sstarcher/uchiwa
links:
- api
ports:
- '3000:3000'
volumes:
- "./dashboard:/etc/sensu/dashboard.d"
- "./logs/uchiwa.log:/var/log/uchiwa.log"
networks:
- my-net
redis:
image: redis:3
networks:
- my-net
networks:
my-net:
All of the containers start just fine but the one for the client. Is shows this message:
{"timestamp":"2017-06-16T20:37:18.101670+0000","level":"warn","message":"loading config file","file":"/etc/sensu/config.json"}
{"timestamp":"2017-06-16T20:37:18.102094+0000","level":"warn","message":"loading config files from directory","directory":"/etc/sensu/conf.d"}
{"timestamp":"2017-06-16T20:37:18.102367+0000","level":"warn","message":"loading config file","file":"/etc/sensu/conf.d/transport.json"}
{"timestamp":"2017-06-16T20:37:18.102640+0000","level":"warn","message":"config file applied changes","file":"/etc/sensu/conf.d/transport.json","changes":{}}
{"timestamp":"2017-06-16T20:37:18.102879+0000","level":"warn","message":"loading config file","file":"/etc/sensu/conf.d/client.json"}
{"timestamp":"2017-06-16T20:37:18.102981+0000","level":"fatal","message":"config file must be valid json","file":"/etc/sensu/conf.d/client.json","error":"unexpected comma at line 7, column 17 [parse.c:575]"}
{"timestamp":"2017-06-16T20:37:18.103128+0000","level":"fatal","message":"SENSU NOT RUNNING!"}
./client-conf/client.json looks like:
{
"client": {
"socket": {
"bind": "127.0.0.1"
},
"name": "4494446b45e0",
"address": "127.0.0.1",
"subscriptions": [
"docker"
],
"keepalive": {
"thresholds": {
"warning": 120,
"critical": 180
},
"handler": "default"
}
},
"transport": {
"name": "redis",
"reconnect_on_error": true
},
"rabbitmq": {
"host": "rabbitmq",
"port": 5671,
"vhost": "/sensu",
"user": "sensu",
"password": "secret",
"heartbeat": 30,
"prefetch": 50
}
}
I don't know where it gets that /etc/sensu/conf.d/* config files. Can you lend me a hand?
Thanks in advance!
I would like to verify/test that all checks are running on host machine and not within the docker container where Sensu client is running. Could you please help out with some hints? My docker-compose file looks like this:
version: '2'
services:
client:
build: .
command: client
container_name: docker-sensu-client-prod
image: adop/sensu-client
environment:
CLIENT_NAME: aca-jira01
CLIENT_SUBSCRIPTIONS: basic
CLIENT_ADDRESS: 127.0.0.1
REDIS_HOST: 192.168.99.100
REDIS_PORT: 6379
REDIS_AUTO_RECONNECT: "true"
REDIS_RECONNECT_ON_ERROR: "true"
HOST_DEV_DIR: /host_dev
HOST_PROC_DIR: /host_proc
HOST_SYS_DIR: /host_sys
ports:
- '3030:3030'
volumes:
- /dev:/host_dev/:ro
- /proc:/host_proc/:ro
- /sys:/host_sys/:ro
Looks like the Docker build of this repo failed a few weeks back: https://hub.docker.com/r/sstarcher/sensu/builds/bebvh7em4nnbf7qeagg3fqh/
You could always link your builds with "Debian" - so it'll get rebuilt whenever Debian pushes out a change. That'll ensure you're repo gets built regularly and stops these random fails from being a problem as they'll no-doubt get retried before too long.
Perhaps you can repush and update Sensu to version 0.26.5 whilst we're there?
When using the example docker-compose.yml I ran into a problem where the client container would try to run parallel gem installations of sstarcher/aws and mailer plugins which both have dependencies on unf_ext. It seems to create a race condition where one gem starts to build unf_ext and the other begins to build unf_ext and wipes out the priors work as seen here:
https://github.com/sstarcher/sensu-plugins-aws/archive/master.tar.gz
Downloading sensu-plugins/mailer:master
https://github.com/sensu-plugins/sensu-plugins-mailer/archive/master.tar.gz
Building sensu-plugins/mailer:master
Building sstarcher/aws:master
Installing sensu-plugins/mailer:master
Installing sstarcher/aws:master
ERROR: Error installing sensu-plugins-mailer-1.2.0.gem:
ERROR: Failed to build gem native extension.
current directory: /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/unf_ext-0.0.7.4/ext/unf_ext
/opt/sensu/embedded/bin/ruby -r ./siteconf20170911-31-1dglfcg.rb extconf.rb
checking for -lstdc++... yes
creating Makefile
current directory: /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/unf_ext-0.0.7.4/ext/unf_ext
make "DESTDIR=" clean
current directory: /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/unf_ext-0.0.7.4/ext/unf_ext
make "DESTDIR="
compiling unf.cc
In file included from unf.cc:1:0:
unf/normalizer.hh:11:19: fatal error: util.hh: No such file or directory
compilation terminated.
Makefile:209: recipe for target 'unf.o' failed
make: *** [unf.o] Error 1
make failed, exit code 2
Gem files will remain installed in /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/unf_ext-0.0.7.4 for inspection.
Results logged to /opt/sensu/embedded/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0/unf_ext-0.0.7.4/gem_make.out
I've worked around this by preventing the install script from backgrounding each plugin install. I can submit a PR but I'm not sure if this is the best approach.
When starting the container, if you mount in custom config or even client.json, it's blindly being processed and replaced with the template.
This is an excellent set of Docker images and I was nearly able to use "as-is", but I am using Amazon SES for sending emails and this doesn't work "out of the box".
The mailer-ses plugin is already installed:
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugins-mailer-0.0.2/bin/handler-mailer-ses.rb
/opt/sensu/embedded/bin/handler-mailer-ses.rb
But that plugin requires a Ruby gem aws-ses
, which isn't installed by default.
For now I have extended the image by running gem install aws-ses
, but it would be nice to have it built-in. I see there's a RUNTIME_INSTALL
env variable, but it looks like that's for plugins, not the gems they require.
We use "requirepass"/"masterauth" for our Redis configuration, and need to be able to provide a password for the Sensu Redis configuration so that it is able to authenticate with our Redis cluster.
Any chance of getting new versions of the containers for the latest versions?
Fail to start with the example docker-compose.yml
file.
The error is
Starting sensu_api_1
Attaching to sensu_api_1
api_1 | sed: no input files
sensu_api_1 exited with code 4
The problem seem to be in the /bin/start file, line 49 to 51
Since isn't *.rb
file in /opt/sensu/embedded/bin/
.
Sensu Client compose-file looks like this:
version: '2'
services:
client:
command: client
container_name: docker-sensu-client-prod
image: sstarcher/sensu
environment:
CLIENT_NAME: testclient
CLIENT_SUBSCRIPTIONS: os
CLIENT_ADDRESS: 127.0.0.1
RUNTIME_INSTALL: docker memory-checks
REDIS_HOST: 192.168.99.100
REDIS_PORT: 6379
#REDIS_PASSWORD: ""
#REDIS_DB: 0
REDIS_AUTO_RECONNECT: "true"
REDIS_RECONNECT_ON_ERROR: "true"
volumes:
- ./resources/check.d:/etc/sensu/check.d/
ports:
- '3030:3030'
Same place as the compose-file is placed I have folder named resources
which contains check.d
folder where all check files are placed. After running docker-compose up -d
all files within ./resource/check.d are deleted.
Hi,
When I restart one of the containers (I am currently experimenting with the client), it overrides the config files mapped to my host when it starts up. But I would like to make changes to this config.
How to do that?
Hi,
I would add multiple clients on the same server. It would be cool add port in the template in order to custom port :)
why ENV CLIENT_ADDRESS not set default container ip?
docker-compose.yml contents:
api:
image: sstarcher/sensu
command: api
links:
- rabbitmq
- redis
server:
image: sstarcher/sensu
command: server
volumes:
- './checks:/etc/sensu/check.d/'
links:
- rabbitmq
- redis
- api
client:
image: sstarcher/sensu
command: client
environment:
CLIENT_NAME: qa-poker
CLIENT_ADDRESS: '127.0.0.1'
CLIENT_SUBSCRIPTIONS: test
RUNTIME_INSTALL: http
links:
- rabbitmq
uchiwa:
image: sstarcher/uchiwa
links:
- api:sensu
ports:
- '80:3000'
rabbitmq:
image: rabbitmq:3.5-management
redis:
image: redis
I can confirm that my check makes it into the server's /etc/sensu/check.d
directory and is picked up:
server_1 | {"timestamp":"2016-05-25T13:51:05.507991+0000","level":"warn","message":"config file applied changes","file":"/etc/sensu/check.d/check-sensu-website.json","changes":{"checks":{"sensu-website":[null,{"command":"check-http.rb -u https://sensuapp.org","subscribers":["test"],"interval":10}]}}}
But it's invisible to the API:
root@d3177012135b:/# curl -s http://api:4567/clients
[{"socket":{"bind":"127.0.0.0","port":3030},"name":"qa-poker","address":"127.0.0.1","subscriptions":["test"],"keepalive":{"handler":"default"},"version":"0.23.2","timestamp":1464184889}]
root@d3177012135b:/# curl -s http://api:4567/checks
[]root@d3177012135b:/#
docker-compose logs client
output:
client_1 | Downloading sensu-plugins/http:master
client_1 | Building sensu-plugins/http:master
client_1 | Installing sensu-plugins/http:master
client_1 | Finished sensu-plugins/http:master
However, when I: docker exec -it xxx_client_1 bash
and ls /etc/sensu/plugins
, there's nothing there.
I don't know if is something related to the container or with my setup, but I can get any handler to work! I've tried the event-file.rb
example in sensu docs, but with no success. Could someone help me?
Hi,
Thanks for creating this docker-sensu container. I ran docker-compose up and I got the attached error for client_1.
Adding the snippet at which the failure occurs.
client_1 | update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
client_1 | Setting up build-essential (12.1ubuntu2) ...
client_1 | Processing triggers for libc-bin (2.24-9ubuntu2) ...
client_1 | Processing triggers for sgml-base (1.29) ...
client_1 | Downloading sstarcher/aws:master
client_1 | Downloading sensu-plugins/mail:master
client_1 |
client_1 | gzip: stdin: not in gzip format
client_1 | tar: Child returned status 1
client_1 | tar: Error is not recoverable: exiting now
client_1 | /bin/install: line 47: cd: sensu-plugins-mail-master: No such file or directory
client_1 | Building sensu-plugins/mail:master
Is there something I am missing here?
If one mount the check.d as follows
/etc/sensu/check.d:/etc/sensu/check.d
then the local check.d is cleaned after docker-compose up
https://github.com/sstarcher/docker-sensu/blob/alpine/templates/rabbitmq.json.tmpl#L5
"host": {{ default "rabbitmq" .RABBITMQ_HOST | quote }}",
vs
"host": {{ default "rabbitmq" .RABBITMQ_HOST | quote }},
the bin/install script assumes the git download url ends with "master.tar.gz" when in fact it's "archive/[version].tar.gz"
Sensu_sensu-srv_1 | 5-10-28T05:24:39.854859970Z --2015-10-28 05:23:48-- https://github.com/sensu-plugins/sensu-plugins-sensu-plugins-disk-checks/archive/master.tar.gz
Sensu_sensu-srv_1 | 5-10-28T05:24:39.854859970Z Resolving github.com (github.com)... 192.30.252.131
Sensu_sensu-srv_1 | 5-10-28T05:24:39.854859970Z Connecting to github.com (github.com)|192.30.252.131|:443... connected.
Sensu_sensu-srv_1 | 5-10-28T05:24:39.854859970Z HTTP request sent, awaiting response... 404 Not Found
Sensu_sensu-srv_1 | 2015-10-28T05:24:39.854859970Z 2015-10-28 05:23:48 ERROR 404: Not Found.
example:
https://github.com/sensu-plugins/sensu-plugins-network-checks/archive/0.0.5.tar.gz
Hi,
It's good if we can add multiples datacenters for uchiwa configuration :)
The 1.0.0 release of this repo is now end of life -> https://wiki.ubuntu.com/Releases
Thoughts on cutting a new 2.0.0 release based on master?
This will let users lock to a version instead of commit hash or 'latest'.
Is the docker sensu-client designed to perform checks in the machine where the container is running?
For example process checks are returning just results relative to processes running within the container.
How can we manage that?
Hi, i hava an error installing sensu-plugins-docker with end RUNTIME_INSTALL, my docker-compose is
environment:
RUNTIME_INSTALL: sensu-plugins/sensu-plugins-docker
Error is:
Downloading sensu-plugins/sensu-plugins-docker:master
tar: invalid magic
tar: short read
Building sensu-plugins/sensu-plugins-docker:master
/bin/install: line 32: cd: sensu-plugins-sensu-plugins-docker-master: No such file or directory
Hey there!
Is it possible to implement SSL support (configuration through templates and environment variables) for rabbitmq and sensu?
It seems like the needed changes got merged in but there wasn't a specific tag and so there isn't an automated build with the tag over on docker hub. Thanks and love the project.
Is there something that is causing the latest image to rebuild 14 so many times in the last day?
Sorry for another issue!
I've noticed that the containers aren't writing logs to /var/log/sensu
, so the only way I can get some more info is to change the LOG_LEVEL
and follow stdout.
Should this work or could this be added as an env var?
Cheers.
Seems like the last build introduced an error. I'm using the docker-compose example listed on README, with sstarcher/uchiwa
and I'm getting the following error
server_1 | {"timestamp":"2016-02-13T17:04:36.125812+0000","level":"error","message":"[amqp] Detected TCP connection failurserver_1 | {"timestamp":"2016-02-13T17:04:36.125812+0000","level":"error","message":"[amqp] Detected TCP connection failure"}
client_1 | {"timestamp":"2016-02-13T17:04:46.030183+0000","level":"error","message":"[amqp] Detected TCP connection failure"}
api_1 | {"timestamp":"2016-02-13T17:04:48.623956+0000","level":"error","message":"[amqp] Detected TCP connection failure"}e"}
client_1 | {"timestamp":"2016-02-13T17:04:46.030183+0000","level":"error","message":"[amqp] Detected TCP connection failure"}
api_1 | {"timestamp":"2016-02-13T17:04:48.623956+0000","level":"error","message":"[amqp] Detected TCP connection failure"}
Investigating the container I got this config on /etc/sensu/conf.d/rabbitmq.json
in api, server and client,
{
"rabbitmq": {
"port": tcp://172.17.0.3:4369,
"host": "rabbitmq",
"user": "guest",
"password": "guest",
"vhost": "/",
"prefetch": 1
}
}
I could go inside the container and change this mannualy to 5672
and the error will stop, but I don't think this is the expected behavior
Attempting to add a RUNTIME_INSTALL to the server environment variables in docker-compose.yaml causes the server container to crash
environment:
RUNTIME_INSTALL: sensu-plugins/disk-checks:master
It is possible that I'm not calling the RUNTIME_INSTALL properly?
Perhaps an example of proper execution might help.
Hey again,
The image doesn't container build-essentials
so I can't compile ruby gems (Eg. sensu-install -p mailer
). How are you currently handling this?
I threw up a container that is based on your image and has build-essentials
installed, then used this to generate the sensu files (handlers, plugins, etc.) & gems, but it's a bind to copy these over to the different folders on my sensu_server
container.
I guess I could just build on top of your image and add build-essentials
๐คทโโ๏ธ
Regards,
James.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.