From 2267cda50bb3622843cc3d360af3f787465ab19f Mon Sep 17 00:00:00 2001 From: kuisathaverat Date: Thu, 19 Nov 2020 18:41:00 +0100 Subject: [PATCH 1/2] Update Elastic Agent for 7.10.0 --- Dockerfile | 7 ++++--- scripts/docker-entrypoint | 31 +++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index be9c9c9..a800f51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,7 +74,8 @@ RUN groupadd --gid 1000 ${ELASTIC_PRODUCT} && useradd --uid 1000 --gid 1000 --gr # Elastic Agent permissions RUN find /usr/share//elastic-agent/data -type d -exec chmod 0770 {} \; && \ - find /usr/share//elastic-agent/data -type f -exec chmod 0660 {} \; + find /usr/share//elastic-agent/data -type f -exec chmod 0660 {} \; && \ + chmod +x /usr/share//elastic-agent/data/elastic-agent-*/elastic-agent COPY jq /usr/local/bin RUN chown root:root /usr/local/bin/jq && chmod 0755 /usr/local/bin/jq @@ -93,8 +94,8 @@ LABEL org.label-schema.schema-version="1.0" \ org.label-schema.vcs-url="https://github.com/elastic/${ELASTIC_PRODUCT}" \ org.label-schema.license="Elastic License" license="Elastic License" -ENTRYPOINT ["/usr/local/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint", "-E", "http.enabled=true", "-E", "http.host=unix:///usr/share/elastic-agent/data/elastic-agent.sock"] +ENTRYPOINT ["/usr/local/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint"] CMD ["--environment", "container"] # see https://www.elastic.co/guide/en/beats/elastic-agent/current/http-endpoint.html -HEALTHCHECK --interval=10s --timeout=5s --start-period=1m --retries=5 CMD curl -I -f --max-time 5 --unix-socket '/usr/share/elastic-agent/data/elastic-agent.sock' 'http:/stats/?pretty' +HEALTHCHECK --interval=10s --timeout=5s --start-period=1m --retries=5 CMD test -w '/tmp/elastic-agent/default/metricbeat/metricbeat.sock' diff --git a/scripts/docker-entrypoint b/scripts/docker-entrypoint index e2b8e31..83b8cb2 100644 --- a/scripts/docker-entrypoint +++ b/scripts/docker-entrypoint @@ -12,12 +12,23 @@ set -eo pipefail # KIBANA_PASSWORD - password for accessing kibana API [changeme] # KIBANA_USERNAME - username for accessing kibana API [elastic] +function log(){ + local msg=$1 + if [ "${DEBUG}" == "1" ]; then + echo $msg + fi +} + function setup(){ - curl -X POST ${KIBANA_HOST:-http://localhost:5601}/api/fleet/setup -H 'kbn-xsrf: true' -u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} - curl -X POST ${KIBANA_HOST:-http://localhost:5601}/api/fleet/agents/setup \ + echo "Fleet setup" + curl -X POST -sS ${KIBANA_HOST:-http://localhost:5601}/api/fleet/setup -H 'kbn-xsrf: true' -u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} + echo "" + echo "Agent setup" + curl -X POST -sS ${KIBANA_HOST:-http://localhost:5601}/api/fleet/agents/setup \ -H 'Content-Type: application/json' \ -H 'kbn-xsrf: true' \ -u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} + echo "" } function enroll(){ @@ -27,23 +38,27 @@ function enroll(){ if [[ -n "${FLEET_ENROLLMENT_TOKEN}" ]]; then apikey="${FLEET_ENROLLMENT_TOKEN}" else - enrollResp=$(curl ${KIBANA_HOST:-http://localhost:5601}/api/fleet/enrollment-api-keys \ + echo "Enroll Agent API key" + enrollResp=$(curl -sS ${KIBANA_HOST:-http://localhost:5601}/api/fleet/enrollment-api-keys \ -H 'Content-Type: application/json' \ -H 'kbn-xsrf: true' \ -u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} ) + echo "" local exitCode=$? if [ $exitCode -ne 0 ]; then exit $exitCode fi - echo $enrollResp + log $enrollResp local apikeyId=$(echo $enrollResp | jq -r '.list[0].id') - echo $apikeyId + log $apikeyId - enrollResp=$(curl ${KIBANA_HOST:-http://localhost:5601}/api/fleet/enrollment-api-keys/$apikeyId \ + echo "Enroll Agent" + enrollResp=$(curl -sS ${KIBANA_HOST:-http://localhost:5601}/api/fleet/enrollment-api-keys/$apikeyId \ -H 'Content-Type: application/json' \ -H 'kbn-xsrf: true' \ -u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} ) + echo "" exitCode=$? if [ $exitCode -ne 0 ]; then @@ -52,13 +67,13 @@ function enroll(){ apikey=$(echo $enrollResp | jq -r '.item.api_key') fi - echo $apikey + log $apikey if [[ -n "${FLEET_ENROLL_INSECURE}" ]] && [[ ${FLEET_ENROLL_INSECURE} == 1 ]]; then insecure_flag="--insecure" fi - ./elastic-agent enroll ${insecure_flag} ${KIBANA_HOST:-http://localhost:5601} $apikey -f + elastic-agent enroll ${insecure_flag} ${KIBANA_HOST:-http://localhost:5601} $apikey -f } if [[ -n "${FLEET_SETUP}" ]] && [[ ${FLEET_SETUP} == 1 ]]; then setup; fi -- GitLab From 69d03c5e457ec489880fa976f7a62b91bcb148b7 Mon Sep 17 00:00:00 2001 From: kuisathaverat Date: Fri, 20 Nov 2020 11:26:24 +0100 Subject: [PATCH 2/2] chore: typos and broken links --- Dockerfile | 7 +++---- README.md | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index a800f51..5e51c76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ################################################################################ # Build stage 0 -# Extract APM Server and make various file manipulations. +# Extract Elastic Agent and make various file manipulations. ################################################################################ ARG BASE_REGISTRY=registry1.dsop.io ARG BASE_IMAGE=ironbank/redhat/ubi/ubi8 @@ -17,7 +17,6 @@ WORKDIR /usr/share/${ELASTIC_PRODUCT} COPY --chown=1000:0 ${ELASTIC_PRODUCT}-${ELASTIC_STACK}-${OS_AND_ARCH}.tar.gz . RUN tar --strip-components=1 -zxf ${ELASTIC_PRODUCT}-${ELASTIC_STACK}-${OS_AND_ARCH}.tar.gz \ && rm ${ELASTIC_PRODUCT}-${ELASTIC_STACK}-${OS_AND_ARCH}.tar.gz -#COPY config/elastic-agent.yml /usr/share/${ELASTIC_PRODUCT} # Support arbitrary user ids # Ensure that group permissions are the same as user permissions. @@ -86,16 +85,16 @@ RUN chmod 755 /usr/local/bin/docker-entrypoint USER ${ELASTIC_PRODUCT} ENV ELASTIC_PRODUCT=${ELASTIC_PRODUCT} +# TODO update these links when Elastic Agent is in GA LABEL org.label-schema.schema-version="1.0" \ org.label-schema.vendor="Elastic" \ org.label-schema.name="${ELASTIC_PRODUCT}" \ org.label-schema.version="${ELASTIC_STACK}" \ - org.label-schema.url="https://www.elastic.co/products/${ELASTIC_PRODUCT}" \ + org.label-schema.url="https://www.elastic.co/guide/en/ingest-management/current/index.html" \ org.label-schema.vcs-url="https://github.com/elastic/${ELASTIC_PRODUCT}" \ org.label-schema.license="Elastic License" license="Elastic License" ENTRYPOINT ["/usr/local/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint"] CMD ["--environment", "container"] -# see https://www.elastic.co/guide/en/beats/elastic-agent/current/http-endpoint.html HEALTHCHECK --interval=10s --timeout=5s --start-period=1m --retries=5 CMD test -w '/tmp/elastic-agent/default/metricbeat/metricbeat.sock' diff --git a/README.md b/README.md index 49bbe9a..a5cb255 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ **elastic-agent** is a single, unified way to add monitoring for logs, metrics, and other types of data to each host. A single agent makes it easier and faster to deploy monitoring across your infrastructure. The agent’s single, unified configuration makes it easier to add integrations for new data sources. For more information about elastic-agent, please visit -https://www.elastic.co/guide/en/ingest-management/7.9/index.html. +https://www.elastic.co/guide/en/ingest-management/7.10/index.html. --- **NOTE** @@ -14,7 +14,7 @@ This functionality is in beta and is subject to change. The design and code is l ### Installation instructions -Please follow the documentation on [Quick start](https://www.elastic.co/guide/en/ingest-management/7.9/ingest-management-getting-started.html). +Please follow the documentation on [Quick start](https://www.elastic.co/guide/en/ingest-management/7.10/ingest-management-getting-started.html). ### Where to file issues and PRs @@ -37,7 +37,7 @@ visiting [Elastic Community](https://www.elastic.co/community). This software is governed by the [Elastic -License](https://github.com/elastic/elasticsearch/blob/7.9/licenses/ELASTIC-LICENSE.txt), +License](https://github.com/elastic/elasticsearch/blob/7.10/licenses/ELASTIC-LICENSE.txt), and includes the full set of [free features](https://www.elastic.co/subscriptions). -- GitLab