Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adibendahan committed Apr 19, 2016
0 parents commit 74f688f
Show file tree
Hide file tree
Showing 25 changed files with 1,354 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
@@ -0,0 +1,6 @@
CHANGELOG.md merge=union
CHANGELOG.asciidoc merge=union

# Keep these file types as CRLF (Windows).
*.bat text eol=crlf
*.cmd text eol=crlf
8 changes: 8 additions & 0 deletions .gitignore
@@ -0,0 +1,8 @@
/.idea
/vendor
/build

.DS_Store
/mysqlbeat
/mysqlbeat.test
*.pyc
43 changes: 43 additions & 0 deletions .travis.yml
@@ -0,0 +1,43 @@
sudo: required
dist: trusty
services:
- docker

language: go

go:
- 1.5.3

os:
- linux
- osx

env:
matrix:
- TARGETS="check"
- TARGETS="-C mysqlbeat testsuite"

global:
# Cross-compile for amd64 only to speed up testing.
- GOX_FLAGS="-arch amd64"

addons:
apt:
packages:
- python-virtualenv

before_install:
# Redo the travis setup but with the elastic/libbeat path. This is needed so the package path is correct
- mkdir -p $HOME/gopath/src/github.com/elastic/beats/
- rsync -az ${TRAVIS_BUILD_DIR}/ $HOME/gopath/src/github.com/elastic/beats/
- export TRAVIS_BUILD_DIR=$HOME/gopath/src/github.com/elastic/beats/
- cd $HOME/gopath/src/github.com/elastic/beats/

install:
- true

script:
- make $TARGETS

after_success:
# Copy full.cov to coverage.txt because codecov.io requires this file
Empty file added CONTRIBUTING.md
Empty file.
13 changes: 13 additions & 0 deletions LICENSE
@@ -0,0 +1,13 @@
Copyright (c) 2016 Adi Ben-Dahan

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
38 changes: 38 additions & 0 deletions Makefile
@@ -0,0 +1,38 @@
BEATNAME=mysqlbeat
BEAT_DIR=github.com/adibendahan
SYSTEM_TESTS=false
TEST_ENVIRONMENT=false
ES_BEATS=./vendor/github.com/elastic/beats
GOPACKAGES=$(shell glide novendor)
PREFIX?=.

# Path to the libbeat Makefile
-include $(ES_BEATS)/libbeat/scripts/Makefile

.PHONY: init
init:
glide update --no-recursive
make update
git init

.PHONY: commit
commit:
git add README.md CONTRIBUTING.md
git commit -m "Initial commit"
git add LICENSE
git commit -m "Add the LICENSE"
git add .gitignore .gitattributes
git commit -m "Add git settings"
git add .
git reset -- .travis.yml
git commit -m "Add mysqlbeat"
git add .travis.yml
git commit -m "Add Travis CI"

.PHONY: update-deps
update-deps:
glide update --no-recursive

# This is called by the beats packer before building starts
.PHONY: before-build
before-build:
48 changes: 48 additions & 0 deletions README.md
@@ -0,0 +1,48 @@
# mysqlbeat
Fully customizable Beat for MySQL server.
This beat ships the results of any query defined on the config file to elastic.


## Current status
This project is in an alpha stage, In fact this is the first time ever I wrote go code.
Please excuse any rookie mistakes I might have done, fixes are welcome.

## Features

* Connect to any MySQL server and run queries
* 'single-row' queries will be translated as columnname:value.
* 'two-columns' will be translated as value-column1:value-column2 for each row.
* 'multiple-rows' each row will be a document (with columnname:value) - NO DELTA SUPPORT.

* Any column that ends with the delatwildcard (default is __DELTA) will delta results, extremely useful for server counters.
((neval - oldval)/timediff.Seconds())

## How to Build

```shell
$ go build
```

## Configuration

You must edit mysqlbeat configuration in ```mysqlbeat.yml``` .

* Add queries to the `queries` array
* Add query types to the `querytypes` array
* Define user/pass to connect to the MySQL - MAKE SURE THE USER ONLY HAS PERMISSIONS TO RUN THE QUERY DESIRED AND NOTHING ELSE.
* Password64 should be saved as a base64 []byte array, to generate the array you can use the following: https://play.golang.org/p/L8Z0lFnzCy (make sure to add a comma between all array numbers)
* Define the column wild card for delta columns


## Template
Since the template depends on the queries you will decide to run, I can't provide a template.
I recommend completing the configuration and run the mysqlbeat just enough time to create the index, then get the _mapping and adjust it.
Delete the index and send the new mapping with:
curl -XPUT http://<host>:9200/_template/mysqlbeat -d@etc/mysqlbeat-template.json

## How to use

Just run ```mysqlbeat -c mysqlbeat.yml``` and you are good to go.

## License
GNU General Public License v2

0 comments on commit 74f688f

Please sign in to comment.