Skip to content

Commit 4b6a372

Browse files
Merge branch 'develop' into 'master'
[BREAKING] Use different config file to test rules See merge request bitsensor/back-end/elastalert!34
2 parents f527bb2 + 875c23c commit 4b6a372

File tree

7 files changed

+58
-14
lines changed

7 files changed

+58
-14
lines changed

.gitlab-ci.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,6 @@ test:
4444
- npm install --quiet
4545
- npm test
4646

47-
deploy:npm:
48-
image: node:latest
49-
stage: deploy
50-
script:
51-
- npm install --quiet
52-
- sh scripts/update-authors.sh
53-
- echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'>.npmrc
54-
- npm publish --access public
55-
only:
56-
- tags
57-
5847
deploy:docker:
5948
stage: deploy
6049
script:

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ COPY . /opt/elastalert-server
4040

4141
RUN npm install --production --quiet
4242
COPY config/elastalert.yaml /opt/elastalert/config.yaml
43+
COPY config/elastalert-test.yaml /opt/elastalert/config-test.yaml
4344
COPY config/config.json config/config.json
4445
COPY rule_templates/ /opt/elastalert/rule_templates
4546
COPY elastalert_modules/ /opt/elastalert/elastalert_modules

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
v ?= v0.1.31
1+
v ?= v0.1.38
22

33
all: build
44

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ To run the Docker image you will want to mount the volumes for configuration and
1616
```bash
1717
docker run -d -p 3030:3030 \
1818
-v `pwd`/config/elastalert.yaml:/opt/elastalert/config.yaml \
19+
-v `pwd`/config/elastalert-test.yaml:/opt/elastalert/config-test.yaml \
1920
-v `pwd`/config/config.json:/opt/elastalert-server/config/config.json \
2021
-v `pwd`/rules:/opt/elastalert/rules \
2122
-v `pwd`/rule_templates:/opt/elastalert/rule_templates \
@@ -112,6 +113,8 @@ run_every:
112113
buffer_time:
113114
minutes: 1
114115
```
116+
117+
There is also a `elastalert-test.yaml` file which is only used when you use the API to test a rule. This allows you to write to a different `writeback_index` for example when testing rules.
115118

116119
## API
117120
This server exposes the following REST API's:

config/elastalert-test.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# NOTE: This config is used when testing a rule
2+
3+
# The elasticsearch hostname for metadata writeback
4+
# Note that every rule can have its own elasticsearch host
5+
es_host: localhost
6+
7+
# The elasticsearch port
8+
es_port: 9200
9+
10+
# This is the folder that contains the rule yaml files
11+
# Any .yaml file will be loaded as a rule
12+
rules_folder: rules
13+
14+
# How often ElastAlert will query elasticsearch
15+
# The unit can be anything from weeks to seconds
16+
run_every:
17+
seconds: 5
18+
19+
# ElastAlert will buffer results from the most recent
20+
# period of time, in case some log sources are not in real time
21+
buffer_time:
22+
minutes: 1
23+
24+
# Optional URL prefix for elasticsearch
25+
#es_url_prefix: elasticsearch
26+
27+
# Connect with TLS to elasticsearch
28+
#use_ssl: True
29+
30+
# Verify TLS certificates
31+
#verify_certs: True
32+
33+
# GET request with body is the default option for Elasticsearch.
34+
# If it fails for some reason, you can pass 'GET', 'POST' or 'source'.
35+
# See http://elasticsearch-py.readthedocs.io/en/master/connection.html?highlight=send_get_body_as#transport
36+
# for details
37+
#es_send_get_body_as: GET
38+
39+
# Option basic-auth username and password for elasticsearch
40+
#es_username: someusername
41+
#es_password: somepassword
42+
43+
# The index on es_host which is used for metadata storage
44+
# This can be a unmapped index, but it is recommended that you run
45+
# elastalert-create-index to set a mapping
46+
writeback_index: elastalert_status
47+
48+
# If an alert fails for some reason, ElastAlert will retry
49+
# sending the alert until this time period has elapsed
50+
alert_time_limit:
51+
days: 2

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bitsensor/elastalert",
3-
"version": "0.0.14",
3+
"version": "1.0.0",
44
"description": "A server that runs ElastAlert and exposes REST API's for manipulating rules and alerts.",
55
"license": "MIT",
66
"main": "index.js",

src/controllers/test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default class TestController {
3131
let stdoutLines = [];
3232
let stderrLines = [];
3333

34-
processOptions.push('-m', 'elastalert.test_rule', '--config', 'config.yaml', tempFilePath, '--days', options.days);
34+
processOptions.push('-m', 'elastalert.test_rule', '--config', 'config-test.yaml', tempFilePath, '--days', options.days);
3535

3636
if (options.format === 'json') {
3737
processOptions.push('--formatted-output');

0 commit comments

Comments
 (0)