Skip to content

Commit

Permalink
Merge branch 'feature/example' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
trend-andy-pan committed Sep 27, 2019
2 parents 7b64a80 + 5156a78 commit 54aae90
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 76 deletions.
17 changes: 17 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,20 @@ PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

# E.L.K. setting
ELK_VERSION=6.4.0

# Elasticsearch
ES_HOST=example-elasticsearch
ES_PORT1=9200
ES_PORT2=9300

# Logstash
LS_HOST=example-logstash
LS_PORT1=5000
LS_PORT2=9600

# Kibana
KB_HOST=example-kibana
KB_PORT=5601
2 changes: 1 addition & 1 deletion ELK/logstash/pipeline/logstash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ input {

file {
type => "inputFile"
path => "/home/inputFile/log-*"
path => "/home/inputFile/*.log"
start_position => "beginning"
}
}
Expand Down
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,54 @@ E.L.K. example for PHP laravel via docker.

## 如何使用

1. 安裝 Docker

[官方安裝文件](https://docs.docker.com/install/)

## 指令說明
2. 產生 環境變數
```bash
$ cp .env.example .env
```

3. 啟動
```bash
$ make dev
```

## 相關範例
3. 安裝 PHP 相關套件
```bash
$ make install
```

4. 等待 E.L.K. 相關環境執行完畢 (約 1 ~ 5 分鐘)

5. 進入 Kibana 查看網站是否正常執行 <br>
`http://127.0.0.1:{KB_PORT}/`

KB_PORT 預設值: 5601

6. `Management` 分頁 找到 Kibana `Index Patterns` 連結

![image](https://github.com/andykuen/Docker-ELKonLaravel/blob/master/assets/images/kibana_01.png)

7. 設定 E.L.K. index 資訊

![image](https://github.com/andykuen/Docker-ELKonLaravel/blob/master/assets/images/kibana_02.png)

![image](https://github.com/andykuen/Docker-ELKonLaravel/blob/master/assets/images/kibana_03.png)

8. `Discover` 分頁 即可看到相關資訊。

![image](https://github.com/andykuen/Docker-ELKonLaravel/blob/master/assets/images/kibana_04.png)

## 新增一筆資料

### URL
[`POST`] `http://127.0.0.1:{APP_PORT}/api/log`

### BODY (application/json)
```JSON
{
"msg": "你想要的內容"
}
```
13 changes: 13 additions & 0 deletions app/Http/Controllers/ExampleController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ExampleController extends Controller
{
function createLog(Request $request){
\Log::info($request->input('msg', null));
return response('OK', 200);
}
}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
volumes:
- ./ELK/logstash/pipeline:/usr/share/logstash/pipeline:ro
- ./ELK/logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml:ro
- ./ELK/logstash/inputFile/:/home/inputFile
- ./storage/logs/:/home/inputFile
networks:
- LAN

Expand Down
Binary file added images/kibana_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/kibana_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/kibana_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/kibana_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ del: .docker-down

.docker-down:
docker-compose down

install:
docker exec -it ${APP_NAME} composer install
72 changes: 0 additions & 72 deletions readme 拷貝.md

This file was deleted.

2 changes: 2 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});

Route::post('/log', 'ExampleController@createLog');
1 change: 1 addition & 0 deletions storage/logs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*
!.gitignore
!laravel-2019-09-27.log
1 change: 1 addition & 0 deletions storage/logs/laravel-2019-09-27.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[2019-09-27 04:50:37] local.INFO: Hello Word

0 comments on commit 54aae90

Please sign in to comment.