Analytics Plugins
Last updated: 2 minutes read.
Since Tyk 4.1.0 we have incorporated analytic plugins which enables editing or removal of all parts of analytics records and raw request and responses recorded by Tyk at the gateway level. This feature leverages existing Go plugin infrastructure.
- Tyk receives the request.
- Tyk runs the full middleware chain, including any other plugins hooks like Pre, Post, Custom Authentication, etc.
- Tyk sends the request to your upstream API.
- The response is received and analytics plugin function is triggered before recording the hit to redis.
- Your plugin modifies the analytics record and sends it back to Tyk.
- Tyk takes the modified analytics record and record the hit in redis.
Example analytics Go plugins can be found here
An analytics plugin is configured using the analytics_plugin
configuration block within an API Definition. This contains the following configuration parameters:
enable
: Set totrue
to enable the pluginfunc_name
: The name of the function representing the pluginplugin_path
: The path to the source code file containing the function that implements the plugin
To enable the analytics rewriting functionality, adjust the following in API definition:
{
"analytics_plugin": {
"enable": true,
"func_name": "<function name>",
"plugin_path": "<path>/analytics_plugin.so"
}
}
The example API Definition resource listed below listens on path /httpbin and forwards requests upstream to http://httpbin.org. A Go Analytics Plugin is enabled for function MaskAnalyticsData, located within the /opt/tyk-gateway/plugins/example-plugin.so shared object file.
|
|