-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Elasticsearch 8 support + remove ES 6 support #744
Conversation
This also drops support for Elasticsearch 6 (all versions)
And fix resulting unit tests
Didn't realise we were still intructing people to write rules in the ES4 style
Does changing elasticsearch-py to 7.17.0 mean to stop supporting opensearch? .. The connection of opensearch will be repelled from elasticsearch-py7.14.0.
|
Do you not update?
|
Update setup.py as well as requirements.txt. |
Users seem to want es8 support rather than refactoring. As a developer, I know you want to get rid of old code that you want to clean. It's just my personal opinion, so you can ignore it. es8 support is the highest priority over erasing es5 and 6. Gradually erase old code after es8 support. For example, erase the es5 code six months later and erase the es6 code one year later. |
I'm not sure that the es5 code is squeezed but the es_mapping 5 folders and files are still there. Forgot to erase it? |
Thanks for the review @nsano-rururu! To address your points:
|
|
|
OpenSearch client compatibility
|
|
That seems to be the opposite of what was agreed here some months ago. |
If you can handle all the complaints from users, you can only say that you can merge them. When you say so. |
Then why are you asking a question? I don't know what it means. |
I think your idea is that opensearch support isn't considered from the beginning. |
With the current pull request content, I think I have no choice but to announce that opensearch should continue to use the past version as well as es6. |
If you merge as it is, the effect will be huge and you will get a lot of inquiries even if you write it in the changelog or put it on the FAQ, so it is realistic to add the correspondence table of elastalert2 version, elasticseach version, opensearch at the top of the readme. It may be. Do you hate that too? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e44dc75
Do you not update the document?
I installed it in the dockerfile of elastalert-server and tried it. There are a lot of warnings from elasticsearch-py, but is it working as expected? elasticsearch 7.17 Dockerfile FROM python:3.9-alpine3.15 as ea2
# ARG ELASTALERT_VERSION=2.3.0
# ENV ELASTALERT_VERSION=${ELASTALERT_VERSION}
# ARG ELASTALERT_URL=https://github.com/jertel/elastalert2/archive/refs/tags/$ELASTALERT_VERSION.zip
# ENV ELASTALERT_URL=${ELASTALERT_URL}
ENV ELASTALERT_HOME /opt/elastalert
RUN apk add --update --no-cache git
# WORKDIR /opt
# RUN apk add --update --no-cache wget && \
# wget -O elastalert.zip "${ELASTALERT_URL}" && \
# unzip elastalert.zip && \
# rm elastalert.zip && \
# mv e* "${ELASTALERT_HOME}"
RUN mkdir -p /opt/elastalert_install_work && \
cd /opt/elastalert_install_work && \
git clone https://github.com/jertel/elastalert2 && \
cd elastalert2 && \
git fetch origin pull/744/head:es8 && \
git checkout es8 && \
cd ../ && \
mv e* "${ELASTALERT_HOME}"
FROM node:16.13-alpine3.15 as install
ENV PATH /home/node/.local/bin:$PATH
RUN apk add --update --no-cache \
ca-certificates \
cargo \
curl \
gcc \
libffi-dev \
libmagic \
make \
musl-dev \
openssl \
openssl-dev \
py3-pip \
py3-wheel \
python3 \
python3-dev \
tzdata
COPY --from=ea2 /opt/elastalert /opt/elastalert
WORKDIR /opt/elastalert-server
COPY . /opt/elastalert-server
RUN npm install --production --quiet
RUN pip3 install --no-cache-dir --upgrade pip==22.0.3
USER node
WORKDIR /opt/elastalert
RUN pip3 install --no-cache-dir cryptography --user
RUN pip3 install --no-cache-dir -r requirements.txt --user
FROM node:16.13-alpine3.15
LABEL maintainer="John Susek <[email protected]>"
ENV TZ Etc/UTC
ENV PATH /home/node/.local/bin:$PATH
RUN apk add --update --no-cache \
ca-certificates \
cargo \
curl \
gcc \
libffi-dev \
libmagic \
make \
musl-dev \
openssl \
openssl-dev \
py3-pip \
python3 \
python3-dev \
tzdata
COPY --from=install /opt/elastalert /opt/elastalert
COPY --from=install /home/node/.local/lib/python3.9/site-packages /home/node/.local/lib/python3.9/site-packages
WORKDIR /opt/elastalert-server
COPY --from=install /opt/elastalert-server ./
COPY config/elastalert.yaml /opt/elastalert/config.yaml
COPY config/config.json config/config.json
COPY rule_templates/ /opt/elastalert/rule_templates
COPY elastalert_modules/ /opt/elastalert/elastalert_modules
# Add default rules directory
# Set permission as unpriviledged user (1000:1000), compatible with Kubernetes
RUN mkdir -p /opt/elastalert/rules/ /opt/elastalert/server_data/tests/ \
&& chown -R node:node /opt
USER node
EXPOSE 3030
WORKDIR /opt/elastalert-server
ENTRYPOINT ["npm", "start"] rule file alert:
- "slack"
alert_subject: "alert_subject: \"Test {} 123 aa☃\""
alert_subject_args:
- "message"
alert_text: "Test {} 123 bb☃"
alert_text_args:
- "message"
filter:
- query:
query_string:
query: "message:Quit"
index: "mariadblog-*"
is_enabled: true
name: "a"
num_events: 2
realert:
minutes: 5
slack_webhook_url: 'https://hooks.slack.com/services/xxxx'
slack_channel_override: "#abc"
slack_emoji_override: ":ghost:"
slack_msg_color: "danger"
slack_parse_override: "none"
slack_timeout: 10
slack_title_link: "http://127.0.0.1:8080/rules/a"
slack_username_override: "Praeco"
terms_size: 50
timeframe:
minutes: 5
timestamp_field: "@timestamp"
timestamp_type: "iso"
type: "frequency"
use_strftime_index: false docker log 10:58:24.377Z INFO elastalert-server: Config: No config.dev.json file was found in /opt/elastalert-server/config/config.dev.json.
10:58:24.398Z INFO elastalert-server: Config: Proceeding to look for normal config file.
10:58:24.399Z INFO elastalert-server: Config: A config file was found in /opt/elastalert-server/config/config.json. Using that config.
10:58:24.500Z INFO elastalert-server: Router: Listening for GET request on /.
10:58:24.502Z INFO elastalert-server: Router: Listening for GET request on /status.
10:58:24.514Z INFO elastalert-server: Router: Listening for GET request on /status/errors.
10:58:24.516Z INFO elastalert-server: Router: Listening for GET request on /rules.
10:58:24.527Z INFO elastalert-server: Router: Listening for GET request on /rules/:id*.
10:58:24.535Z INFO elastalert-server: Router: Listening for POST request on /rules/:id*.
10:58:24.542Z INFO elastalert-server: Router: Listening for DELETE request on /rules/:id*.
10:58:24.549Z INFO elastalert-server: Router: Listening for GET request on /templates.
10:58:24.557Z INFO elastalert-server: Router: Listening for GET request on /templates/:id*.
10:58:24.562Z INFO elastalert-server: Router: Listening for POST request on /templates/:id*.
10:58:24.573Z INFO elastalert-server: Router: Listening for DELETE request on /templates/:id*.
10:58:24.579Z INFO elastalert-server: Router: Listening for PUT request on /folders/:type/:path*.
10:58:24.583Z INFO elastalert-server: Router: Listening for DELETE request on /folders/:type/:path*.
10:58:24.620Z INFO elastalert-server: Router: Listening for POST request on /test.
10:58:24.628Z INFO elastalert-server: Router: Listening for POST request on /silence/:path*.
10:58:24.633Z INFO elastalert-server: Router: Listening for GET request on /config.
10:58:24.635Z INFO elastalert-server: Router: Listening for POST request on /config.
10:58:24.653Z INFO elastalert-server: Router: Listening for GET request on /metadata/elastalert.
10:58:24.654Z INFO elastalert-server: Router: Listening for GET request on /metadata/elastalert_status.
10:58:24.655Z INFO elastalert-server: Router: Listening for GET request on /metadata/silence.
10:58:24.657Z INFO elastalert-server: Router: Listening for GET request on /metadata/elastalert_error.
10:58:24.658Z INFO elastalert-server: Router: Listening for GET request on /metadata/past_elastalert.
10:58:24.658Z INFO elastalert-server: Router: Listening for GET request on /indices.
10:58:24.662Z INFO elastalert-server: Router: Listening for GET request on /mapping/:index.
10:58:24.663Z INFO elastalert-server: Router: Listening for POST request on /search/:index.
10:58:24.663Z INFO elastalert-server: Router: Listening for GET request on /config.
10:58:24.684Z INFO elastalert-server: ProcessController: Starting ElastAlert
10:58:24.685Z INFO elastalert-server: ProcessController: Creating index
10:58:34.746Z INFO elastalert-server:
ProcessController: Reading Elastic 7 index mappings:
Reading index mapping 'es_mappings/7/silence.json'
Reading index mapping 'es_mappings/7/elastalert_status.json'
Reading index mapping 'es_mappings/7/elastalert.json'
Reading index mapping 'es_mappings/7/past_elastalert.json'
Reading index mapping 'es_mappings/7/elastalert_error.json'
New index praeco_elastalert_status created
Done!
10:58:34.746Z ERROR elastalert-server:
ProcessController: /opt/elastalert/elastalert/create_index.py:39: DeprecationWarning: Using positional arguments for APIs is deprecated and will be disabled in 8.0.0. Instead use only keyword arguments for all APIs. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
if es_index.exists(ea_index):
/opt/elastalert/elastalert/create_index.py:57: DeprecationWarning: Using positional arguments for APIs is deprecated and will be disabled in 8.0.0. Instead use only keyword arguments for all APIs. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
if es_index.exists(index_name):
/opt/elastalert/elastalert/create_index.py:64: DeprecationWarning: Using positional arguments for APIs is deprecated and will be disabled in 8.0.0. Instead use only keyword arguments for all APIs. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
es_index.create(index_name)
/home/node/.local/lib/python3.9/site-packages/elasticsearch/connection/base.py:200: ElasticsearchWarning: Camel case format name dateOptionalTime is deprecated and will be removed in a future version. Use snake case name date_optional_time instead.
warnings.warn(message, category=ElasticsearchWarning)
/home/node/.local/lib/python3.9/site-packages/elasticsearch/connection/base.py:200: ElasticsearchWarning: [types removal] Using include_type_name in put mapping requests is deprecated. The parameter will be removed in the next major version.
warnings.warn(message, category=ElasticsearchWarning)
10:58:34.746Z INFO elastalert-server: ProcessController: Index create exited with code 0
10:58:34.754Z INFO elastalert-server: ProcessController: Starting elastalert with arguments [none]
10:58:34.775Z INFO elastalert-server: ProcessController: Started Elastalert (PID: 377)
10:58:34.782Z INFO elastalert-server: Server: Server listening on port 3030
10:58:34.792Z INFO elastalert-server: Server: Websocket listening on port 3333
10:58:34.799Z INFO elastalert-server: Server: Server started
10:58:40.541Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
10:59:10.961Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
10:59:41.364Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
10:59:46.058Z ERROR elastalert-server:
ProcessController: WARNING:py.warnings:/opt/elastalert/elastalert/elastalert.py:1611: DeprecationWarning: The 'body' parameter is deprecated for the 'index' API and will be removed in a future version. Instead use the 'document' parameter. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.writeback_es.index(index=index, body=body)
10:59:46.169Z ERROR elastalert-server:
ProcessController: WARNING:py.warnings:/home/node/.local/lib/python3.9/site-packages/elasticsearch/connection/base.py:200: ElasticsearchWarning: Camel case format name dateOptionalTime is deprecated and will be removed in a future version. Use snake case name date_optional_time instead.
warnings.warn(message, category=ElasticsearchWarning)
11:00:12.052Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:00:38.115Z ERROR elastalert-server:
ProcessController: WARNING:py.warnings:/opt/elastalert/elastalert/elastalert.py:1631: DeprecationWarning: The 'body' parameter is deprecated for the 'search' API and will be removed in a future version. Instead use API parameters directly. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.writeback_es.search(index=self.writeback_index, body=query, size=1000)
11:00:42.388Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:00:45.837Z ERROR elastalert-server:
ProcessController: WARNING:py.warnings:/opt/elastalert/elastalert/elastalert.py:371: DeprecationWarning: The 'body' parameter is deprecated for the 'search' API and will be removed in a future version. Instead use API parameters directly. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.thread_data.current_es.search(
11:01:12.789Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:01:43.113Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:02:13.411Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:02:43.720Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:02:51.701Z ERROR elastalert-server:
ProcessController: WARNING:py.warnings:/opt/elastalert/elastalert/elastalert.py:1876: DeprecationWarning: The 'body' parameter is deprecated for the 'search' API and will be removed in a future version. Instead use API parameters directly. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.writeback_es.search(index=index, size=1, body=query,
11:02:53.359Z INFO elastalert-server: Routes: Successfully handled GET request for '/rules/:id'.
11:02:53.372Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:02:53.390Z INFO elastalert-server: Routes: Successfully handled GET request for '/config'.
11:02:53.397Z INFO elastalert-server: Routes: Successfully handled GET request for '/config'.
11:02:53.424Z INFO elastalert-server: Routes: Successfully handled GET request for '/rules'.
11:03:14.289Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:03:30.577Z INFO elastalert-server: Routes: Successfully handled GET request for '/rules/:id'.
11:03:44.919Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:04:15.349Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:04:46.035Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:04:57.605Z ERROR elastalert-server:
ProcessController: WARNING:py.warnings:/opt/elastalert/elastalert/elastalert.py:1611: DeprecationWarning: The 'body' parameter is deprecated for the 'index' API and will be removed in a future version. Instead use the 'document' parameter. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.writeback_es.index(index=index, body=body)
11:05:16.366Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:05:38.115Z ERROR elastalert-server:
ProcessController: WARNING:py.warnings:/opt/elastalert/elastalert/elastalert.py:1631: DeprecationWarning: The 'body' parameter is deprecated for the 'search' API and will be removed in a future version. Instead use API parameters directly. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.writeback_es.search(index=self.writeback_index, body=query, size=1000)
11:05:46.658Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:05:58.472Z ERROR elastalert-server:
ProcessController: WARNING:py.warnings:/opt/elastalert/elastalert/elastalert.py:371: DeprecationWarning: The 'body' parameter is deprecated for the 'search' API and will be removed in a future version. Instead use API parameters directly. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.thread_data.current_es.search(
11:05:59.070Z ERROR elastalert-server:
ProcessController: WARNING:py.warnings:/opt/elastalert/elastalert/elastalert.py:1876: DeprecationWarning: The 'body' parameter is deprecated for the 'search' API and will be removed in a future version. Instead use API parameters directly. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.writeback_es.search(index=index, size=1, body=query,
11:06:16.984Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:06:47.293Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:07:17.611Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:07:47.939Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:08:18.345Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:08:48.573Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:09:18.855Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:09:49.112Z INFO elastalert-server: Routes: Successfully handled GET request for '/'.
11:10:09.330Z ERROR elastalert-server:
ProcessController: WARNING:py.warnings:/opt/elastalert/elastalert/elastalert.py:1611: DeprecationWarning: The 'body' parameter is deprecated for the 'index' API and will be removed in a future version. Instead use the 'document' parameter. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.writeback_es.index(index=index, body=body)
11:10:19.513Z INFO elastalert-server: Routes: Successfully handled GET request for '/'. |
I changed the elasticsearch-py version of setup.py to 7.17 and am running it. elastalert-create-index (py39) [CORP\sano@a-ngft53r34ong elastalert2]$ elastalert-create-index
Reading Elastic 7 index mappings:
Reading index mapping 'es_mappings/7/silence.json'
Reading index mapping 'es_mappings/7/elastalert_status.json'
Reading index mapping 'es_mappings/7/elastalert.json'
Reading index mapping 'es_mappings/7/past_elastalert.json'
Reading index mapping 'es_mappings/7/elastalert_error.json'
Deleting index elastalert_status_status.
Deleting index elastalert_status_error.
/home/sano/py39/lib/python3.9/site-packages/elasticsearch-7.17.0-py3.9.egg/elasticsearch/connection/base.py:200: ElasticsearchWarning: Camel case format name dateOptionalTime is deprecated and will be removed in a future version. Use snake case name date_optional_time instead.
warnings.warn(message, category=ElasticsearchWarning)
/home/sano/py39/lib/python3.9/site-packages/elasticsearch-7.17.0-py3.9.egg/elasticsearch/connection/base.py:200: ElasticsearchWarning: [types removal] Using include_type_name in put mapping requests is deprecated. The parameter will be removed in the next major version.
warnings.warn(message, category=ElasticsearchWarning)
New index elastalert_status created
Done!
(py39) [CORP\sano@a-ngft53r34ong elastalert2]$ elastalert-test-rule Error in elastalert-test-rule (py39) [CORP\sano@a-ngft53r34ong elastalert2]$ elastalert-test-rule rules/a.yaml
INFO:elastalert:Note: In debug mode, alerts will be logged to console but NOT actually sent.
To send them but remain verbose, use --verbose instead.
Error connecting to ElasticSearch:
AttributeError("type object 'ElastAlerter' has no attribute 'modify_rule_for_ES5'")
INFO:elastalert:Note: In debug mode, alerts will be logged to console but NOT actually sent.
To send them but remain verbose, use --verbose instead.
1 rules loaded
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
INFO:elastalert:Queried rule a from 2022-03-01 20:48 JST to 2022-03-01 20:53 JST: 0 / 0 hits
Would have written the following documents to writeback index (default is elastalert_status):
elastalert_status - {'rule_name': 'a', 'endtime': datetime.datetime(2022, 3, 1, 11, 53, 55, 380438, tzinfo=tzutc()), 'starttime': datetime.datetime(2022, 3, 1, 11, 48, 52, 380438, tzinfo=tzutc()), 'matches': 0, 'hits': 0, '@timestamp': datetime.datetime(2022, 3, 1, 11, 53, 55, 575557, tzinfo=tzutc()), 'time_taken': 0.014517068862915039}
(py39) [CORP\sano@a-ngft53r34ong elastalert2]$ Running ElastAlert 2 (py39) [CORP\sano@a-ngft53r34ong elastalert2]$ python -m elastalert.elastalert --verbose --rule rules/a.yaml
1 rules loaded
INFO:elastalert:Starting up
INFO:elastalert:Disabled rules are: []
INFO:elastalert:Sleeping for 9.99984 seconds
WARNING:elasticsearch:POST http://localhost:9200/elastalert_status_status/_search?_source_includes=endtime%2Crule_name&size=1 [status:404 request:0.016s]
ERROR:elastalert:Error querying for last run: NotFoundError(404, 'index_not_found_exception', 'no such index [elastalert_status_status]', elastalert_status_status, index_or_alias)
INFO:elastalert:Queried rule a from 2022-03-01 20:45 JST to 2022-03-01 21:00 JST: 3 / 3 hits
WARNING:elasticsearch:POST http://localhost:9200/elastalert_status_silence/_search?_source_includes=until%2Cexponent&size=1 [status:404 request:0.007s]
ERROR:elastalert:Error while querying for alert silence status: NotFoundError(404, 'index_not_found_exception', 'no such index [elastalert_status_silence]', elastalert_status_silence, index_or_alias)
WARNING:elasticsearch:POST http://localhost:9200/elastalert_status_silence/_search?_source_includes=until%2Cexponent&size=1 [status:404 request:0.008s]
ERROR:elastalert:Error while querying for alert silence status: NotFoundError(404, 'index_not_found_exception', 'no such index [elastalert_status_silence]', elastalert_status_silence, index_or_alias)
INFO:elastalert:Alert 'a' sent to Slack
WARNING:py.warnings:/home/sano/dkwork3/wk2/elastalert2/elastalert/elastalert.py:1611: DeprecationWarning: The 'body' parameter is deprecated for the 'index' API and will be removed in a future version. Instead use the 'document' parameter. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.writeback_es.index(index=index, body=body)
INFO:elastalert:Ran a from 2022-03-01 20:45 JST to 2022-03-01 21:00 JST: 3 query hits (0 already seen), 1 matches, 1 alerts sent
INFO:elastalert:a range 900
WARNING:py.warnings:/home/sano/dkwork3/wk2/elastalert2/elastalert/elastalert.py:1631: DeprecationWarning: The 'body' parameter is deprecated for the 'search' API and will be removed in a future version. Instead use API parameters directly. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.writeback_es.search(index=self.writeback_index, body=query, size=1000)
INFO:elastalert:Background configuration change check run at 2022-03-01 21:00 JST
INFO:elastalert:Disabled rules are: []
INFO:elastalert:Sleeping for 9.997979 seconds
INFO:elastalert:Background alerts thread 0 pending alerts sent at 2022-03-01 21:00 JST
WARNING:py.warnings:/home/sano/dkwork3/wk2/elastalert2/elastalert/elastalert.py:371: DeprecationWarning: The 'body' parameter is deprecated for the 'search' API and will be removed in a future version. Instead use API parameters directly. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.thread_data.current_es.search( INFO:elastalert:Background configuration change check run at 2022-03-01 21:06 JST
INFO:elastalert:Background alerts thread 0 pending alerts sent at 2022-03-01 21:06 JST
INFO:elastalert:Disabled rules are: []
INFO:elastalert:Sleeping for 9.999773 seconds
INFO:elastalert:Queried rule a from 2022-03-01 21:01 JST to 2022-03-01 21:07 JST: 12 / 12 hits
INFO:elastalert:Alert 'a' sent to Slack
WARNING:py.warnings:/home/sano/dkwork3/wk2/elastalert2/elastalert/elastalert.py:1611: DeprecationWarning: The 'body' parameter is deprecated for the 'index' API and will be removed in a future version. Instead use the 'document' parameter. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.writeback_es.index(index=index, body=body)
WARNING:py.warnings:/home/sano/dkwork3/wk2/elastalert2/elastalert/elastalert.py:1876: DeprecationWarning: The 'body' parameter is deprecated for the 'search' API and will be removed in a future version. Instead use API parameters directly. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.writeback_es.search(index=index, size=1, body=query,
INFO:elastalert:Ignoring match for silenced rule a
INFO:elastalert:Ran a from 2022-03-01 21:01 JST to 2022-03-01 21:07 JST: 12 query hits (9 already seen), 2 matches, 1 alerts sent
INFO:elastalert:a range 358
WARNING:py.warnings:/home/sano/dkwork3/wk2/elastalert2/elastalert/elastalert.py:1631: DeprecationWarning: The 'body' parameter is deprecated for the 'search' API and will be removed in a future version. Instead use API parameters directly. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.writeback_es.search(index=self.writeback_index, body=query, size=1000)
INFO:elastalert:Background configuration change check run at 2022-03-01 21:07 JST
INFO:elastalert:Background alerts thread 0 pending alerts sent at 2022-03-01 21:07 JST
INFO:elastalert:Disabled rules are: []
INFO:elastalert:Sleeping for 9.999797 seconds
WARNING:py.warnings:/home/sano/dkwork3/wk2/elastalert2/elastalert/elastalert.py:371: DeprecationWarning: The 'body' parameter is deprecated for the 'search' API and will be removed in a future version. Instead use API parameters directly. See https://github.com/elastic/elasticsearch-py/issues/1698 for more information
res = self.thread_data.current_es.search(
INFO:elastalert:Queried rule a from 2022-03-01 21:01 JST to 2022-03-01 21:07 JST: 12 / 12 hits
INFO:elastalert:Ran a from 2022-03-01 21:01 JST to 2022-03-01 21:07 JST: 12 query hits (12 already seen), 0 matches, 0 alerts sent
INFO:elastalert:a range 370
INFO:elastalert:Background configuration change check run at 2022-03-01 21:07 JST
INFO:elastalert:Background alerts thread 0 pending alerts sent at 2022-03-01 21:07 JST
INFO:elastalert:Disabled rules are: []
INFO:elastalert:Sleeping for 9.999757 seconds
INFO:elastalert:Background configuration change check run at 2022-03-01 21:07 JST
INFO:elastalert:Background alerts thread 0 pending alerts sent at 2022-03-01 21:07 JST
INFO:elastalert:Disabled rules are: []
INFO:elastalert:Sleeping for 9.999779 seconds
INFO:elastalert:Queried rule a from 2022-03-01 21:01 JST to 2022-03-01 21:07 JST: 12 / 12 hits
INFO:elastalert:Ran a from 2022-03-01 21:01 JST to 2022-03-01 21:07 JST: 12 query hits (12 already seen), 0 matches, 0 alerts sent
INFO:elastalert:a range 383
INFO:elastalert:Background configuration change check run at 2022-03-01 21:07 JST
INFO:elastalert:Background alerts thread 0 pending alerts sent at 2022-03-01 21:07 JST
INFO:elastalert:Disabled rules are: []
INFO:elastalert:Sleeping for 9.999748 seconds
INFO:elastalert:Queried rule a from 2022-03-01 21:01 JST to 2022-03-01 21:07 JST: 12 / 12 hits
INFO:elastalert:Ran a from 2022-03-01 21:01 JST to 2022-03-01 21:07 JST: 12 query hits (12 already seen), 0 matches, 0 alerts sent
INFO:elastalert:a range 396
INFO:elastalert:Background configuration change check run at 2022-03-01 21:07 JST
INFO:elastalert:Background alerts thread 0 pending alerts sent at 2022-03-01 21:07 JST
INFO:elastalert:Disabled rules are: []
INFO:elastalert:Sleeping for 9.999725 seconds
INFO:elastalert:Queried rule a from 2022-03-01 21:01 JST to 2022-03-01 21:07 JST: 12 / 12 hits
INFO:elastalert:Ran a from 2022-03-01 21:01 JST to 2022-03-01 21:07 JST: 12 query hits (12 already seen), 0 matches, 0 alerts sent
INFO:elastalert:a range 409
INFO:elastalert:Background configuration change check run at 2022-03-01 21:07 JST
INFO:elastalert:Background alerts thread 0 pending alerts sent at 2022-03-01 21:07 JST
INFO:elastalert:Disabled rules are: []
INFO:elastalert:Sleeping for 9.999805 seconds |
make test-docker has no test failures. |
Isn't it okay to remove the description of elasticsearch2 below? docs/source/recipes/writing_filters.rst
|
It might be better to add that _type is no longer elasticsearch8 examples/rules/example_percentage_match.yaml L12
examples/rules/example_new_term.yaml L50 _type: "login_event" |
I've updated the upgrade notes with a warning about deleting ElastAlert indices before starting the 8.x upgrade process. More information can be found on this Elastic 8 upgrade bug here: elastic/elasticsearch#84199 |
I just tested Discover URLs with ES 8 + Kibana 8 and it worked without any changes. I don't have any ElastAlert 2 error logs. Can you give me more information about the error? Was it printed in the ElastAlert 2 output? Or in Kibana error log? Here's the rule configuration I used:
|
This has been pushed. Thanks for reporting this. |
There are no elastalert2 errors. I get an error when I display the url generated by elastalert2 in a browser. alert:
- "slack"
alert_subject: "alert_subject: \"Test {} 123 aa☃\""
alert_subject_args:
- "message"
alert_text: "Test {} 123 bb☃"
alert_text_args:
- "message"
filter:
- query:
query_string:
query: "message:Quit"
generate_kibana_discover_url: true
import: "BaseRule.config"
index: "mariadblog-*"
is_enabled: true
kibana_discover_app_url: "http://localhost:5601/app/discover#/"
kibana_discover_from_timedelta:
minutes: 10
kibana_discover_index_pattern_id: "mariadblog"
kibana_discover_to_timedelta:
minutes: 10
kibana_discover_version: "8.0"
match_enhancements: []
name: "a"
num_events: 2
realert:
minutes: 5
slack_attach_kibana_discover_url: true
slack_channel_override: "#abc"
slack_emoji_override: ":ghost:"
slack_kibana_discover_color: "#ec4b98"
slack_kibana_discover_title: "Discover in Kibana"
slack_msg_color: "danger"
slack_parse_override: "none"
slack_timeout: 10
slack_title_link: "http://127.0.0.1:8080/rules/a"
slack_username_override: "Praeco"
slack_webhook_url: 'https://hooks.slack.com/services/xxxxxxxxxxx'
terms_size: 50
timeframe:
minutes: 5
timestamp_field: "@timestamp"
timestamp_type: "iso"
type: "frequency"
use_strftime_index: false |
Ok, I see it now. Since I didn't have an actual index pattern ID defined it defaulted to an existing view which allowed it to return results. When I specify a real pattern ID it will fail as you mentioned. |
…breaks 8.x when left in
The Kibana 8.0 discover URL fix is now pushed. A new Docker image is also pushed for tag Since we've dropped 6.x and earlier support I suggest in a future PR that the |
I should have judged by looking at kibana_version about the shortened URL. If the api specifications do not change when es7 support is completely discontinued, it can be deleted, but it cannot be said that it will definitely change. I think that it is a parameter prepared to clarify which version is supported, so I think that it is better not to delete it. |
That's fine with me to keep it. I know you are the one that typically does the version update, so if you don't mind that maintenance work let's continue with it as-is. |
Is the fix that kibana Discover supports kibana 8 without affecting the behavior of kibana 7.x? |
kibana discover has confirmed that it does not affect the operation in kibana 7.17. |
I tested the fix against both 7 and 8, both worked fine. |
generate_kibana_link
The documentation says it's for kibana 3 only.
use_kibana_dashboard and use_kibana4_dashboard
The documentation states that use_kibana_dashboard is for kibana 3 and use_kibana4_dashboard is for kibana 4. https://github.com/jertel/elastalert2/blob/master/docs/source/ruletypes.rst#use_kibana_dashboard
https://github.com/jertel/elastalert2/blob/master/docs/source/ruletypes.rst#use_kibana4_dashboard
|
Thanks @nsano-rururu. All references to Kibana dashboard integration are now removed. Docker image with tag |
https://github.com/jertel/elastalert2/blob/master/chart/elastalert2/values.yaml#L82 # generate_kibana_link: true |
Description
A big diff that I would like as much attention as possible on!
The key underlying change is bumping elasticsearch-py to the latest 7.* version, 7.17.0.
This will - hopefully in a future diff - allow us to enable the ES 8 compatibility mode.
As a consequence of the version bump, ES 6 support is removed as discussed in #92 (comment). I took the opportunity to remove a lot of the ES-6 related code from the codebase.
I have tried to update as many unit tests as possible - as far as I'm aware I've only removed unit tests where they are no longer relevant because we don't support ES 5 or 6.
That said, this has involved some extensive refactoring. I have tested locally, both using the unit tests and an Elasticsearch instance, and things seem to be working, but I would appreciate at least one other person giving this a whirl before landing.
Checklist
make test-docker
with my changes.Questions or Comments