Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit 437b9f5

Browse files
author
Chris Wiechmann
authored
Some typos fixed and added a troubleshooting section
1 parent ef95bb3 commit 437b9f5

File tree

1 file changed

+94
-12
lines changed

1 file changed

+94
-12
lines changed

README.md

Lines changed: 94 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# API-Management Traffic-Monitor based ELK stack
22

3-
When having many API-Gateway instances with millions of requests the API-Gateway Traffic Monitor can become slow. The purpose of this project is to solve that performance issue and get other benefits by using a standard external datastore: Elasticsearch.
3+
When having many API-Gateway instances with millions of requests the API-Gateway Traffic Monitor can become slow and the observation period quite short. The purpose of this project is to solve that performance issue, make it possible to observe a long time-frame and get other benefits by using a standard external datastore: [Elasticsearch](https://www.elastic.co/elasticsearch).
44

55
The overall architecture this project provides looks like this:
66
![Architecture][img1]
77

8+
This also makes it possible to collect data from API-Gateways running all over the world into a centralized Elasticsearch instance to have it available with the best possible performance independing from the network performance.
9+
It also helps, when running the Axway API-Gateway in Docker-Orchestration-Environment where containers are started and stopped as it avoids to loose data, when an API-Gateway container is stopped.
10+
811
### How it works
9-
Each API-Gateway instance is writing, [if configured](#enable-open-traffic-event-log), Open-Traffic Event-Log-Files, which are streamed by [Filebeat](https://www.elastic.co/beats/filebeat) into a Logstash-Instance. [Logstash](https://www.elastic.co/logstash) performs data pre-processing, combines different events and finally forwards the document into an [Elasticsearch](https://www.elastic.co/elasticsearch) cluster.
12+
Each API-Gateway instance is writing, [if configured](#enable-open-traffic-event-log), Open-Traffic Event-Log-Files, which are streamed by [Filebeat](https://www.elastic.co/beats/filebeat) into a Logstash-Instance. [Logstash](https://www.elastic.co/logstash) performs data pre-processing, combines different events and finally forwards these so called documents into an Elasticsearch cluster.
1013

1114
Once the data is indexed by Elasticsearch it can be used by different clients. This process allows almost realtime monitoring of incoming requests. It takes around 5 seconds until a request is available in Elasticsearch.
1215

@@ -19,7 +22,7 @@ API-Builder exposing Traffic-Monitor API:
1922
![Traffic-Monitor API](https://github.com/Axway-API-Management-Plus/apigateway-openlogging-elk/workflows/Test%20Traffic-Monitor%20API/badge.svg)
2023

2124
## Option 2 - Loginspector
22-
The Loginspector is a new separated user-interface with very basic set of functionilties. As part of the project the Loginspector is activated by default when using `docker-compose up -d`. If you don't wanna use it, it can be disabled by commenting out the following lines in the docker-compose.yml file:
25+
The Loginspector is a new separated user-interface with very basic set of functionalities. As part of the project the Loginspector is activated by default when using `docker-compose up -d`. If you don't wanna use it, it can be disabled by commenting out the following lines in the docker-compose.yml file:
2326
```yaml
2427
nginx:
2528
image: nginx:1.17.6
@@ -36,34 +39,34 @@ The Loginspector is a new separated user-interface with very basic set of functi
3639
```
3740
The Log-Inspector is accessible on the following URL: `http://hostname-to-your-docker-machine:8888/logspector.html`
3841

39-
![Log-Spector][img5]
42+
![Log-Inspector][img5]
4043

4144

4245
## Prerequisites
4346
For a simple deployment the prerequisites are very simple as all services can be started as a Docker-Container. In order to start all components in PoC-Like-Mode you just need:
4447

4548
1. A Docker engine
46-
2. docker-compose installed
49+
2. Docker-compose
4750
3. An API-Management Version >7.7-20200130
48-
- Versin 7.7-20200130 is required due to some Dateform changes in the Open-Traffic-Format. With older versions of the API-Gateway you will get an error in Logstash processing.
51+
- Versin 7.7-20200130 is required due to some Dateformat changes in the Open-Traffic-Format. With older versions of the API-Gateway you will get an error in Logstash processing.
4952

50-
Using the provided docker-compose is good to play with, however this approach is not recommended for production environments. Depending the load a dedicated machine (node) for Elasticsearch is recommended. The default configuration is prepared to scale up to five Elasticsearch nodes, which can handle millions of requests. To run Logstash and the API-Builder service a Docker-Orchestration framework is recommended as you get monitoring, self-healing, elasticity.
53+
Using the provided docker-compose is good to play with, however this approach is not recommended for production environments. Depending on the load, a dedicated machine (node) for Elasticsearch is recommended. The default configuration is prepared to scale up to five Elasticsearch nodes, which can handle millions of requests. To run Logstash and the API-Builder service a Docker-Orchestration framework is recommended as you get monitoring, self-healing, elasticity and more.
5154

5255
## Installation / Configuration
53-
To run the components in a PoC-Like mode, the recommended way is to clone this project onto a machine having docker and docker-compose installed. Also this machine must have file-based access to the running API-Gateway instance, as the Filebeat docker container will mount the open-traffic folder into the docker-container.
56+
To run the components in a PoC-Like mode, the recommended way is to clone this project onto a machine having docker and docker-compose installed. Also this machine must have file-based access to the running API-Gateway instance, as the Filebeat docker container will mount the open-traffic folder into the container.
5457

5558
`git clone https://github.com/Axway-API-Management-Plus/apigateway-openlogging-elk.git`
5659

5760
This creates a local copy of the repository and you can start from there.
5861

5962
### Enable Open-Traffic Event Log
6063
Obviously you have to enable Open-Traffic-Event log for your API-Gateway instances. [Read here][1] how to enable the Open-Traffic Event-Log.
61-
After this configuration has been done, Open-Traffic log-files will created by default in this location: `apigateway/logs/opentraffic`. This location becomes relevant in the next step, when configuring Filebeat.
64+
After this configuration has been done, Open-Traffic log-files will created by default in this location: `apigateway/logs/opentraffic`. This location becomes relevant when configuring Filebeat.
6265

6366
### Configure the Admin-Node-Manager
64-
This step is required if you would like to use the existing Traffic-Monitor in combination Elasticsearch.
65-
The Admin-Node-Manager (listening by default on port 8090) is responsible to server the API-Manager Traffic-Monitor and needs to be configured to use the API-Builder API instead.
66-
For the following steps, please open the Admin-Node-Manager configuration in Policy-Studio. You can [here](https://docs.axway.com/bundle/axway-open-docs/page/docs/apim_administration/apigtw_admin/general_rbac_ad_ldap/index.html#use-the-ldap-policy-to-protect-management-services) how to do that.
67+
This step is required if you would like to use the existing API-Gateway Manager Traffic-Monitor in combination Elasticsearch.
68+
The Admin-Node-Manager (listening by default on port 8090) is responsible to serve the Traffic-Monitor and needs to be configured to use the API-Builder REST-API instead.
69+
For the following steps, please open the Admin-Node-Manager configuration in Policy-Studio. You can read [here](https://docs.axway.com/bundle/axway-open-docs/page/docs/apim_administration/apigtw_admin/general_rbac_ad_ldap/index.html#use-the-ldap-policy-to-protect-management-services) how to do that.
6770
- Create a new policy called: `Use Elasticsearch API`
6871
- Configure this policy like so:
6972
![use ES API][img3]
@@ -110,6 +113,85 @@ Of course, the components can also run on different machines or on a Docker-Orch
110113
docker-compose down
111114
````
112115
116+
## Troubleshooting
117+
#### Check processes/containers are running
118+
From with the folder where the docker-compose.yml file is located run
119+
```
120+
docker-compose inspect
121+
Name Command State Ports
122+
------------------------------------------------------------------------------------------------------------------------------------------------------------------
123+
apigateway-openlogging-elk_elk-traffic-monitor-api_1_3fbba4deea37 docker-entrypoint.sh node . Up (healthy) 0.0.0.0:8889->8080/tcp
124+
apigateway-openlogging-elk_filebeat_1_3ad3117a1312 /usr/local/bin/docker-entr ... Up 0.0.0.0:9000->9000/tcp
125+
apigateway-openlogging-elk_logstash_1_c6227859a9a4 /usr/local/bin/docker-entr ... Up 0.0.0.0:5044->5044/tcp, 9600/tcp
126+
elasticsearch1 /usr/local/bin/docker-entr ... Up 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp
127+
```
128+
Depending on the services you enabled/disbaled you see the status.
129+
130+
#### Check Filebeat is picking up data
131+
You need to check the filebeat Log-File within the running docker container.
132+
`docker exec -it apigateway-openlogging-elk_filebeat_1_3ad3117a1312 bash`
133+
`cd logs`
134+
`tail -f filebeat`
135+
Make sure, the Filebeat Harvester is started on the Open-Traffic-Files:
136+
```
137+
INFO log/harvester.go:251 Harvester started for file: /var/log/work/group-2_instance-1_traffic.log
138+
```
139+
The following error means, Logstash is not running or reachable:
140+
```
141+
ERROR pipeline/output.go:100 Failed to connect to backoff(async(tcp://logstash:5044)): lookup logstash on 127.0.0.11:53: no such host
142+
```
143+
General note: You don't see Filebeat telling you, when it is successfully processing your log-files. When the Harvester process is started and you don't see any errors, you can assume your files are processed.
144+
145+
#### Check Logstash processing
146+
Logstash write to Stdout, hence you can view information just with:
147+
```
148+
docker logs apigateway-openlogging-elk_logstash_1_c6227859a9a4 --follow
149+
```
150+
When Logstash is successfully started you shoudl see the following:
151+
```
152+
[INFO ][logstash.javapipeline ] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>1, "pipeline.batch.size"=>20, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>20, :thread=>"#<Thread:0x7d34e839 run>"}
153+
[INFO ][logstash.inputs.beats ] Beats inputs: Starting input listener {:address=>"0.0.0.0:5044"}
154+
[INFO ][logstash.javapipeline ] Pipeline started {"pipeline.id"=>"main"}
155+
[INFO ][org.logstash.beats.Server] Starting server on port: 5044
156+
[INFO ][logstash.agent ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
157+
...
158+
......
159+
...
160+
[INFO ][logstash.outputs.elasticsearch] Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[http://elasticsearch1:9200/]}}
161+
[INFO ][logstash.outputs.elasticsearch] ES Output version determined {:es_version=>7}
162+
[INFO ][logstash.outputs.elasticsearch] New Elasticsearch output {:class=>"LogStash::Outputs::ElasticSearch", :hosts=>["//elasticsearch1:9200"]}
163+
[INFO ][logstash.javapipeline ] Starting pipeline {:pipeline_id=>".monitoring-logstash", "pipeline.workers"=>1, "pipeline.batch.size"=>2, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>2, :thread=>"#<Thread:0x147f9919 run>"}
164+
[INFO ][logstash.javapipeline ] Pipeline started {"pipeline.id"=>".monitoring-logstash"}
165+
[INFO ][logstash.agent ] Pipelines running {:count=>2, :running_pipelines=>[:main, :".monitoring-logstash"], :non_running_pipelines=>[]}
166+
[INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
167+
```
168+
Once, Logstash is successfully processing data you see them flying by in the log output.
169+
170+
#### Check Elasticsearch processing
171+
It takes a while until Elasticsearch is finally started and reports it with the following line:
172+
```
173+
docker logs elasticsearch1 --follow
174+
```
175+
When Elasticsearch is finally started:
176+
```
177+
"level": "INFO", "component": "o.e.c.r.a.AllocationService", "cluster.name": "elasticsearch", "node.name": "elasticsearch1", "message": "Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[.kibana_1][0]]]).", "cluster.uuid": "k22kMiq4R12I7BSTD87n5Q", "node.id": "6TVkdA-YR7epgV39dZNG2g" }
178+
```
179+
Status Yellow is expected when running Elasticsearch on a single node, as it can achieve the desired replicas. You may use Kibana Development tools or curl to get additional information.
180+
181+
#### Check API-Builder processing
182+
The API-Builder docker container is running
183+
```
184+
docker logs apigateway-openlogging-elk_elk-traffic-monitor-api_1_3fbba4deea37 --follow
185+
```
186+
```
187+
server started on port 8080
188+
```
189+
When using the API-Gateway Traffic-Monitor and having the Admin-Node-Manager re-configured you see how API-Builder is processing the requests:
190+
```
191+
Request {"method":"GET","url":"/api/elk/v1/api/router/service/instance-1/ops/search?format=json&field=leg&value=0&count=1000&ago=10m&protocol=http","headers":{"host":"localhost:8889","max-forwards":"20","via":"1.0 api-env (Gateway)","accept":"application/json","accept-language":"en-US,en;q=0.5","cookie":"cookie_pressed_153=false; t3-admin-tour-firstshow=1; VIDUSR=1584691147-TE1M3vI9BFWgkA%3d%3d; layout_type=table; portal.logintypesso=false; portal.demo=off; portal.isgridSortIgnoreCase=on; 6e7e1bb1dd446d4cd36889414ccb4cb7=8g9p3kh27t1se22lu6avkmu0a1; joomla_user_state=logged_in; 220b750abfbc8d2f2f878161bab0ab65=62gr71dkre858nc0gjldri18gt","csrf-token":"8E96374767C47BFADC9C606FF969D7CF56FB3F9523E41B34F3B3B269F7302646","referer":"https://api-env:8090/","user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0","x-requested-with":"XMLHttpRequest","connection":"close","x-correlationid":"Id-fd7c745ebfaed039b2155481 1"},"remoteAddress":"::ffff:172.25.0.1","remotePort":55916}
192+
Response {"statusCode":200,"headers":{"server":"API Builder/4.25.0","request-id":"35fb859d-00b0-404b-97e6-b549db17f84c","x-xss-protection":"1; mode=block","x-frame-options":"DENY","surrogate-control":"no-store","cache-control":"no-store, no-cache, must-revalidate, proxy-revalidate","pragma":"no-cache","expires":"0","x-content-type-options":"nosniff","start-time":"1584692477587","content-type":"application/json; charset=utf-8","response-time":"408","content-md5":"e306ea2d930a3b80f0e91a29131d520b","content-length":"267","etag":"W/\"10b-2N+JsHuxDxMVKhJR1A8GuNGnKDQ\"","vary":"Accept-Encoding"}}
193+
```
194+
113195
[img1]: imgs/component-overview.png
114196
[img2]: imgs/node-manager-policies.png
115197
[img3]: imgs/node-manager-use-es-api.png

0 commit comments

Comments
 (0)