Skip to content

Commit fed7b3a

Browse files
committed
2 parents a962ac4 + a91514a commit fed7b3a

70 files changed

Lines changed: 1018 additions & 149 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docker-compose.elk.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: '3.4'
2+
3+
services:
4+
5+
elasticsearch:
6+
build:
7+
context: elk/elasticsearch/
8+
volumes:
9+
- ./elk/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
10+
ports:
11+
- "9200:9200"
12+
- "9300:9300"
13+
environment:
14+
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
15+
16+
logstash:
17+
build:
18+
context: elk/logstash/
19+
volumes:
20+
- ./elk/logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml:ro
21+
- ./elk/logstash/pipeline:/usr/share/logstash/pipeline:ro
22+
ports:
23+
- "8080:8080"
24+
environment:
25+
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
26+
depends_on:
27+
- elasticsearch
28+
29+
kibana:
30+
build:
31+
context: elk/kibana/
32+
volumes:
33+
- ./elk/kibana/config/:/usr/share/kibana/config:ro
34+
ports:
35+
- "5601:5601"
36+
depends_on:
37+
- elasticsearch

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
version: '3.4'
22

33
services:
4+
45
seq:
56
image: datalust/seq:latest
67

elk/Readme.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
This article contains a brief introduction to centralized structured logging with [Serilog](https://serilog.net/) and event viewing with [ELK](https://www.elastic.co/elk-stack) in eShopOnContainers. ELK is an acronym of ElasticSearch, LogStash and Kibana. This is one of the most used tools in the industry standards.
2+
3+
![](img/elk/kibana-working.png)
4+
5+
## Wiring eshopOnContainers with ELK in Localhost
6+
7+
eshopOnContainers is ready for work with ELK, you only need to setup the configuration parameter **LogstashUrl**, in **Serilog** Section, for achieve this, you can do it modifing this parameter in every appsettings.json of every service, or via Environment Variable **Serilog:LogstashUrl**.
8+
9+
There is another option, a zero-configuration environment for testing the integration launching via ```docker-compose``` command, on the root directory of eshopOnContainers:
10+
11+
```sh
12+
docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.elk.yml build
13+
14+
docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.elk.yml up
15+
```
16+
17+
### Configuring Logstash index on Kibana
18+
19+
Once time you have started and configured your application, you only need to configure the logstash index on kibana.
20+
You can address to Kibana, with docker-compose setup is at [http://localhost:5601](http://localhost:5601)
21+
22+
If you have accessed to kibana too early, you can see this error. It's normal, depending of your machine the kibana stack needs a bit of time to startup.
23+
![](img/elk/kibana_startup.png)
24+
25+
You can wait a bit and refresh the page, the first time you enter, you need to configure and index pattern, in the ```docker-compose``` configuration, the index pattern name is **eshops-\***.
26+
![](img/elk/kibana_eshops_index.png)
27+
28+
With the index pattern configured, you can enter in the discover section and start viewing how the tool is recollecting the logging information.
29+
30+
![](img/elk/kibana_result.png)
31+
32+
## Configuring ELK on Azure VM
33+
Another option is to use a preconfigured virtual machine with Logstash, ElasticSearch and Kibana and point the configuration parameter **LogstashUrl**. For doing this you can address to Microsoft Azure, and start searching a Certified ELK Virtual Machine
34+
35+
![](img/elk/create-vm-elk-azure.png)
36+
37+
This options it have a certified preconfigured options (Network, VirtualMachine type, OS, RAM, Disks) for having a good starting point of ELK with good performance.
38+
39+
![](img/elk/create-vm-elk-azure-summary.png)
40+
41+
When you have configured the main aspects of your virtual machine, you will have a "review & create" last step like this:
42+
![](img/elk/create-vm-elk-azure-last-step.png)
43+
44+
### Configuring the bitnami environment
45+
46+
This virtual machine has a lot of configuration pipeing done. If you want to change something of the default configuration you can address this documentation:
47+
[https://docs.bitnami.com/virtual-machine/apps/elk/get-started/](https://docs.bitnami.com/virtual-machine/apps/elk/get-started/)
48+
49+
The only thing you have to change is the logstash configuration inside the machine. This configuration is at the file ```/opt/bitnami/logstash/conf/logstash.conf```
50+
You must edit the file and overwrite with this configuration:
51+
```conf
52+
input {
53+
http {
54+
#default host 0.0.0.0:8080
55+
codec => json
56+
}
57+
}
58+
59+
## Add your filters / logstash plugins configuration here
60+
filter {
61+
split {
62+
field => "events"
63+
target => "e"
64+
remove_field => "events"
65+
}
66+
}
67+
68+
output {
69+
elasticsearch {
70+
hosts => "elasticsearch:9200"
71+
index=>"eshops-%{+xxxx.ww}"
72+
}
73+
}
74+
```
75+
76+
For doing this you can connect via ssh to the vm and edit the file using the vi editor for example.
77+
When the file will be edited, check there are Inbound Port Rules created for the logstash service. You can do it going to Networking Menu on your ELK Virtual Machine Resource in Azure.
78+
79+
![](img/elk/azure-nsg-inboundportsConfig.png)
80+
81+
The only thing that remains is to connect to your vm vía browser. And check the bitnami splash page is showing.
82+
83+
![](img/elk/bitnami_splash.png)
84+
85+
You can get the password for accessing going to your virtual machine in azure and check the boot diagnostics, theres a message that shows to you which is your password.
86+
87+
When you have the user and password you can access to the kibana tool, and create the ```eshops-*``` index pattern that is well documented at the beggining of this documentation and then start to discover.
88+
![](img/elk/)

elk/elasticsearch/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# https://github.com/elastic/elasticsearch-docker
2+
FROM docker.elastic.co/elasticsearch/elasticsearch-oss:6.0.0
3+
4+
# Add your elasticsearch plugins setup here
5+
# Example: RUN elasticsearch-plugin install analysis-icu
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
## Default Elasticsearch configuration from elasticsearch-docker.
3+
## from https://github.com/elastic/elasticsearch-docker/blob/master/build/elasticsearch/elasticsearch.yml
4+
#
5+
cluster.name: "docker-cluster"
6+
network.host: 0.0.0.0
7+
8+
# minimum_master_nodes need to be explicitly set when bound on a public IP
9+
# set to 1 to allow single node clusters
10+
# Details: https://github.com/elastic/elasticsearch/pull/17288
11+
discovery.zen.minimum_master_nodes: 1
12+
13+
## Use single node discovery in order to disable production mode and avoid bootstrap checks
14+
## see https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html
15+
#
16+
discovery.type: single-node

elk/kibana/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# https://github.com/elastic/kibana-docker
2+
FROM docker.elastic.co/kibana/kibana-oss:6.0.0
3+
4+
# Add your kibana plugins setup here
5+
# Example: RUN kibana-plugin install <name|url>

elk/kibana/config/kibana.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
## Default Kibana configuration from kibana-docker.
3+
## from https://github.com/elastic/kibana-docker/blob/master/build/kibana/config/kibana.yml
4+
#
5+
server.name: kibana
6+
server.host: "0"
7+
elasticsearch.url: http://elasticsearch:9200

elk/logstash/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# https://github.com/elastic/logstash-docker
2+
FROM docker.elastic.co/logstash/logstash-oss:6.0.0
3+
4+
# Add your logstash plugins setup here
5+
# Example: RUN logstash-plugin install logstash-filter-json
6+
RUN logstash-plugin install logstash-input-http

elk/logstash/config/logstash.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
## Default Logstash configuration from logstash-docker.
3+
## from https://github.com/elastic/logstash-docker/blob/master/build/logstash/config/logstash-oss.yml
4+
#
5+
http.host: "0.0.0.0"
6+
path.config: /usr/share/logstash/pipeline
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
input {
2+
http {
3+
#default host 0.0.0.0:8080
4+
codec => json
5+
}
6+
}
7+
8+
## Add your filters / logstash plugins configuration here
9+
filter {
10+
split {
11+
field => "events"
12+
target => "e"
13+
remove_field => "events"
14+
}
15+
}
16+
17+
output {
18+
elasticsearch {
19+
hosts => "elasticsearch:9200"
20+
index=>"eshops-%{+xxxx.ww}"
21+
}
22+
}

0 commit comments

Comments
 (0)