Skip to content

Commit

Permalink
Moesif PR (#4008)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guaris authored Jun 10, 2022
1 parent e3cd859 commit a3fba71
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 30 deletions.
1 change: 1 addition & 0 deletions .github/styles/kong/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ lua
Luarocks
minikube
Mockbin
Moesif
MongoDB
namespace
namespaces
Expand Down
116 changes: 86 additions & 30 deletions app/_hub/moesif/kong-plugin-moesif/_index.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
---
name: Moesif API Analytics
publisher: Moesif
version: 1.x.x

categories:
- analytics-monitoring
- logging

type: plugin

desc: User Behavior API analytics and observability
desc: Powerful API analytics and tools to activate, understand, and monetize customers.

description: |
Monitor API logs and usage metrics in [Moesif](https://www.moesif.com/solutions/track-api-program?language=kong-api-gateway&utm_medium=docs&utm_campaign=partners&utm_source=kong){:target="_blank"}{:rel="noopener noreferrer"}, which enables you to:
This plugin logs API traffic to [Moesif API Analytics](https://www.moesif.com?language=kong-api-gateway&utm_medium=docs&utm_campaign=partners&utm_source=kong), which enables you to:
* [Understand customer API usage](https://www.moesif.com/features/api-analytics?utm_medium=docs&utm_campaign=partners&utm_source=kong){:target="_blank"}{:rel="noopener noreferrer"} and the value they bring.
* [Debug issues quickly](https://www.moesif.com/features/api-logs?utm_medium=docs&utm_campaign=partners&utm_source=kong){:target="_blank"}{:rel="noopener noreferrer"} with high-cardinality API logs and metrics.
* [Get alerted](https://www.moesif.com/features/api-monitoring?utm_medium=docs&utm_campaign=partners&utm_source=kong){:target="_blank"}{:rel="noopener noreferrer"} of problems and anomalous behavior.
* [Trigger behavioral emails](https://www.moesif.com/features/user-behavioral-emails?utm_medium=docs&utm_campaign=partners&utm_source=kong){:target="_blank"}{:rel="noopener noreferrer"} warning customers of issues.
* [Detect and Block API threats](https://www.moesif.com/solutions/api-security?utm_medium=docs&utm_campaign=partners&utm_source=kong){:target="_blank"}{:rel="noopener noreferrer"} and abuse including OWASP Top 10 API threats.
* [Understand customer API usage](https://www.moesif.com/features/api-analytics?utm_medium=docs&utm_campaign=partners&utm_source=kong)
* [Debug issues quickly](https://www.moesif.com/features/api-logs?utm_medium=docs&utm_campaign=partners&utm_source=kong)
* [Monetize your APIs](https://www.moesif.com/solutions/metered-api-billing?utm_medium=docs&utm_campaign=partners&utm_source=kong)
* [Get alerted of API issues](https://www.moesif.com/features/api-monitoring?utm_medium=docs&utm_campaign=partners&utm_source=kong)
* [Guide customers at scale](https://www.moesif.com/features/user-behavioral-emails?utm_medium=docs&utm_campaign=partners&utm_source=kong)
* [Protect and govern your API](https://www.moesif.com/features/api-governance-rules?utm_medium=docs&utm_campaign=partners&utm_source=kong)
This plugin supports automatic analysis of high-volume REST, GraphQL, and other APIs without adding latency.
Expand All @@ -34,6 +36,12 @@ terms_of_service_url: https://www.moesif.com/terms?utm_medium=docs&utm_campaign=
kong_version_compatibility: # required
community_edition: # optional
compatible:
- 2.8.x
- 2.7.x
- 2.6.x
- 2.5.x
- 2.4.x
- 2.3.x
- 2.2.x
- 2.1.x
- 2.0.x
Expand All @@ -52,6 +60,13 @@ kong_version_compatibility: # required
#incompatible:
enterprise_edition: # optional
compatible:
- 2.8.x
- 2.7.x
- 2.6.x
- 2.5.x
- 2.4.x
- 2.3.x
- 2.2.x
- 2.1.x
- 1.5.x
- 1.3-x
Expand All @@ -70,13 +85,23 @@ params:
service_id: true
consumer_id: true
route_id: true
dbless_compatible: yes
protocols:
- http
- https
- tcp
- tls
- tls_passthrough
- udp
- grpc
- grpcs
dbless_compatible: 'yes'
dbless_explanation: The plugin is compatible with any with DB-less mode including `local`, `cluster`, and `redis`
config:
- name: application_id
required: true
default:
value_in_examples: MY_MOESIF_APPLICATION_ID
description: Your Moesif Application Id from your [Moesif](http://www.moesif.com){:target="_blank"}{:rel="noopener noreferrer"} dashboard. Go to Top Right Menu -> Installation.
description: Your Moesif Application Id from your [Moesif](http://www.moesif.com) dashboard. Go to Top Right Menu -> Installation.
- name: api_endpoint
required: false
default: "`https://api.moesif.net`"
Expand All @@ -101,14 +126,6 @@ params:
required: false
default: "`1.0`"
description: API Version you want to tag this request with in Moesif.
- name: user_id_header
required: false
default: "X-Consumer-Custom-Id"
description: Request or response header to use to identify the User in Moesif.
- name: company_id_header
required: false
default: ""
description: Request or response header to use to identify the Company (Account) in Moesif.
- name: disable_capture_request_body
required: false
default: "`false`"
Expand Down Expand Up @@ -141,6 +158,22 @@ params:
required: false
default: "`200`"
description: Maximum batch size when sending to Moesif.
- name: user_id_header
required: false
default: "`X-Consumer-Custom-Id`"
description: Request or response header used to identify the User in Moesif.
- name: company_id_header
required: false
default: ""
description: Request or response header used to identify the Company (Account) in Moesif.
- name: authorization_header_name
required: false
default: "`authorization`"
description: Request header containing a Bearer or basic token to extract user id. See identifying users. Also, supports a comma-separated string. The plugin will check headers in order "X-Api-Key, Authorization".
- name: authorization_user_id_field
required: false
default: "`sub`"
description: Field name in JWT/OpenId token’s payload for identifying users. Only applicable if authorization_header_name is set and is a Bearer token.
- name: event_queue_size
required: false
default: "`5000`"
Expand Down Expand Up @@ -182,35 +215,58 @@ params:
### How it works

When enabled, this plugin captures API traffic and logs it to
[Moesif API Analytics](https://www.moesif.com/?language=kong-api-gateway&utm_medium=docs&utm_campaign=partners&utm_source=kong){:target="_blank"}{:rel="noopener noreferrer"}.
This plugin logs to Moesif with an [asynchronous design](https://www.moesif.com/enterprise/api-analytics-infrastructure?language=kong-api-gateway&utm_medium=docs&utm_campaign=partners&utm_source=kong){:target="_blank"}{:rel="noopener noreferrer"} and doesn't add any latency to your API calls.
[Moesif API Analytics](https://www.moesif.com/?language=kong-api-gateway&utm_medium=docs&utm_campaign=partners&utm_source=kong).
This plugin logs to Moesif with an [asynchronous design](https://www.moesif.com/enterprise/api-analytics-infrastructure?language=kong-api-gateway&utm_medium=docs&utm_campaign=partners&utm_source=kong) and doesn't add any latency to your API calls.

[Package on Luarocks](http://luarocks.org/modules/moesif/kong-plugin-moesif){:target="_blank"}{:rel="noopener noreferrer"}
[Package on Luarocks](http://luarocks.org/modules/moesif/kong-plugin-moesif)

Moesif natively supports REST, GraphQL, Web3, SOAP, JSON-RPC, and more.

### How to install
## How to install

> If you are using Kong's [Kubernetes Ingress Controller](https://github.com/Kong/kubernetes-ingress-controller), the installation is slightly different. Review the [docs for Kubernetes Ingress](https://www.moesif.com/docs/server-integration/kong-ingress-controller/).
The `.rock` file is a self-contained package that can be installed locally or from a remote server.

If the luarocks utility is installed in your system (this is likely the case if you used one of the official installation packages), you can install the 'rock' in your LuaRocks tree (a directory in which LuaRocks installs Lua modules).
If the LuaRocks utility is installed in your system (this is likely the case if you used one of the official installation packages), you can install the 'rock' in your LuaRocks tree (a directory in which LuaRocks installs Lua modules).

### Install the Moesif plugin

1. Install the package from the luarocks repository:
```shell
luarocks install --server=http://luarocks.org/manifests/moesif kong-plugin-moesif
```
2. If you don’t have a `kong.conf`, create one from the default:
```shell
cp /etc/kong/kong.conf.default /etc/kong/kong.conf
```
3. In your `kong.conf`, append moesif to the plugins field. Make sure the field is not commented out:
```text

### Update your loaded plugins list
In your `kong.conf`, append `moesif` to the `plugins` field (or `custom_plugins` if old version of Kong). Make sure the field is not commented out.

```yaml
plugins = bundled,moesif # Comma-separated list of plugins this node
# should load. By default, only plugins
# bundled in official distributions are
# loaded via the `bundled` keyword.
```
4. Restart Kong:

If you don't have a `kong.conf`, create one from the default using the following command:
`cp /etc/kong/kong.conf.default /etc/kong/kong.conf`

### Restart Kong

After LuaRocks is installed, restart Kong before enabling the plugin

```shell
kong restart
```

### Enable the Moesif plugin

```shell
curl -i -X POST --url http://localhost:8001/plugins/ --data "name=moesif" --data "config.application_id=YOUR_APPLICATION_ID";
```

### Restart Kong again

If you don't see any logs in Moesif, you may need to restart Kong again.

```shell
kong restart
```

0 comments on commit a3fba71

Please sign in to comment.