Skip to content

Commit 67cce9e

Browse files
committed
LOG-1195: Add Openshift Ingest Plugin for ES
Add default openshift_schema pipeline definiton for all [app-, infra-, audit-] indices.
1 parent ddbb5d0 commit 67cce9e

10 files changed

+67
-3
lines changed

elasticsearch/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ USER 0
3131

3232
ARG ES_ARCHIVE_URL
3333
ARG PROMETHEUS_EXPORTER_URL
34+
ARG INGEST_PLUGIN_URL
3435
ARG OPENDISTRO_URL
3536
ARG OPENSHIFT_CI
3637

@@ -44,6 +45,7 @@ ENV ES_PATH_CONF=/etc/elasticsearch/ \
4445
JAVA_HOME=/usr/lib/jvm/jre \
4546
NODE_QUORUM=1 \
4647
PROMETHEUS_EXPORTER_VER=6.8.1.0-redhat-00001 \
48+
INGEST_PLUGIN_VER=6.8.1.0-redhat-00002 \
4749
OPENDISTRO_VER=0.10.0.4-redhat-00001 \
4850
PLUGIN_LOGLEVEL=INFO \
4951
RECOVER_AFTER_NODES=1 \
@@ -80,6 +82,7 @@ RUN /var/tmp/install-es.sh
8082

8183
COPY ${upstream_code}/sgconfig/ ${HOME}/sgconfig/
8284
COPY ${upstream_code}/index_templates/ ${ES_HOME}/index_templates/
85+
COPY ${upstream_code}/ingest_pipelines/ ${ES_HOME}/ingest_pipelines/
8386
COPY ${upstream_code}/index_patterns/ ${ES_HOME}/index_patterns/
8487
COPY ${upstream_code}/init/ ${ES_HOME}/init/
8588
COPY ${upstream_code}/probe/ ${ES_HOME}/probe/

elasticsearch/Dockerfile.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ USER 0
4444

4545
ARG ES_ARCHIVE_URL
4646
ARG PROMETHEUS_EXPORTER_URL
47+
ARG INGEST_PLUGIN_URL
4748
ARG OPENDISTRO_URL
4849
ARG OPENSHIFT_CI
4950

@@ -57,6 +58,7 @@ ENV ES_PATH_CONF=/etc/elasticsearch/ \
5758
JAVA_HOME=/usr/lib/jvm/jre \
5859
NODE_QUORUM=1 \
5960
PROMETHEUS_EXPORTER_VER=6.8.1.0-redhat-00001 \
61+
INGEST_PLUGIN_VER=6.8.1.0-redhat-00002 \
6062
OPENDISTRO_VER=0.10.0.4-redhat-00001 \
6163
PLUGIN_LOGLEVEL=INFO \
6264
RECOVER_AFTER_NODES=1 \
@@ -96,6 +98,7 @@ RUN /var/tmp/install-es.sh
9698

9799
COPY --from=builder ${upstream_code}/sgconfig/ ${HOME}/sgconfig/
98100
COPY --from=builder ${upstream_code}/index_templates/ ${ES_HOME}/index_templates/
101+
COPY --from=builder ${upstream_code}/ingest_pipelines/ ${ES_HOME}/ingest_pipelines/
99102
COPY --from=builder ${upstream_code}/index_patterns/ ${ES_HOME}/index_patterns/
100103
COPY --from=builder ${upstream_code}/init/ ${ES_HOME}/init/
101104
COPY --from=builder ${upstream_code}/probe/ ${ES_HOME}/probe/

elasticsearch/ci-env.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ set -o xtrace
44

