Skip to content

Commit 84059ba

Browse files
better docs and Dockerfile
1 parent 9c5a19d commit 84059ba

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

packages/kong-plugin/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM kong/kong-gateway:3.7
2+
# Ensure any patching steps are executed as root user
3+
USER root
4+
5+
# Add custom plugin to the image
6+
COPY ./kong/plugins/readme-plugin /usr/local/share/lua/5.1/kong/plugins/readme-plugin
7+
ENV KONG_PLUGINS=bundled,readme-plugin
8+
9+
# Ensure kong user is selected for image execution
10+
USER kong
11+
12+
# Run kong
13+
ENTRYPOINT ["/entrypoint.sh"]
14+
EXPOSE 8000 8443 8001 8444
15+
STOPSIGNAL SIGQUIT
16+
HEALTHCHECK --interval=10s --timeout=10s --retries=10 CMD kong health
17+
CMD ["kong", "docker-start"]

packages/kong-plugin/README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@
1010

1111
With [ReadMe's Metrics API](https://readme.com/metrics) your team can get deep insights into your API's usage. If you're a developer, it takes a few small steps to send your API logs to [ReadMe](http://readme.com). Here's an overview of how the integration works:
1212

13-
- You add the Cloudflare Worker to your Cloudflare account
14-
- The Cloudflare Worker sends ReadMe the details of your API's incoming requests and outgoing responses, with the option for you to redact any private parameters or headers.
13+
- Install this plugin in Kong. You can the provided docker image or copy the plugin into your own Kong image.
14+
- The plugin sends ReadMe the details of your API's incoming requests and outgoing responses, with the option for you to redact any private headers using the configuration options.
1515
- ReadMe uses these request and response details to create an API Metrics Dashboard which can be used to analyze specific API calls or monitor aggregate usage data.
1616

17-
**For information on how to set it up, check out our [integration documentation](https://docs.readme.com/docs/sending-logs-to-readme-with-cloudflare).**
17+
### Deploying locally
18+
19+
```bash
20+
docker build -t kong-readme-plugin:1 .
21+
curl -Ls https://get.konghq.com/quickstart | bash -s -- -r "" -i kong-readme-plugin -t 1
22+
curl -i -s -X POST http://localhost:8001/plugins --data name=readme-plugin --data 'config.api_key=<Your API Key>'
23+
# setup endpoints or test
24+
curl -i http://localhost:8000/mock/anything
25+
```
1826

1927
### testing
2028
```bash
@@ -34,7 +42,7 @@ curl -i -s -X POST http://localhost:8001/plugins --data name=readme-plugin --dat
3442
# add a new service
3543
curl -i -s -X POST http://localhost:8001/services --data name=example_service --data url='http://httpbin.org'
3644
# Associate the custom plugin with the example_service service
37-
curl -is -X POST http://localhost:8001/services/example_service/plugins --data 'name=readme-plugin' -d "config.queue.max_retry_time=1"
45+
curl -is -X POST http://localhost:8001/services/example_service/plugins --data 'name=readme-plugin' -d "config.queue.max_retry_time=1"
3846
# Add a new route for sending requests through the example_service
3947
curl -i -X POST http://localhost:8001/services/example_service/routes --data 'paths[]=/mock' --data name=example_route
4048
# test
@@ -44,7 +52,7 @@ curl -i http://localhost:8000/mock/anything
4452
### Development tricks
4553
Get plugin config for a route
4654
```bash
47-
curl http://localhost:8001/plugins | jq '.data | map(select(.name == "readme-plugin")) | first'
55+
curl -s http://localhost:8001/plugins | jq '.data | map(select(.name == "readme-plugin")) | first'
4856
```
4957

5058
```bash

packages/kong-plugin/kong/plugins/readme-plugin/handler.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ local Queue = require "kong.tools.queue"
22
local cjson = require "cjson"
33
local url = require "socket.url"
44
local http = require "resty.http"
5-
local kong_meta = require "kong.meta"
6-
75

86
local kong = kong
97
local ngx = ngx
@@ -219,7 +217,7 @@ end
219217

220218
local HttpLogHandler = {
221219
PRIORITY = 12,
222-
VERSION = kong_meta.version,
220+
VERSION = "0.0.1",
223221
}
224222

225223
function HttpLogHandler:log(conf)

0 commit comments

Comments
 (0)