-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: local Elastic Stack setup (#23)
- Loading branch information
Showing
14 changed files
with
420 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Version of Elastic products | ||
ELASTIC_STACK_VERSION=8.16.1 | ||
|
||
# Set to 'basic' or 'trial' to automatically start the 30-day trial | ||
ELASTIC_LICENSE=basic | ||
|
||
# SAMPLE Predefined Key only to be used in POC environments | ||
ELASTIC_ENCRYPTION_KEY=c34d38b3a14956121ff2170e5030b471551370178f43e5626eec58b04a30fae2 | ||
|
||
# Set the cluster name | ||
ELASTIC_CLUSTER=eslocal | ||
|
||
# Increase or decrease based on the available host memory (in bytes) | ||
ELASTIC_MEM_LIMIT=2147483648 | ||
|
||
# Password for the 'elastic' user (at least 6 characters) | ||
ELASTIC_PASSWORD=elastic | ||
|
||
# Password for the 'kibana_system' user (at least 6 characters) | ||
KIBANA_PASSWORD=kibana | ||
|
||
# Increase or decrease based on the available host memory (in bytes) | ||
KIBANA_MEM_LIMIT=1073741824 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
instances: | ||
- name: es01 | ||
dns: | ||
- es01 | ||
- localhost | ||
ip: | ||
- 127.0.0.1 | ||
- name: kibana | ||
dns: | ||
- kibana | ||
- localhost | ||
ip: | ||
- 127.0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
if [ x${ELASTIC_PASSWORD} == x ]; then | ||
echo "Set the ELASTIC_PASSWORD environment variable in the .env file"; | ||
exit 1; | ||
elif [ x${KIBANA_PASSWORD} == x ]; then | ||
echo "Set the KIBANA_PASSWORD environment variable in the .env file"; | ||
exit 1; | ||
fi; | ||
|
||
if [ ! -f config/certs/ca.zip ]; then | ||
echo "Creating CA"; | ||
bin/elasticsearch-certutil ca --silent --pem -out config/certs/ca.zip; | ||
unzip config/certs/ca.zip -d config/certs; | ||
fi; | ||
|
||
if [ ! -f config/certs/certs.zip ]; then | ||
echo "Creating certs"; | ||
cp /.local/config/instances.yml config/certs/instances.yml; | ||
bin/elasticsearch-certutil cert --silent --pem \ | ||
-out config/certs/certs.zip \ | ||
--in config/certs/instances.yml \ | ||
--ca-cert config/certs/ca/ca.crt \ | ||
--ca-key config/certs/ca/ca.key; | ||
unzip config/certs/certs.zip -d config/certs; | ||
fi; | ||
|
||
echo "Setting file permissions" | ||
chown -R root:root config/certs; | ||
|
||
find . -type d -exec chmod 755 \{\} \;; | ||
find . -type f -exec chmod 644 \{\} \;; | ||
|
||
TIMEOUT=10 | ||
|
||
until | ||
echo "Waiting for Elasticsearch availability (sleeping for ${TIMEOUT}s)"; | ||
curl -s --cacert config/certs/ca/ca.crt https://es01:9200 | grep -q "missing authentication credentials"; | ||
do sleep $TIMEOUT; done; | ||
|
||
until | ||
echo "Setting kibana_system password (sleeping for ${TIMEOUT}s)"; | ||
curl -s -X POST \ | ||
--cacert config/certs/ca/ca.crt \ | ||
-u "elastic:${ELASTIC_PASSWORD}" \ | ||
-H "Content-Type: application/json" https://es01:9200/_security/user/kibana_system/_password \ | ||
-d "{\"password\":\"${KIBANA_PASSWORD}\"}" | grep -q "^{}"; | ||
do sleep $TIMEOUT; done; | ||
|
||
echo "All done!"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ARG ELASTIC_STACK_VERSION=8.16.1 | ||
|
||
FROM docker.elastic.co/beats/filebeat:${ELASTIC_STACK_VERSION} | ||
|
||
USER root | ||
|
||
COPY ./elasticstack/filebeat01/filebeat.yml filebeat.yml | ||
|
||
RUN chmod go-w filebeat.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
filebeat.autodiscover: | ||
providers: | ||
- type: docker | ||
hints.enabled: true | ||
hints.default_config: | ||
type: container | ||
paths: | ||
- /var/lib/docker/containers/${data.container.id}/*.log | ||
|
||
processors: | ||
- add_docker_metadata: ~ | ||
|
||
setup.kibana: | ||
host: ${KIBANA_HOSTS} | ||
username: ${ELASTIC_USER} | ||
password: ${ELASTIC_PASSWORD} | ||
|
||
output.elasticsearch: | ||
hosts: ${ELASTIC_HOSTS} | ||
username: ${ELASTIC_USER} | ||
password: ${ELASTIC_PASSWORD} | ||
ssl: | ||
enabled: true | ||
certificate_authorities: certs/ca/ca.crt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
server.host: "0.0.0.0" | ||
telemetry.optIn: "false" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ARG ELASTIC_STACK_VERSION=8.16.1 | ||
|
||
FROM docker.elastic.co/logstash/logstash:${ELASTIC_STACK_VERSION} | ||
|
||
USER root | ||
|
||
COPY ./elasticstack/logstash01/logstash.conf pipeline/logstash.conf | ||
|
||
RUN chmod go-w pipeline/logstash.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
input { | ||
file { | ||
# https://www.elastic.co/guide/en/logstash/current/plugins-inputs-file.html | ||
mode => "read" | ||
path => "/tmp/logstash01/*.log" | ||
} | ||
} | ||
|
||
filter { | ||
} | ||
|
||
output { | ||
elasticsearch { | ||
index => "logstash-%{+YYYY.MM.dd}" | ||
hosts=> "${ELASTIC_HOSTS}" | ||
user=> "${ELASTIC_USER}" | ||
password=> "${ELASTIC_PASSWORD}" | ||
ssl_certificate_authorities=> "certs/ca/ca.crt" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ARG ELASTIC_STACK_VERSION=8.16.1 | ||
|
||
FROM docker.elastic.co/beats/metricbeat:${ELASTIC_STACK_VERSION} | ||
|
||
USER root | ||
|
||
COPY ./elasticstack/metricbeat01/metricbeat.yml metricbeat.yml | ||
|
||
RUN chmod go-w metricbeat.yml |
Oops, something went wrong.