-
Notifications
You must be signed in to change notification settings - Fork 159
Description
Draft tutorial from @danielkhan:
Developer Setup Docker local
[Intro … E.g. Elastic observability is free and open, can be installed locally, supports many languages and OpenTelemetry. […]
This documentation shows how to get started with Elastic Observability in 5 minutes. […]]
Install Get Docker | Docker Documentation and Install Docker Compose | Docker Documentation .
Please make sure to dedicate
[Alternatively to the instructions provided here, could we also provide some artefact on e.g. GitHub to simply clone?]
Create a directoryelastic-observability
somewhere on your system.
In this directory, create a filedocker/compose.yml
with this content:
version: '2.2'
services:
elasticsearch:
container_name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION}
environment:
- bootstrap.memory_lock=true
- cluster.name=docker-cluster
- cluster.routing.allocation.disk.threshold_enabled=false
- discovery.type=single-node
- xpack.security.enabled=true
- xpack.security.authc.api_key.enabled=true
- ES_JAVA_OPTS=-Xms750m -Xmx750m
ulimits:
memlock:
hard: -1
soft: -1
volumes:
- esdata:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- esnet
healthcheck:
interval: 20s
retries: 10
test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"'
kibana:
container_name: kibana
image: docker.elastic.co/kibana/kibana:${VERSION}
depends_on:
elasticsearch:
condition: service_healthy
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
- ELASTICSEARCH_USERNAME=kibana_system
- ELASTICSEARCH_PASSWORD=${ELASTICSEARCH_KIBANA_PASSWORD}
ports:
- 5601:5601
networks:
- esnet
healthcheck:
interval: 10s
retries: 20
test: curl -u ‘kibana_system:${ELASTICSEARCH_KIBANA_PASSWORD}’ —write-out ‘HTTP %{http_code}’ —fail —silent —output /dev/null http://localhost:5601/api/status
apm-server:
image: docker.elastic.co/apm/apm-server:${VERSION}
depends_on:
elasticsearch:
condition: service_healthy
kibana:
condition: service_healthy
cap_add: [“CHOWN”, “DAC_OVERRIDE”, “SETGID”, “SETUID”]
cap_drop: [“ALL”]
ports:
- 8200:8200
networks:
- esnet
command: >
apm-server -e
-E apm-server.rum.enabled=true
-E setup.kibana.host=kibana:5601
-E apm-server.kibana.username=elastic
-E apm-server.kibana.password=${ELASTICSEARCH_PASSWORD}
-E setup.template.settings.index.number_of_replicas=0
-E apm-server.kibana.enabled=true
-E apm-server.kibana.host=kibana:5601
-E output.elasticsearch.hosts=[“elasticsearch:9200”]
-E output.elasticsearch.username=“elastic”
-E output.elasticsearch.password=${ELASTICSEARCH_PASSWORD}
healthcheck:
interval: 10s
retries: 12
test: curl —write-out ‘HTTP %{http_code}’ —fail —silent —output /dev/null http://localhost:8200/
volumes:
esdata:
name: esdata
driver: local
networks:
esnet:
name: esnet
driver: bridge
Additionally, create a file .env
that will hold your configuration:
VERSION=7.16.0-SNAPSHOT // Needs to change depending on the doc page viewed
ELASTICSEARCH_KIBANA_PASSWORD=
ELASTICSEARCH_PASSWORD=
ATTENTION: When using Git, please make sure to add .env
to your .gitignore
file to not accidentally push credentials to GitHub.
Now in this directory, run docker compose up elasticsearch
to download and start Elasticsearch.
Once Elasticsearch is running , run docker exec elasticsearch /bin/bash -c ‘bin/elasticsearch-setup-passwords auto —batch —url http://elasticsearch:9200'
This will create and store a set of passwords in Elastic.
Store the output of this command at a safe place.
Open your .env
file and fill copy the password for thekibana_system
and elastic
user to their respective config variables:
VERSION=7.16.0-SNAPSHOT
ELASTICSEARCH_KIBANA_PASSWORD=<Generated password for user kibana_system>
ELASTICSEARCH_PASSWORD=<Generated password for user elastic>
Now stop docker and run it again using docker compose up
(without elasticsearch
).
This will start Elasticsearch, Kibana and the APM Server.
Please wait until bloglines for app-server
show up on the console output.
Please ignore lines, that indicate an authentication error.
[I’m getting this - currently trying to figure out what it is - does not have an impact]]
elasticsearch | {"type": "server", "timestamp": "2021-11-25T12:26:05,969Z", "level": "INFO", "component": "o.e.x.s.a.RealmsAuthenticator", "cluster.name": "docker-cluster", "node.name": "8d05684f22de", "message": "Authentication of [elastic] was terminated by realm [reserved] - failed to authenticate user [elastic]", "cluster.uuid": "BOGGeCrEQz-1vLjiII1NBQ", "node.id": "isSa2LI4Sa2mwmXxa63y1A"
Now navigate to http://localhost:5601 in your browser and log in with the usernameelastic
and the password you generated before.
Click on the Observability tile and follow the instructions on screen to set up APM.
[In my tests, I saw that the Docker default memory setting wasn’t enough on my Silicon MBP and the Elastic server crashed with Error 137.
Can we verify and propose safe memory limits? ]