Skip to content

Instantly share code, notes, and snippets.

View megastef's full-sized avatar
🏠
Working from home

Megastef megastef

🏠
Working from home
  • Twitter: @seti321
  • Germany
View GitHub Profile
@megastef
megastef / sematext-agent-docker.nomad
Last active May 21, 2017 14:28
Monitoring and Logging for all Docker containers on Nomad by HashiCorp
# Run Job Definition: nomad run sematext-agent-docker.nomad
# https://www.hashicorp.com/blog/nomad.html
# More Info: https://hub.docker.com/r/sematext/sematext-agent-docker/
# http://blog.sematext.com/2015/12/15/docker-logging-partner-sematext-logsene/
job "sematext-agent-docker" {
# set your region here
region = "global"
# Mandatory, parameter pls. change!
datacenters = ["us-west-1"]
# run this job globally
@megastef
megastef / patterns.yml
Last active May 9, 2017 11:29
a multiline pattern for SDA / logagent
patterns:
- # your app name
blockStart: !!js/regexp ^\d{4}-\d{2}-\d{2}_\d{2}:\d{2}:\d{2}
sourceName: !!js/regexp /YOUR_IMAGE_NAME_HERE/i
match:
- type: YOUR_IMAGE_OR_APP_NAME
regex: !!js/regexp /^(\d{4}-\d{2}-\d{2}_\d{2}:\d{2}:\d{2})\s+(\S+)\s+\[(.+?)\]\s{0,4}\[(.+?)\]\s-\s([\S|\s]+)/
dateFormat: YYYY-MM-DD_HH:mm:ss
fields:
- ts
@megastef
megastef / patterns.yml
Created May 5, 2017 09:45
Example process JSON from journald before shipping with Sematext Docker Agent or Logagent
json:
enabled: true
removeFields:
- __CURSOR
- __MONOTONIC_TIMESTAMP
- _TRANSPORT
- JOURNAL_NAME
- JOURNAL_PATH
- CURRENT_USE
- CURRENT_USE_PRETTY
{
"/": {
"name": "/",
"subcontainers": [
{
"name": "/docker"
},
{
"name": "/init.scope"
},
@megastef
megastef / create-docker-swarm-w-unix-socket.sh
Created January 11, 2016 17:12
Create a Docker Swarm with docker-machine and enable dockerd Unix Sockets
export SWARM_TOKEN=$(docker run swarm create)
docker-machine create \
-d virtualbox \
--engine-env 'DOCKER_OPTS="-H unix:///var/run/docker.sock"' \
--swarm \
--swarm-master \
--swarm-discovery token://$SWARM_TOKEN \
swarm-master
for NODE in {1..3};
@megastef
megastef / log4j-pattern.yaml
Last active March 21, 2017 12:33
log4j logagent pattern
originalLine: false
patterns:
- # log4j logs, please replace sourceName with a pattern for your image or container name
sourceName: !!js/regexp /.*/i
blockStart: !!js/regexp /^\d+\/\d+\/\d+\s/
match:
- regex: !!js/regexp /(\d+\/\d+\/\d+\s\d+\:\d+\:\d+)\s\S+\s\S+\s\[(\S+)\]\s(\S+)\s+(\S+)\s+-\s+([\S\|\s]+)/i
type: yourAppNameLog4j
fields:
@megastef
megastef / export.json
Created February 15, 2017 14:53
Kibana Docker / GeoIP
[
{
"_id": "default",
"_type": "dashboard",
"_source": {
"title": "default",
"hits": 0,
"description": "",
"panelsJSON": "[{\"col\":1,\"id\":\"Map\",\"panelIndex\":1,\"row\":1,\"size_x\":5,\"size_y\":5,\"type\":\"visualization\"},{\"col\":1,\"columns\":[\"host\",\"severity\",\"message\",\"compose_project\",\"compose_container_number\",\"compose_service\",\"docker_host\",\"image_name\",\"swarm_id\"],\"id\":\"Logs\",\"panelIndex\":2,\"row\":6,\"size_x\":7,\"size_y\":5,\"sort\":[\"@timestamp\",\"desc\"],\"type\":\"search\"},{\"col\":6,\"id\":\"Containers-per-host-and-image-type\",\"panelIndex\":3,\"row\":1,\"size_x\":4,\"size_y\":5,\"type\":\"visualization\"},{\"col\":10,\"id\":\"Docker-Compose-Image-slash-Service\",\"panelIndex\":4,\"row\":1,\"size_x\":3,\"size_y\":5,\"type\":\"visualization\"},{\"id\":\"Containers-per-host\",\"type\":\"visualization\",\"panelIndex\":5,\"size_x\":3,\"size_y\":5,\"col\":10,\"row\":6}]",
"optionsJSON": "{\"darkTheme\":false}",
@megastef
megastef / docker-compose-in-process.yml
Last active January 20, 2017 10:40
tomcat monitoring on docker
# in-process monitor for Tomcat, needs less resources and no network setup
version: '2'
services:
spm-client:
image: sematext/spm-client
container_name: spm-client-tc
hostname: spm-client-tc
environment:
# please set env var SPM_TOKEN before you run docker-compose
@megastef
megastef / docker-compose.yml
Last active January 20, 2017 10:38
Monitor Elasticsearch 2.x with SPM Client on Docker
spm-client:
image: sematext/spm-client
container_name: spm-client
# share the network with the host to reach ES on localhost:9200
net: host
environment:
# SPM Token from http://apps.sematext.com
- SPM_CONFIG=${SPM_TOKEN} es standalone
volumes:
# spm-client > v1.31.65 requires access to docker socket
@megastef
megastef / pattern.yml
Last active December 23, 2016 11:23
lambda-multiline-test
originalLine: true
geoIP: true
maxmindDbDir: /tmp/
json:
enabled: false
patterns:
- # multi line test