55
PROMETHEUS_EXPORTER_URL=${PROMETHEUS_EXPORTER_URL:-$MAVEN_REPO_URL/org/elasticsearch/plugin/prometheus/prometheus-exporter/$PROMETHEUS_EXPORTER_VER/prometheus-exporter-$PROMETHEUS_EXPORTER_VER.zip}
66
OPENDISTRO_URL=${OPENDISTRO_URL:-$MAVEN_REPO_URL/com/amazon/opendistroforelasticsearch/opendistro_security/$OPENDISTRO_VER/opendistro_security-$OPENDISTRO_VER.zip}
7+
INGEST_PLUGIN_URL=${INGEST_PLUGIN_URL:-https://github.com/ViaQ/elasticsearch-openshift-ingest-plugin/releases/download/$INGEST_PLUGIN_VER/openshift-ingest-plugin-$INGEST_PLUGIN_VER.zip}
78

89
if [[ "${OPENSHIFT_CI:-}" == "true" ]]; then
910
# This flag is set during CI runs. If no ARG was passed in,
1011
# default to maven.org.
1112
export ES_ARCHIVE_URL=https://github.com/openshift/origin-aggregated-logging/releases/download/elasticsearch-oss-$ES_VER/elasticsearch-oss-$ES_VER.zip
1213
export OPENDISTRO_URL=https://github.com/openshift/origin-aggregated-logging/releases/download/opendistro_security-$OPENDISTRO_VER/opendistro_security-$OPENDISTRO_VER.zip
1314

15+
INGEST_PLUGIN_VER=$(echo $INGEST_PLUGIN_VER | cut -d'-' -f1)
16+
export INGEST_PLUGIN_URL=https://github.com/ViaQ/elasticsearch-openshift-ingest-plugin/releases/download/$INGEST_PLUGIN_VER/openshift-ingest-plugin-$INGEST_PLUGIN_VER.zip
17+
# Modify this if you need to CI-test the plugin sourcing from different repo
18+
# export INGEST_PLUGIN_URL=https://github.com/lukas-vlcek/elasticsearch-openshift-ingest-plugin/releases/download/v$INGEST_PLUGIN_VER/openshift-ingest-plugin-$INGEST_PLUGIN_VER.zip
19+
1420
PROMETHEUS_EXPORTER_VER=$(echo $PROMETHEUS_EXPORTER_VER | cut -d'-' -f1)
1521
export PROMETHEUS_EXPORTER_URL=https://github.com/vvanholl/elasticsearch-prometheus-exporter/releases/download/$PROMETHEUS_EXPORTER_VER/prometheus-exporter-$PROMETHEUS_EXPORTER_VER.zip
1622
fi
17-
es_plugins=($OPENDISTRO_URL $PROMETHEUS_EXPORTER_URL)
23+
es_plugins=($OPENDISTRO_URL $PROMETHEUS_EXPORTER_URL $INGEST_PLUGIN_URL)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
- nvr: org.elasticsearch-elasticsearch-6.8.1.redhat_00006-1
22
- nvr: com.amazon.opendistroforelasticsearch-opendistro_security-0.10.0.4_redhat_00001-1
33
- nvr: org.elasticsearch.plugin.prometheus-prometheus-exporter-6.8.1.0_redhat_00001-1
4+
- nvr: org.elasticsearch.plugin.ingest-openshift-ingest-plugin-6.8.1.0_redhat_00002-1

elasticsearch/index_templates/com.redhat.viaq-openshift-operations.template.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,7 @@
973973
},
974974
"order": 10,
975975
"settings": {
976-
"index.refresh_interval": "5s"
976+
"index.refresh_interval": "5s",
977+
"index.default_pipeline": "openshift_schema.json"
977978
}
978979
}

elasticsearch/index_templates/com.redhat.viaq-openshift-project.template.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,7 @@
972972
},
973973
"order": 10,
974974
"settings": {
975-
"index.refresh_interval": "5s"
975+
"index.refresh_interval": "5s",
976+
"index.default_pipeline": "openshift_schema.json"
976977
}
977978
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"description": "Openshift ingest pipeline for custom schema",
3+
"processors": [
4+
{ "openshift-ingestion-processor": {} }
5+
]
6+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash -e
2+
#
3+
# Copyright 2018 Red Hat, Inc. and/or its affiliates
4+
# and other contributors as indicated by the @author tags.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
source "logging"
19+
20+
info Adding ingest pipelines
21+
shopt -s failglob
22+
for ingest_file in ${ES_HOME}/ingest_pipelines/*.json
23+
do
24+
25+
template=`basename $ingest_file`
26+
# Check if ingest template already exists
27+
response_code=$(es_util --query=_ingest/pipeline/$template \
28+
${DEBUG:+-v} -s \
29+
--request HEAD --head --output /dev/null \
30+
-w '%{response_code}')
31+
if [ "${response_code}" == "200" ]; then
32+
info "Ingest pipeline '$template' found in the cluster, overriding it"
33+
else
34+
info "Create ingest pipeline '$template'"
35+
fi
36+
es_util --query=_ingest/pipeline/$template \
37+
${DEBUG:+-v} -s -X PUT \
38+
-d@${ingest_file}
39+
40+
done
41+
shopt -u failglob
42+
info Finished adding ingest pipelines

elasticsearch/install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ done
2323
#fix location from config
2424
if [[ "${ES_HOME}" != "/usr/share/elasticsearch" ]]; then
2525
ln -s ${ES_HOME}/index_templates /usr/share/elasticsearch/index_templates
26+
ln -s ${ES_HOME}/ingest_pipelines /usr/share/elasticsearch/ingest_pipelines
2627
ln -s ${ES_HOME}/index_patterns /usr/share/elasticsearch/index_patterns
2728
fi
2829

0 commit comments

Comments
 (0)