From b473229237ad258ea355b775a5461d0d03e658f1 Mon Sep 17 00:00:00 2001 From: John Susek Date: Tue, 11 Sep 2018 14:56:34 -0500 Subject: [PATCH 01/21] Add json format for test results. --- src/controllers/test/index.js | 4 ++++ src/handlers/test/post.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/controllers/test/index.js b/src/controllers/test/index.js index 9e6c6f3d..3587e9f1 100644 --- a/src/controllers/test/index.js +++ b/src/controllers/test/index.js @@ -33,6 +33,10 @@ export default class TestController { processOptions.push('-m', 'elastalert.test_rule', '--config', 'config.yaml', tempFilePath, '--days', options.days); + if (options.format === 'json') { + processOptions.push('--formatted-output'); + } + if (options.alert) { processOptions.push('--alert'); } diff --git a/src/handlers/test/post.js b/src/handlers/test/post.js index 1d8bf74a..ed3e61f6 100644 --- a/src/handlers/test/post.js +++ b/src/handlers/test/post.js @@ -8,7 +8,8 @@ let logger = new RouteLogger('/test', 'POST'); const optionsSchema = Joi.object().keys({ testType: Joi.string().valid('all', 'schemaOnly', 'countOnly').default('all'), days: Joi.number().min(1).default(1), - alert: Joi.boolean().default(false) + alert: Joi.boolean().default(false), + format: Joi.string().default('') }).default(); function analyzeRequest(request) { From ddfd8a5aca9ec7e23c898a5d7494193bedf11073 Mon Sep 17 00:00:00 2001 From: John Susek Date: Wed, 12 Sep 2018 08:56:58 -0500 Subject: [PATCH 02/21] Add maxResults option to control number of results returned from elastalert. --- src/controllers/test/index.js | 5 +++++ src/handlers/test/post.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/controllers/test/index.js b/src/controllers/test/index.js index 3587e9f1..a791885b 100644 --- a/src/controllers/test/index.js +++ b/src/controllers/test/index.js @@ -37,6 +37,11 @@ export default class TestController { processOptions.push('--formatted-output'); } + if (options.maxResults > 0) { + processOptions.push('--max-query-size'); + processOptions.push(options.maxResults); + } + if (options.alert) { processOptions.push('--alert'); } diff --git a/src/handlers/test/post.js b/src/handlers/test/post.js index ed3e61f6..1ac35115 100644 --- a/src/handlers/test/post.js +++ b/src/handlers/test/post.js @@ -9,7 +9,8 @@ const optionsSchema = Joi.object().keys({ testType: Joi.string().valid('all', 'schemaOnly', 'countOnly').default('all'), days: Joi.number().min(1).default(1), alert: Joi.boolean().default(false), - format: Joi.string().default('') + format: Joi.string().default(''), + maxResults: Joi.number().default(0) }).default(); function analyzeRequest(request) { From 0d4c6acbbe25024b4d76aac5b34ecac788c5422f Mon Sep 17 00:00:00 2001 From: John Susek Date: Wed, 12 Sep 2018 09:01:29 -0500 Subject: [PATCH 03/21] Update docs --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f9ce037f..a37b6a48 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,13 @@ This server exposes the following REST API's: "days": "1" // Whether to send real alerts - "alert": false + "alert": false, + + // Return results in structured JSON + "format": "json", + + // Limit returned results to this amount + "maxResults": 1000 } } ``` From aaaaa42a00d1cf96cee9d4eb78a553730bae34d2 Mon Sep 17 00:00:00 2001 From: John Susek Date: Wed, 12 Sep 2018 10:46:22 -0500 Subject: [PATCH 04/21] Don't newline join when format is JSON. --- src/controllers/test/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/controllers/test/index.js b/src/controllers/test/index.js index a791885b..63740b0d 100644 --- a/src/controllers/test/index.js +++ b/src/controllers/test/index.js @@ -70,7 +70,12 @@ export default class TestController { testProcess.on('exit', function (statusCode) { if (statusCode === 0) { - resolve(stdoutLines.join('\n')); + if (options.format === 'json') { + resolve(stdoutLines.join()); + } + else { + resolve(stdoutLines.join('\n')); + } } else { reject(stderrLines.join('\n')); logger.error(stderrLines.join('\n')); From ceb0053e640a621e54e7948816049856ff538b3d Mon Sep 17 00:00:00 2001 From: John Susek Date: Fri, 14 Sep 2018 09:04:28 -0500 Subject: [PATCH 05/21] Fix issue with large resultsets --- src/controllers/test/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/test/index.js b/src/controllers/test/index.js index 63740b0d..053bb487 100644 --- a/src/controllers/test/index.js +++ b/src/controllers/test/index.js @@ -71,7 +71,7 @@ export default class TestController { testProcess.on('exit', function (statusCode) { if (statusCode === 0) { if (options.format === 'json') { - resolve(stdoutLines.join()); + resolve(stdoutLines.join('')); } else { resolve(stdoutLines.join('\n')); From d2f29b9f7caa793d08f710fe0e121b7dfd5e4bd8 Mon Sep 17 00:00:00 2001 From: John Susek Date: Fri, 14 Sep 2018 14:39:18 -0500 Subject: [PATCH 06/21] Add support for CORS --- package.json | 1 + src/elastalert_server.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/package.json b/package.json index 965973ac..e9aa5d25 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "babel-register": "^6.14.0", "body-parser": "^1.15.2", "bunyan": "^1.8.1", + "cors": "^2.8.4", "express": "^4.14.0", "fs-extra": "^5.0.0", "joi": "^13.1.2", diff --git a/src/elastalert_server.js b/src/elastalert_server.js index d3747b45..8db07e9d 100644 --- a/src/elastalert_server.js +++ b/src/elastalert_server.js @@ -9,6 +9,7 @@ import ProcessController from './controllers/process'; import RulesController from './controllers/rules'; import TemplatesController from './controllers/templates'; import TestController from './controllers/test'; +import cors from 'cors'; let logger = new Logger('Server'); @@ -58,6 +59,7 @@ export default class ElastalertServer { // Start the server when the config is loaded config.ready(function () { try { + self._express.use(cors()); self._express.use(bodyParser.json()); self._express.use(bodyParser.urlencoded({ extended: true })); self._setupRouter(); From 281ebbc51be1aca51cee9be61b8909e30c502f91 Mon Sep 17 00:00:00 2001 From: John Susek Date: Tue, 11 Sep 2018 19:45:49 -0500 Subject: [PATCH 07/21] Fix issue with creating a template. --- src/handlers/templates/id/post.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handlers/templates/id/post.js b/src/handlers/templates/id/post.js index 6412d27d..e4459bb5 100644 --- a/src/handlers/templates/id/post.js +++ b/src/handlers/templates/id/post.js @@ -26,8 +26,8 @@ export default function templatePostHandler(request, response) { }); }) .catch(function (error) { - if (error.error === 'ruleNotFound') { - server.templatesController.createRule(request.params.id, body) + if (error.error === 'templateNotFound') { + server.templatesController.createTemplate(request.params.id, body) .then(function () { logger.sendSuccessful(); response.send({ From 11f25c41e44b3c3784d641b5260c07229227e8b6 Mon Sep 17 00:00:00 2001 From: John Susek Date: Sat, 15 Sep 2018 10:44:41 -0500 Subject: [PATCH 08/21] Add new endpoint /metadata to return elastalert's metadata from the writeback index --- README.md | 4 ++++ package.json | 1 + src/common/elasticsearch_client.js | 22 +++++++++++++++++++++ src/handlers/metadata/get.js | 31 ++++++++++++++++++++++++++++++ src/routes/routes.js | 6 ++++++ 5 files changed, 64 insertions(+) create mode 100644 src/common/elasticsearch_client.js create mode 100644 src/handlers/metadata/get.js diff --git a/README.md b/README.md index a37b6a48..b397c92c 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,10 @@ This server exposes the following REST API's: } ``` +- **GET `/metadata/:type`** + + Returns metadata from elasticsearch related to elasalert's state. `:type` should be one of: elastalert_status, elastalert, elastalert_error, or silence. See [docs about the elastalert metadata index](https://elastalert.readthedocs.io/en/latest/elastalert_status.html). + - **[WIP] GET `/config`** Gets the ElastAlert configuration from `config.yaml` in `elastalertPath` (from the config). diff --git a/package.json b/package.json index e9aa5d25..f02feb67 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "express": "^4.14.0", "fs-extra": "^5.0.0", "joi": "^13.1.2", + "js-yaml": "^3.12.0", "lodash": "^4.15.0", "mkdirp": "^0.5.1", "object-resolve-path": "^1.1.1", diff --git a/src/common/elasticsearch_client.js b/src/common/elasticsearch_client.js new file mode 100644 index 00000000..52deda39 --- /dev/null +++ b/src/common/elasticsearch_client.js @@ -0,0 +1,22 @@ +import yaml from 'js-yaml'; +import fs from 'fs'; +import process from 'process'; +import elasticsearch from 'elasticsearch'; + +export function getConfig() { + try { + var appRoot = process.cwd(); + var config = yaml.safeLoad(fs.readFileSync(appRoot + '/config/elastalert.yaml', 'utf8')); + return config; + } catch (e) { + console.error(e); + } +} + +export function getClient() { + var config = getConfig(); + var client = new elasticsearch.Client({ + hosts: [ `http://${config.es_host}:${config.es_port}`] + }); + return client; +} diff --git a/src/handlers/metadata/get.js b/src/handlers/metadata/get.js new file mode 100644 index 00000000..21b2237f --- /dev/null +++ b/src/handlers/metadata/get.js @@ -0,0 +1,31 @@ +import { getConfig, getClient } from '../../common/elasticsearch_client'; + +var config = getConfig(); +var client = getClient(); + +export default function metadataHandler(request, response) { + /** + * @type {ElastalertServer} + */ + + client.search({ + index: config.writeback_index, + type: request.params.type, + body: { + from : request.query.from || 0, + size : request.query.size || 10, + query: { + match_all: {} + }, + sort: [{ '@timestamp': { order: 'desc' } }] + } + }).then(function(resp) { + resp.hits.hits = resp.hits.hits.map(h => h._source); + response.send(resp.hits); + }, function(err) { + response.send({ + error: err + }); + }); + +} diff --git a/src/routes/routes.js b/src/routes/routes.js index 3a435340..cab646c7 100644 --- a/src/routes/routes.js +++ b/src/routes/routes.js @@ -14,6 +14,7 @@ import templateDeleteHandler from '../handlers/templates/id/delete'; import testPostHandler from '../handlers/test/post'; import configGetHandler from '../handlers/config/get'; import configPostHandler from '../handlers/config/post'; +import metadataHandler from '../handlers/metadata/get'; /** * A server route. @@ -74,6 +75,11 @@ let routes = [ path: 'download', method: ['POST'], handler: [downloadRulesHandler] + }, + { + path: 'metadata/:type', + method: ['GET'], + handler: [metadataHandler] } ]; From 54c72fd9471e6186e91978ae5d489d1c952768a4 Mon Sep 17 00:00:00 2001 From: Martijn Rondeel Date: Tue, 18 Sep 2018 10:48:16 +0200 Subject: [PATCH 09/21] Update elastalert to v0.1.36 (#45) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7e9b8a69..f4b19685 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM alpine:latest as py-ea -ARG ELASTALERT_VERSION=v0.1.33 +ARG ELASTALERT_VERSION=v0.1.36 ENV ELASTALERT_VERSION=${ELASTALERT_VERSION} # URL from which to download Elastalert. ARG ELASTALERT_URL=https://github.com/Yelp/elastalert/archive/$ELASTALERT_VERSION.zip From cc96a095702ca6df8ff4ded289ad833dfa1f8e76 Mon Sep 17 00:00:00 2001 From: Martijn Rondeel Date: Tue, 18 Sep 2018 10:49:05 +0200 Subject: [PATCH 10/21] Fix setting the timezone in alpine container (#33) --- Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index f4b19685..1ece5888 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,10 +26,8 @@ RUN sed -i 's/jira>=1.0.10/jira>=1.0.10,<1.0.15/g' setup.py && \ FROM node:alpine LABEL maintainer="BitSensor " -# Set this environment variable to True to set timezone on container start. -ENV SET_CONTAINER_TIMEZONE False -# Default container timezone as found under the directory /usr/share/zoneinfo/. -ENV CONTAINER_TIMEZONE Etc/UTC +# Set timezone for this container +ENV TZ Etc/UTC RUN apk add --update --no-cache curl tzdata python2 make From 76c34b26544905bdbb7f7b969058cc25d957991d Mon Sep 17 00:00:00 2001 From: Martijn Rondeel Date: Tue, 18 Sep 2018 10:52:48 +0200 Subject: [PATCH 11/21] Update version to 0.0.13 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 965973ac..4149c52f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bitsensor/elastalert", - "version": "0.0.12", + "version": "0.0.13", "description": "A server that runs ElastAlert and exposes REST API's for manipulating rules and alerts.", "license": "MIT", "main": "index.js", @@ -11,7 +11,7 @@ }, "repository": { "type": "git", - "url": "git+https://git.bitsensor.io/back-end/elastalert.git" + "url": "git+https://github.com/bitsensor/elastalert.git" }, "directories": { "lib": "./lib", From 5e626368fc9c7e4bfa49e3b20f2fcc2acff2ab50 Mon Sep 17 00:00:00 2001 From: John Susek Date: Thu, 20 Sep 2018 09:37:12 -0500 Subject: [PATCH 12/21] Add endpoint to get field mapping for given index. --- README.md | 4 ++++ src/handlers/mapping/get.js | 20 ++++++++++++++++++++ src/handlers/metadata/get.js | 16 +++++++++++++--- src/routes/routes.js | 6 ++++++ 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 src/handlers/mapping/get.js diff --git a/README.md b/README.md index b397c92c..77c6b1cd 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,10 @@ This server exposes the following REST API's: Returns metadata from elasticsearch related to elasalert's state. `:type` should be one of: elastalert_status, elastalert, elastalert_error, or silence. See [docs about the elastalert metadata index](https://elastalert.readthedocs.io/en/latest/elastalert_status.html). +- **GET `/mapping/:index`** + + Returns field mapping from elasticsearch for a given index. + - **[WIP] GET `/config`** Gets the ElastAlert configuration from `config.yaml` in `elastalertPath` (from the config). diff --git a/src/handlers/mapping/get.js b/src/handlers/mapping/get.js new file mode 100644 index 00000000..98c234d3 --- /dev/null +++ b/src/handlers/mapping/get.js @@ -0,0 +1,20 @@ +import { getClient } from '../../common/elasticsearch_client'; + +var client = getClient(); + +export default function metadataHandler(request, response) { + /** + * @type {ElastalertServer} + */ + + client.indices.getMapping({ + index: request.params.index + }).then(function(resp) { + response.send(resp); + }, function(err) { + response.send({ + error: err + }); + }); + +} diff --git a/src/handlers/metadata/get.js b/src/handlers/metadata/get.js index 21b2237f..e497d24b 100644 --- a/src/handlers/metadata/get.js +++ b/src/handlers/metadata/get.js @@ -3,19 +3,29 @@ import { getConfig, getClient } from '../../common/elasticsearch_client'; var config = getConfig(); var client = getClient(); +function getQueryString(request) { + if (request.params.type === 'elastalert_error') { + return '*:*'; + } + else { + return `rule_name:${request.query.rule_name || '*'}`; + } +} + export default function metadataHandler(request, response) { /** * @type {ElastalertServer} */ - client.search({ index: config.writeback_index, type: request.params.type, body: { from : request.query.from || 0, - size : request.query.size || 10, + size : request.query.size || 100, query: { - match_all: {} + query_string: { + query: getQueryString(request) + } }, sort: [{ '@timestamp': { order: 'desc' } }] } diff --git a/src/routes/routes.js b/src/routes/routes.js index cab646c7..5161560a 100644 --- a/src/routes/routes.js +++ b/src/routes/routes.js @@ -15,6 +15,7 @@ import testPostHandler from '../handlers/test/post'; import configGetHandler from '../handlers/config/get'; import configPostHandler from '../handlers/config/post'; import metadataHandler from '../handlers/metadata/get'; +import mappingHandler from '../handlers/mapping/get'; /** * A server route. @@ -80,6 +81,11 @@ let routes = [ path: 'metadata/:type', method: ['GET'], handler: [metadataHandler] + }, + { + path: 'mapping/:index', + method: ['GET'], + handler: [mappingHandler] } ]; From f115f5e3226b12c8f3213980f09e7e957ca0906a Mon Sep 17 00:00:00 2001 From: John Susek Date: Fri, 21 Sep 2018 15:35:45 -0500 Subject: [PATCH 13/21] Add ES to package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index f02feb67..94242ba8 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "body-parser": "^1.15.2", "bunyan": "^1.8.1", "cors": "^2.8.4", + "elasticsearch": "^15.1.1", "express": "^4.14.0", "fs-extra": "^5.0.0", "joi": "^13.1.2", From 379f23e3f2da2df59fa302d333a8e41c1015a99c Mon Sep 17 00:00:00 2001 From: John Susek Date: Fri, 21 Sep 2018 16:50:00 -0500 Subject: [PATCH 14/21] Use config.json for options related to getting metadata/mappings. --- config/config.json | 7 +++++-- package.json | 1 - src/common/config/schema.js | 3 +++ src/common/elasticsearch_client.js | 17 ++--------------- src/handlers/mapping/get.js | 4 ++-- src/handlers/metadata/get.js | 9 +++++---- 6 files changed, 17 insertions(+), 24 deletions(-) diff --git a/config/config.json b/config/config.json index 51a8c3da..65dfe601 100644 --- a/config/config.json +++ b/config/config.json @@ -12,5 +12,8 @@ "templatesPath": { "relative": true, "path": "/rule_templates" - } -} \ No newline at end of file + }, + "es_host": "elastalert", + "es_port": 9200, + "writeback_index": "elastalert_status" +} diff --git a/package.json b/package.json index 94242ba8..38958cdd 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ "express": "^4.14.0", "fs-extra": "^5.0.0", "joi": "^13.1.2", - "js-yaml": "^3.12.0", "lodash": "^4.15.0", "mkdirp": "^0.5.1", "object-resolve-path": "^1.1.1", diff --git a/src/common/config/schema.js b/src/common/config/schema.js index 9734ec46..fe757a4d 100644 --- a/src/common/config/schema.js +++ b/src/common/config/schema.js @@ -3,6 +3,9 @@ import Joi from 'joi'; const schema = Joi.object().keys({ 'appName': Joi.string().default('elastalert-server'), + 'es_host': Joi.string().default('elastalert'), + 'es_port': Joi.number().default(9200), + 'writeback_index': Joi.string().default('elastalert_status'), 'port': Joi.number().default(3030), 'elastalertPath': Joi.string().default('/opt/elastalert'), 'rulesPath': Joi.object().keys({ diff --git a/src/common/elasticsearch_client.js b/src/common/elasticsearch_client.js index 52deda39..7b7449e8 100644 --- a/src/common/elasticsearch_client.js +++ b/src/common/elasticsearch_client.js @@ -1,22 +1,9 @@ -import yaml from 'js-yaml'; -import fs from 'fs'; -import process from 'process'; import elasticsearch from 'elasticsearch'; - -export function getConfig() { - try { - var appRoot = process.cwd(); - var config = yaml.safeLoad(fs.readFileSync(appRoot + '/config/elastalert.yaml', 'utf8')); - return config; - } catch (e) { - console.error(e); - } -} +import config from './config'; export function getClient() { - var config = getConfig(); var client = new elasticsearch.Client({ - hosts: [ `http://${config.es_host}:${config.es_port}`] + hosts: [ `http://${config.get('es_host')}:${config.get('es_port')}`] }); return client; } diff --git a/src/handlers/mapping/get.js b/src/handlers/mapping/get.js index 98c234d3..7f7f741f 100644 --- a/src/handlers/mapping/get.js +++ b/src/handlers/mapping/get.js @@ -1,12 +1,12 @@ import { getClient } from '../../common/elasticsearch_client'; -var client = getClient(); - export default function metadataHandler(request, response) { /** * @type {ElastalertServer} */ + var client = getClient(); + client.indices.getMapping({ index: request.params.index }).then(function(resp) { diff --git a/src/handlers/metadata/get.js b/src/handlers/metadata/get.js index e497d24b..36bd8eb3 100644 --- a/src/handlers/metadata/get.js +++ b/src/handlers/metadata/get.js @@ -1,7 +1,6 @@ -import { getConfig, getClient } from '../../common/elasticsearch_client'; +import config from '../../common/config'; +import { getClient } from '../../common/elasticsearch_client'; -var config = getConfig(); -var client = getClient(); function getQueryString(request) { if (request.params.type === 'elastalert_error') { @@ -16,8 +15,10 @@ export default function metadataHandler(request, response) { /** * @type {ElastalertServer} */ + var client = getClient(); + client.search({ - index: config.writeback_index, + index: config.get('writeback_index'), type: request.params.type, body: { from : request.query.from || 0, From 8e5011b058600a1fb11d71b7fc4149db2abcd166 Mon Sep 17 00:00:00 2001 From: John Susek Date: Fri, 21 Sep 2018 17:13:39 -0500 Subject: [PATCH 15/21] Update README --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 77c6b1cd..38f32e80 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,10 @@ You can use the following config options: "dataPath": { // The path to a folder that the server can use to store data and temporary files. "relative": true, // Whether to use a path relative to the `elastalertPath` folder. "path": "/server_data" // The path to the data folder. - } + }, + "es_host": "elastalert", // For getting metadata and field mappings, connect to this ES server + "es_port": 9200, // Port for above + "writeback_index": "elastalert_status" // Writeback index to examine for /metadata endpoint } ``` From a377e8c60ea6cac3153d73ec3d80a907290026ea Mon Sep 17 00:00:00 2001 From: Martijn Rondeel Date: Tue, 18 Sep 2018 10:48:16 +0200 Subject: [PATCH 16/21] Update elastalert to v0.1.36 (#45) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7e9b8a69..f4b19685 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM alpine:latest as py-ea -ARG ELASTALERT_VERSION=v0.1.33 +ARG ELASTALERT_VERSION=v0.1.36 ENV ELASTALERT_VERSION=${ELASTALERT_VERSION} # URL from which to download Elastalert. ARG ELASTALERT_URL=https://github.com/Yelp/elastalert/archive/$ELASTALERT_VERSION.zip From a1f3df6e9fa98db3d32d5dace88177fdf846c04b Mon Sep 17 00:00:00 2001 From: Martijn Rondeel Date: Tue, 18 Sep 2018 10:49:05 +0200 Subject: [PATCH 17/21] Fix setting the timezone in alpine container (#33) --- Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index f4b19685..1ece5888 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,10 +26,8 @@ RUN sed -i 's/jira>=1.0.10/jira>=1.0.10,<1.0.15/g' setup.py && \ FROM node:alpine LABEL maintainer="BitSensor " -# Set this environment variable to True to set timezone on container start. -ENV SET_CONTAINER_TIMEZONE False -# Default container timezone as found under the directory /usr/share/zoneinfo/. -ENV CONTAINER_TIMEZONE Etc/UTC +# Set timezone for this container +ENV TZ Etc/UTC RUN apk add --update --no-cache curl tzdata python2 make From d9803d82ab51984ae5bc2d90a96330f43e0bb475 Mon Sep 17 00:00:00 2001 From: Martijn Rondeel Date: Tue, 18 Sep 2018 10:52:48 +0200 Subject: [PATCH 18/21] Update version to 0.0.13 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 38958cdd..5f7cb001 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bitsensor/elastalert", - "version": "0.0.12", + "version": "0.0.13", "description": "A server that runs ElastAlert and exposes REST API's for manipulating rules and alerts.", "license": "MIT", "main": "index.js", @@ -11,7 +11,7 @@ }, "repository": { "type": "git", - "url": "git+https://git.bitsensor.io/back-end/elastalert.git" + "url": "git+https://github.com/bitsensor/elastalert.git" }, "directories": { "lib": "./lib", From d16e5d5cadde9e8e17a52151ac544dd9730ab763 Mon Sep 17 00:00:00 2001 From: Martijn Rondeel Date: Mon, 24 Sep 2018 10:47:53 +0200 Subject: [PATCH 19/21] Fix libmagic dependency being absent in alpine container --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1ece5888..c83321d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ LABEL maintainer="BitSensor " # Set timezone for this container ENV TZ Etc/UTC -RUN apk add --update --no-cache curl tzdata python2 make +RUN apk add --update --no-cache curl tzdata python2 make libmagic COPY --from=py-ea /usr/lib/python2.7/site-packages /usr/lib/python2.7/site-packages COPY --from=py-ea /opt/elastalert /opt/elastalert From c277360872d469181bbcc5dd94c855a15c7155b7 Mon Sep 17 00:00:00 2001 From: Martijn Rondeel Date: Mon, 24 Sep 2018 11:05:42 +0200 Subject: [PATCH 20/21] Fix CI pointing to old artifacts.bitsensor.io container hub --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c1e5760c..a1203438 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -60,7 +60,7 @@ deploy:docker: script: - sh scripts/replace_templates.sh ${CI_JOB_TOKEN} - docker info - - echo $BITSENSOR_PASSWORD | docker login -u $BITSENSOR_USERNAME --password-stdin artifacts.bitsensor.io:1443 + - echo $BITSENSOR_PASSWORD | docker login -u $BITSENSOR_USERNAME --password-stdin docker.bitsensor.io - docker build -t elastalert . - docker tag elastalert artifacts.bitsensor.io:1443/elastalert:latest - docker tag elastalert artifacts.bitsensor.io:1443/elastalert:$(git describe --abbrev=0) @@ -76,7 +76,7 @@ deploy:docker:snapshot: script: - sh scripts/replace_templates.sh ${CI_JOB_TOKEN} - docker info - - echo $BITSENSOR_PASSWORD | docker login -u $BITSENSOR_USERNAME --password-stdin artifacts.bitsensor.io:1443 + - echo $BITSENSOR_PASSWORD | docker login -u $BITSENSOR_USERNAME --password-stdin docker.bitsensor.io - docker build -t elastalert . - docker tag elastalert artifacts.bitsensor.io:1443/elastalert:snapshot - docker push artifacts.bitsensor.io:1443/elastalert:snapshot From a4b96e5e39a8b9510b5e373140e249ada39817e6 Mon Sep 17 00:00:00 2001 From: Martijn Rondeel Date: Mon, 24 Sep 2018 11:11:43 +0200 Subject: [PATCH 21/21] Deploy snapshots on docker.bitsensor.io --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a1203438..0355c46b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -62,10 +62,10 @@ deploy:docker: - docker info - echo $BITSENSOR_PASSWORD | docker login -u $BITSENSOR_USERNAME --password-stdin docker.bitsensor.io - docker build -t elastalert . - - docker tag elastalert artifacts.bitsensor.io:1443/elastalert:latest - - docker tag elastalert artifacts.bitsensor.io:1443/elastalert:$(git describe --abbrev=0) - - docker push artifacts.bitsensor.io:1443/elastalert:latest - - docker push artifacts.bitsensor.io:1443/elastalert:$(git describe --abbrev=0) + - docker tag elastalert docker.bitsensor.io/elastalert:latest + - docker tag elastalert docker.bitsensor.io/elastalert:$(git describe --abbrev=0) + - docker push docker.bitsensor.io/elastalert:latest + - docker push docker.bitsensor.io/elastalert:$(git describe --abbrev=0) only: - tags tags: @@ -78,8 +78,8 @@ deploy:docker:snapshot: - docker info - echo $BITSENSOR_PASSWORD | docker login -u $BITSENSOR_USERNAME --password-stdin docker.bitsensor.io - docker build -t elastalert . - - docker tag elastalert artifacts.bitsensor.io:1443/elastalert:snapshot - - docker push artifacts.bitsensor.io:1443/elastalert:snapshot + - docker tag elastalert docker.bitsensor.io/elastalert:snapshot + - docker push docker.bitsensor.io/elastalert:snapshot only: - develop tags: