From 190f174637dbdd8ad25cf1751ebee4205d0c03c8 Mon Sep 17 00:00:00 2001 From: Antoine Cotten Date: Thu, 5 Mar 2020 17:15:08 +0100 Subject: [PATCH] Add APM Server extension tests Update extension README --- .travis.yml | 22 +++++++++--- .travis/run-tests-apm-server.sh | 13 +++++++ extensions/apm-server/README.md | 36 +++++++++++--------- extensions/apm-server/apm-server-compose.yml | 11 ++++-- 4 files changed, 59 insertions(+), 23 deletions(-) create mode 100755 .travis/run-tests-apm-server.sh diff --git a/.travis.yml b/.travis.yml index 854fe1a..969a9af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,7 @@ before_script: - sed -i -e 's/\(xpack.monitoring.elasticsearch.username:\) elastic/\1 logstash_system/g' -e 's/\(xpack.monitoring.elasticsearch.password:\) changeme/\1 testpasswd/g' logstash/config/logstash.yml - sed -i 's/\(password =>\) "changeme"/\1 "testpasswd"/g' logstash/pipeline/logstash.conf - sed -i 's/\(elasticsearch.password:\) changeme/\1 testpasswd/g' extensions/app-search/config/app-search.yml + - sed -i 's/\(password:\) changeme/\1 testpasswd/g' extensions/apm-server/config/apm-server.yml script: # Core Elastic Stack @@ -35,18 +36,29 @@ script: - docker-compose logs elasticsearch - docker-compose logs kibana - docker-compose logs logstash - - docker-compose down -v + - docker-compose stop logstash kibana # Extensions - - docker-compose up -d elasticsearch - - sleep 30 - - .travis/elasticsearch-setup-passwords.exp # App Search - docker-compose -f docker-compose.yml -f extensions/app-search/app-search-compose.yml up -d app-search - .travis/run-tests-app-search.sh - docker-compose -f docker-compose.yml -f extensions/app-search/app-search-compose.yml ps - docker-compose -f docker-compose.yml -f extensions/app-search/app-search-compose.yml logs app-search - - docker-compose -f docker-compose.yml -f extensions/app-search/app-search-compose.yml down -v + - docker-compose -f docker-compose.yml -f extensions/app-search/app-search-compose.yml stop app-search + # APM Server + - docker-compose -f docker-compose.yml -f extensions/apm-server/apm-server-compose.yml up -d apm-server + - .travis/run-tests-apm-server.sh + - docker-compose -f docker-compose.yml -f extensions/apm-server/apm-server-compose.yml ps + - docker-compose -f docker-compose.yml -f extensions/apm-server/apm-server-compose.yml logs apm-server + - docker-compose -f docker-compose.yml -f extensions/apm-server/apm-server-compose.yml stop apm-server + + # Tear down + - >- + docker-compose + -f docker-compose.yml + -f extensions/app-search/app-search-compose.yml + -f extensions/apm-server/apm-server-compose.yml + down -v # Swarm - docker swarm init diff --git a/.travis/run-tests-apm-server.sh b/.travis/run-tests-apm-server.sh new file mode 100755 index 0000000..5f02d59 --- /dev/null +++ b/.travis/run-tests-apm-server.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -eu +set -o pipefail + + +source "$(dirname ${BASH_SOURCE[0]})/lib/testing.sh" + + +declare MODE="" + +log 'Waiting for readiness of APM Server' +poll_ready apm-server 'http://localhost:8200/' diff --git a/extensions/apm-server/README.md b/extensions/apm-server/README.md index 77a7510..cddad91 100644 --- a/extensions/apm-server/README.md +++ b/extensions/apm-server/README.md @@ -1,21 +1,23 @@ # APM Server extension -Adds a container for Elasticsearch APM server. Forwards caught errors and traces to Elasticsearch to enable their -visualisation in Kibana. +The APM Server receives data from APM agents and transforms them into Elasticsearch documents that can be visualised in +Kibana. ## Usage -If you want to include the APM server, run Docker Compose from the root of the repository with an additional command -line argument referencing the `apm-server-compose.yml` file: +To include APM Server in the stack, run Docker Compose from the root of the repository with an additional command line +argument referencing the `apm-server-compose.yml` file: ```console $ docker-compose -f docker-compose.yml -f extensions/apm-server/apm-server-compose.yml up ``` -## Connecting an agent to APM-Server +Meanwhile, you can navigate to the **APM** application in Kibana and follow the setup instructions to get started. + +## Connecting an agent to APM Server The most basic configuration to send traces to APM server is to specify the `SERVICE_NAME` and `SERVICE_URL`. Here is an -example Python FLASK configuration: +example Python Flask configuration: ```python import elasticapm @@ -36,19 +38,21 @@ app.config['ELASTIC_APM'] = { } ``` -More configuration settings can be found under the **Configuration** section for each language: -https://www.elastic.co/guide/en/apm/agent/index.html +More configuration settings can be found for each language in the following documentation page: [Install APM +agents][apm-agents]. ## Checking connectivity and importing default APM dashboards -From the Kibana Dashboard: - -1. `Add APM` button under _Add Data to Kibana_ section -2. Ignore all the install instructions and press `Check APM Server status` button. -3. Press `Check agent status` -4. Press `Load Kibana objects` to get the default dashboards -5. Lastly press the `APM dashboard` to the bottom right. +1. On the Kibana home page, click `Add APM` under the _Observability_ panel. +2. Click `Check APM Server status` to confirm the server is up and running. +3. Click `Check agent status` to verify your agent has registered properly. +4. Click `Load Kibana objects` to create an index pattern for APM. +5. Click `Launch APM` to be taken to the APM dashboard. ## See also -[Running APM Server on Docker](https://www.elastic.co/guide/en/apm/server/current/running-on-docker.html) +[Running APM Server on Docker][apm-docker] + + +[apm-agents]: https://www.elastic.co/guide/en/apm/get-started/current/agents.html +[apm-docker]: https://www.elastic.co/guide/en/apm/server/current/running-on-docker.html diff --git a/extensions/apm-server/apm-server-compose.yml b/extensions/apm-server/apm-server-compose.yml index 449bbd9..bd21a2d 100644 --- a/extensions/apm-server/apm-server-compose.yml +++ b/extensions/apm-server/apm-server-compose.yml @@ -6,10 +6,17 @@ services: context: extensions/apm-server/ args: ELK_VERSION: $ELK_VERSION + command: + # Disable strict permission checking on 'apm-server.yml' configuration file + # https://www.elastic.co/guide/en/beats/libbeat/current/config-file-permissions.html + - --strict.perms=false volumes: - - ./extensions/apm-server/config/apm-server.yml:/usr/share/apm-server/apm-server.yml:ro + - type: bind + source: ./extensions/apm-server/config/apm-server.yml + target: /usr/share/apm-server/apm-server.yml + read_only: true ports: - - "8200:8200" + - '8200:8200' networks: - elk depends_on: