-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from opstree/development
[Development][Add] Added ELK monitoring
- Loading branch information
Showing
18 changed files
with
290 additions
and
4 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,17 @@ | ||
FROM golang:latest AS build-env | ||
MAINTAINER Opstree Solutions | ||
WORKDIR /app | ||
ENV SRC_DIR=/go/src/gitlab.com/opstree/ot-go-webapp/ | ||
ADD . $SRC_DIR | ||
RUN cd $SRC_DIR; go get -v -t -d ./... && \ | ||
go build -o ot-go-webapp; cp ot-go-webapp /app/ | ||
|
||
FROM ubuntu:18.04 | ||
WORKDIR /app | ||
RUN apt-get update -y && \ | ||
apt-get install libc6 -y | ||
COPY --from=build-env /app/ot-go-webapp /app/ | ||
ADD https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.3.1-amd64.deb /opt/ | ||
RUN dpkg -i /opt/filebeat-7.3.1-amd64.deb \ | ||
&& service filebeat start | ||
ENTRYPOINT ["./ot-go-webapp"] |
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,34 @@ | ||
version: '3.3' | ||
services: | ||
redis: | ||
image: redis:latest | ||
restart: always | ||
expose: | ||
- 6379 | ||
|
||
mysql: | ||
image: mysql:5.6 | ||
restart: always | ||
environment: | ||
MYSQL_ROOT_PASSWORD: password | ||
MYSQL_DATABASE: employeedb | ||
expose: | ||
- 3306 | ||
|
||
ot-go-webapp: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
restart: always | ||
depends_on: | ||
- mysql | ||
- redis | ||
environment: | ||
DB_URL: mysql | ||
DB_PORT: 3306 | ||
DB_USER: root | ||
DB_PASSWORD: password | ||
REDIS_HOST: redis | ||
REDIS_PORT: 6379 | ||
ports: | ||
- 8080:8080 |
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,109 @@ | ||
|
||
version: '3.2' | ||
|
||
services: | ||
elasticsearch: | ||
build: | ||
context: elasticsearch/ | ||
args: | ||
ELK_VERSION: $ELK_VERSION | ||
volumes: | ||
- type: bind | ||
source: ./elasticsearch/elasticsearch.yml | ||
target: /usr/share/elasticsearch/config/elasticsearch.yml | ||
read_only: true | ||
- type: volume | ||
source: elasticsearch | ||
target: /usr/share/elasticsearch/data | ||
ports: | ||
- "9200:9200" | ||
- "9300:9300" | ||
environment: | ||
ES_JAVA_OPTS: "-Xmx256m -Xms256m" | ||
ELASTIC_PASSWORD: elastic | ||
networks: | ||
- elk | ||
|
||
logstash: | ||
build: | ||
context: logstash/ | ||
args: | ||
ELK_VERSION: $ELK_VERSION | ||
volumes: | ||
- type: bind | ||
source: ./logstash/logstash.yml | ||
target: /usr/share/logstash/config/logstash.yml | ||
read_only: true | ||
- type: bind | ||
source: ./logstash/conf.d | ||
target: /usr/share/logstash/pipeline | ||
read_only: true | ||
ports: | ||
- "5000:5000" | ||
- "5044:5044" | ||
- "9600:9600" | ||
environment: | ||
LS_JAVA_OPTS: "-Xmx256m -Xms256m" | ||
networks: | ||
- elk | ||
depends_on: | ||
- elasticsearch | ||
|
||
kibana: | ||
build: | ||
context: kibana/ | ||
args: | ||
ELK_VERSION: $ELK_VERSION | ||
volumes: | ||
- type: bind | ||
source: ./kibana/kibana.yml | ||
target: /usr/share/kibana/config/kibana.yml | ||
read_only: true | ||
ports: | ||
- "5601:5601" | ||
networks: | ||
- elk | ||
depends_on: | ||
- elasticsearch | ||
|
||
mysql: | ||
image: mysql:5.6 | ||
restart: always | ||
environment: | ||
MYSQL_ROOT_PASSWORD: password | ||
MYSQL_DATABASE: employeedb | ||
ports: | ||
- "3306:3306" | ||
networks: | ||
- elk | ||
|
||
ot-go-webapp: | ||
image: opstreedevops/ot-go-webapp:filebeat | ||
volumes: | ||
- type: bind | ||
source: ./ot-go-webapp/filebeat.yml | ||
target: /etc/filebeat/filebeat.yml | ||
read_only: true | ||
- type: bind | ||
source: ./ot-go-webapp/entrypoint.sh | ||
target: /app/entrypoint.sh | ||
ports: | ||
- "8080:8080" | ||
environment: | ||
DB_URL: mysql | ||
DB_PORT: 3306 | ||
DB_USER: root | ||
DB_PASSWORD: password | ||
entrypoint: | ||
- ./entrypoint.sh | ||
networks: | ||
- elk | ||
depends_on: | ||
- mysql | ||
|
||
networks: | ||
elk: | ||
driver: bridge | ||
|
||
volumes: | ||
elasticsearch: |
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,3 @@ | ||
ARG ELK_VERSION | ||
|
||
FROM docker.elastic.co/elasticsearch/elasticsearch:${ELK_VERSION} |
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 @@ | ||
--- | ||
cluster.name: "ot-go-webapp-elk" | ||
network.host: 0.0.0.0 | ||
|
||
discovery.type: single-node | ||
|
||
xpack.license.self_generated.type: trial | ||
xpack.security.enabled: true | ||
xpack.monitoring.collection.enabled: true |
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,3 @@ | ||
ARG ELK_VERSION | ||
|
||
FROM docker.elastic.co/kibana/kibana:${ELK_VERSION} |
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,7 @@ | ||
server.name: kibana | ||
server.host: "0" | ||
elasticsearch.hosts: [ "http://elasticsearch:9200" ] | ||
xpack.monitoring.ui.container.elasticsearch.enabled: true | ||
|
||
elasticsearch.username: elastic | ||
elasticsearch.password: elastic |
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,3 @@ | ||
ARG ELK_VERSION | ||
|
||
FROM docker.elastic.co/logstash/logstash:${ELK_VERSION} |
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,15 @@ | ||
input { | ||
beats { | ||
port => 5044 | ||
} | ||
} | ||
|
||
output { | ||
elasticsearch { | ||
hosts => ["http://elasticsearch:9200"] | ||
index => "ot-go-webapp-%{+YYYY.MM.dd}" | ||
user => "elastic" | ||
password => "elastic" | ||
} | ||
} | ||
|
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,5 @@ | ||
filter { | ||
json { | ||
source => "message" | ||
} | ||
} |
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,6 @@ | ||
http.host: "0.0.0.0" | ||
xpack.monitoring.elasticsearch.hosts: [ "http://elasticsearch:9200" ] | ||
|
||
xpack.monitoring.enabled: true | ||
xpack.monitoring.elasticsearch.username: elastic | ||
xpack.monitoring.elasticsearch.password: elastic |
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,16 @@ | ||
FROM golang:latest AS build-env | ||
MAINTAINER Opstree Solutions | ||
WORKDIR /app | ||
ENV SRC_DIR=/go/src/gitlab.com/opstree/ot-go-webapp/ | ||
ADD . $SRC_DIR | ||
RUN cd $SRC_DIR; go get -v -t -d ./... && \ | ||
go build -o ot-go-webapp; cp ot-go-webapp /app/ | ||
|
||
FROM ubuntu:18.04 | ||
WORKDIR /app | ||
RUN apt-get update -y && \ | ||
apt-get install libc6 -y | ||
COPY --from=build-env /app/ot-go-webapp /app/ | ||
ADD https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.3.1-amd64.deb /opt/ | ||
RUN dpkg -i /opt/filebeat-7.3.1-amd64.deb | ||
ENTRYPOINT ["./ot-go-webapp"] |
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,7 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
sleep 25 | ||
service filebeat start | ||
|
||
./ot-go-webapp |
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 @@ | ||
filebeat.inputs: | ||
|
||
- type: log | ||
enabled: true | ||
paths: | ||
- /var/log/ot-go-webapp.access.log | ||
- /var/log/ot-go-webapp.error.log | ||
fields: | ||
type: logs | ||
server: ot-go-webapp | ||
index_name: web | ||
fields_under_root: true | ||
|
||
filebeat.config.modules: | ||
path: ${path.config}/modules.d/*.yml | ||
reload.enabled: false | ||
|
||
setup.template.settings: | ||
index.number_of_shards: 1 | ||
|
||
#----------------------------- Logstash output -------------------------------- | ||
output.logstash: | ||
hosts: ["logstash:5044"] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.