UNCLASSIFIED

Commit b5a94b0c authored by sean.melissari's avatar sean.melissari
Browse files

Merge branch 'elastic-agent-7.10.0' into 'development'

fix Elastic Agent does not connect to Kibana

See merge request !10
parents cb47f9eb 69d03c5e
Pipeline #154927 passed with stages
in 21 minutes and 40 seconds
################################################################################ ################################################################################
# Build stage 0 # 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_REGISTRY=registry1.dsop.io
ARG BASE_IMAGE=ironbank/redhat/ubi/ubi8 ARG BASE_IMAGE=ironbank/redhat/ubi/ubi8
...@@ -17,7 +17,6 @@ WORKDIR /usr/share/${ELASTIC_PRODUCT} ...@@ -17,7 +17,6 @@ WORKDIR /usr/share/${ELASTIC_PRODUCT}
COPY --chown=1000:0 ${ELASTIC_PRODUCT}-${ELASTIC_STACK}-${OS_AND_ARCH}.tar.gz . 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 \ 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 && rm ${ELASTIC_PRODUCT}-${ELASTIC_STACK}-${OS_AND_ARCH}.tar.gz
#COPY config/elastic-agent.yml /usr/share/${ELASTIC_PRODUCT}
# Support arbitrary user ids # Support arbitrary user ids
# Ensure that group permissions are the same as user permissions. # Ensure that group permissions are the same as user permissions.
...@@ -74,7 +73,8 @@ RUN groupadd --gid 1000 ${ELASTIC_PRODUCT} && useradd --uid 1000 --gid 1000 --gr ...@@ -74,7 +73,8 @@ RUN groupadd --gid 1000 ${ELASTIC_PRODUCT} && useradd --uid 1000 --gid 1000 --gr
# Elastic Agent permissions # Elastic Agent permissions
RUN find /usr/share//elastic-agent/data -type d -exec chmod 0770 {} \; && \ 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 COPY jq /usr/local/bin
RUN chown root:root /usr/local/bin/jq && chmod 0755 /usr/local/bin/jq RUN chown root:root /usr/local/bin/jq && chmod 0755 /usr/local/bin/jq
...@@ -85,16 +85,16 @@ RUN chmod 755 /usr/local/bin/docker-entrypoint ...@@ -85,16 +85,16 @@ RUN chmod 755 /usr/local/bin/docker-entrypoint
USER ${ELASTIC_PRODUCT} USER ${ELASTIC_PRODUCT}
ENV ELASTIC_PRODUCT=${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" \ LABEL org.label-schema.schema-version="1.0" \
org.label-schema.vendor="Elastic" \ org.label-schema.vendor="Elastic" \
org.label-schema.name="${ELASTIC_PRODUCT}" \ org.label-schema.name="${ELASTIC_PRODUCT}" \
org.label-schema.version="${ELASTIC_STACK}" \ 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.vcs-url="https://github.com/elastic/${ELASTIC_PRODUCT}" \
org.label-schema.license="Elastic License" license="Elastic License" 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"] 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'
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'
...@@ -3,7 +3,7 @@ ...@@ -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. **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 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** **NOTE**
...@@ -14,7 +14,7 @@ This functionality is in beta and is subject to change. The design and code is l ...@@ -14,7 +14,7 @@ This functionality is in beta and is subject to change. The design and code is l
### Installation instructions ### 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 ### Where to file issues and PRs
...@@ -37,7 +37,7 @@ visiting [Elastic Community](https://www.elastic.co/community). ...@@ -37,7 +37,7 @@ visiting [Elastic Community](https://www.elastic.co/community).
This software is governed by the [Elastic 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 and includes the full set of [free
features](https://www.elastic.co/subscriptions). features](https://www.elastic.co/subscriptions).
......
...@@ -12,12 +12,23 @@ set -eo pipefail ...@@ -12,12 +12,23 @@ set -eo pipefail
# KIBANA_PASSWORD - password for accessing kibana API [changeme] # KIBANA_PASSWORD - password for accessing kibana API [changeme]
# KIBANA_USERNAME - username for accessing kibana API [elastic] # KIBANA_USERNAME - username for accessing kibana API [elastic]
function log(){
local msg=$1
if [ "${DEBUG}" == "1" ]; then
echo $msg
fi
}
function setup(){ function setup(){
curl -X POST ${KIBANA_HOST:-http://localhost:5601}/api/fleet/setup -H 'kbn-xsrf: true' -u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} echo "Fleet setup"
curl -X POST ${KIBANA_HOST:-http://localhost:5601}/api/fleet/agents/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 'Content-Type: application/json' \
-H 'kbn-xsrf: true' \ -H 'kbn-xsrf: true' \
-u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} -u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme}
echo ""
} }
function enroll(){ function enroll(){
...@@ -27,23 +38,27 @@ function enroll(){ ...@@ -27,23 +38,27 @@ function enroll(){
if [[ -n "${FLEET_ENROLLMENT_TOKEN}" ]]; then if [[ -n "${FLEET_ENROLLMENT_TOKEN}" ]]; then
apikey="${FLEET_ENROLLMENT_TOKEN}" apikey="${FLEET_ENROLLMENT_TOKEN}"
else 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 'Content-Type: application/json' \
-H 'kbn-xsrf: true' \ -H 'kbn-xsrf: true' \
-u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} ) -u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} )
echo ""
local exitCode=$? local exitCode=$?
if [ $exitCode -ne 0 ]; then if [ $exitCode -ne 0 ]; then
exit $exitCode exit $exitCode
fi fi
echo $enrollResp log $enrollResp
local apikeyId=$(echo $enrollResp | jq -r '.list[0].id') 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 'Content-Type: application/json' \
-H 'kbn-xsrf: true' \ -H 'kbn-xsrf: true' \
-u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} ) -u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} )
echo ""
exitCode=$? exitCode=$?
if [ $exitCode -ne 0 ]; then if [ $exitCode -ne 0 ]; then
...@@ -52,13 +67,13 @@ function enroll(){ ...@@ -52,13 +67,13 @@ function enroll(){
apikey=$(echo $enrollResp | jq -r '.item.api_key') apikey=$(echo $enrollResp | jq -r '.item.api_key')
fi fi
echo $apikey log $apikey
if [[ -n "${FLEET_ENROLL_INSECURE}" ]] && [[ ${FLEET_ENROLL_INSECURE} == 1 ]]; then if [[ -n "${FLEET_ENROLL_INSECURE}" ]] && [[ ${FLEET_ENROLL_INSECURE} == 1 ]]; then
insecure_flag="--insecure" insecure_flag="--insecure"
fi 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 if [[ -n "${FLEET_SETUP}" ]] && [[ ${FLEET_SETUP} == 1 ]]; then setup; fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment