![]() |
---|
Figure 1: An architecture diagram illustrating horizontal scaling of “n” Instances of Tyk-Pump each with two different backends. |
Supported | Summary |
---|---|
✅ | Single Pump Instance, Single Backend |
✅ | Single Pump Instance, Multiple Backend(s) |
✅ | Multiple Pump Instances, Same Backend(s) |
❌ | Multiple Pump Instances, Different Backend(s) |
mongo-pump-aggregate
collection to display analytics. This is different than the standard mongo
pump plugin that will store individual analytic items into MongoDB. The aggregate functionality was built to be fast, as querying raw analytics is expensive in large data sets. See Pump Dashboard Config for more details.
tyk-analytics.conf
) there is now a storage
section.
main
- Main storage (APIs, Policies, Users, User Groups, etc.)analytics
- Analytics storage (used for display all the charts and for all analytics screens)logs
- Logs storage (log browser page)uptime
- uptime tests analytics datastorage
section, you must populate the following fields:
type
use this field to define your SQL platform (currently SQLite or PostgreSQL are supported)connection_string
the specific connection settings for your platformsql
name and database specific configuration options.
####### SQL example
TYK_PMP_OMITCONFIGFILE
variable.
This is specially useful when using Docker, since by default, the Tyk Pump has a default configuration file with pre-loaded pumps.
filters
, which can be defined per pump. This is its structure:
api_ids
and org_ids
works as allow list (APIs and orgs where we want to send the analytic records).skip_api_ids
and skip_org_ids
works as block list (APIs and orgs where we want to filter out and not send their the analytic records).org1
or org2
will go to the csv
backend and everything but analytics records from api_id_1
to elasticsearch
.
Analytics | Activities Graph | Log Browser | Uptime Analytics |
---|---|---|---|
Mongo (Multi organization) | Mongo Aggregate Pump | Mongo Selective Pump | Uptime Pump |
Mongo (Single organization) | Mongo Aggregate Pump | Mongo Pump | Uptime Pump |
SQL | SQL Aggregate Pump | SQL Pump | Uptime Pump |
mongo
Pump simply saves all individual requests across every organization to a collection called tyk_analytics
. Each request will be stored as a single document.
detailed_recording
in the Gateway is turned on which means that the Gateway records the full payload of the request and response.
omit_index_creation
is available. This option is applicable to the following Pumps: Mongo Pump
,Mongo Aggregate Pump
and Mongo Selective Pump
.
The behavior now depends upon the value of ‘omit_index_creation’ and the Pump in use, as follows:
omit_index_creation
is set to true
, tyk-pump will not create any indexes (for Mongo pumps).omit_index_creation
is set to false
(default) and you are using DocumentDB
, tyk-pump will create the Mongo indexes.omit_index_creation
is set to false
(default) and you are using MongoDB
, the behavior of tyk-pump depends upon whether the collection already exists:
tyk_analytics
collection using the mongo
pump.
Because you have the option to store and display analytics of every organization or separately per organization, you need to configure the Tyk Dashboard with the matching setting according to the way you set the pump to store the data in MongoDB.
The field use_sharded_analytics controls the collection that the dashboard will query.
use_sharded_analytics: false
- the dashboard will query the collection tyk_analytics
that mongo pump populateduse_sharded_analytics: true
- the dashboard will query the collection that mongo-pump-selective
pump populatedmongo-pump-aggregate
pump stores data in a collection called **z_tyk_analyticz_aggregate_{ORG ID}**
.
use_mixed_collection: true
- will store analytics to both your organization defined collections z_tyk_analyticz_aggregate_{ORG ID}
and your org-less tyk_analytics_aggregates
collection.use_mixed_collection: false
- your pump will only store analytics to your org defined collection.tyk_analytics_aggregates
collection is used to query analytics across your whole Tyk setup. This can be used, for example, by a superuser role that is not attached to an organization. When set to true
, you also need to set use_sharded_analytics to true in your Dashboard config.
API Usage Data
:
mongo-pump-aggregate
saved to MongoDB.ignore_aggregations
configuration option. The possible values are:
request_id
or timestamp), this collection can grow a lot since aggregation of unique values simply creates a record/document for every single value with a counter of 1. To mitigate this, avoid tagging unique headers as the first option. If you can’t change the API definition quickly, you can add the tag to the ignore list "ignore_aggregations": ["request_id"]
. This ensures that Tyk pump does not aggregate per request_id
.mongo-pump-selective
pump stores individual requests per organization in collections called z_tyk_analyticz_{ORG ID}
.
Similar to the regular mongo
pump, Each request will be stored as a single document.
use_sharded_keys: true
in the dashboard config file so it will query z_tyk_analyticz_{ORG ID}
collections to populate the Log Browser
.
sql_aggregate
sql
tyk_analytics
database table.
type
- The supported types are sqlite
and postgres
.
connection_string
- Specifies the connection string to the database. For example, for sqlite
it will be the path/name of the database, and for postgres
, specifying the host, port, user, password, and dbname.
log_level
- Specifies the SQL log verbosity. The possible values are: info
,error
and warning
. By default, the value is silent
, which means that it won’t log any SQL query.
table_sharding
- Specifies if all the analytics records are going to be stored in one table or in multiple tables (one per day). By default, it is set to false
.
If table_sharding
is false
, all the records are going to be stored in the tyk_analytics
table. If set to true
, daily records are stored in a tyk_analytics_YYYYMMDD
date formatted table.
tyk_analytics
collection using the sql
pump.
Make sure you have configured the dashboard with your SQL database connection settings:
tyk_aggregated
database table.
type
- The supported types are sqlite
and postgres
.
connection_string
- Specifies the connection string to the database. For example, for sqlite
it will be the path/name of the database, and for postgres
, specifying the host, port, user, password, and dbname.
log_level
- Specifies the SQL log verbosity. The possible values are: info
, error
, and warning
. By default, the value is silent
, which means that it won’t log any SQL query.
track_all_paths
- Specifies if it should store aggregated data for all the endpoints. By default, it is set to false
, which means that it only stores aggregated data for tracked endpoints
.
ignore_tag_prefix_list
- Specifies prefixes of tags that should be ignored.
table_sharding
- Specifies if all the analytics records are going to be stored in one table or in multiple tables (one per day). By default, it is set to false
.
If table_sharding
is false
, all the records are going to be stored in the tyk_aggregated
table. If set to true
, daily records are stored in a tyk_aggregated_YYYYMMDD
date formatted table.
API Usage Data
:
sql-aggregate
saved to the database.
uptime_pump_config
section, you can configure a SQL uptime pump. To do that, you need to add the field uptime_type
with sql
value.
type
- The supported types are sqlite
and postgres
.
connection_string
- Specifies the connection string to the database. For example, for sqlite
it will be the path/name of the database, and for postgres
, specifying the host, port, user, password, and dbname.
table_sharding
- Specifies if all the analytics records will be stored in one table or multiple tables (one per day). By default, it is set to false
.
If table_sharding
is false
, all the records will be stored in the tyk_analytics
table. If set to true
, daily records are stored in a tyk_analytics_YYYYMMDD
date formatted table.
enable_aggregate_lookups
to false
Then add your SQL database connection settings:
tyk_aggregated
database table.
table_sharding
), so that the data can be stored daily (one table of data per day), which will automatically make querying or removing sets of data easier, whether dropping tables for removing logs/analytics, or reading multiple tables based on the selected period.
1.7.0
of Tyk Pump and version 4.3.0
of Tyk Gateway it is possible to configure Graph MongoDB Pump. Once configured, the pump enables support for Graphql-specific metrics. The Graphql-specific metrics currently supported include (more to be added in future versions ):
enable_analytics
to true
in your tyk.conf
.
enable_detailed_recording
in your tyk.conf
to true
. This is needed so that the GraphQL information can be parsed from the request body and response.
collection_name
.
pump.conf
(pump configuration file).
1.8.0
of Tyk Pump and version 5.0.0
of the Tyk Gateway; It is possible to export GraphQL analytics to an SQL database.
enable_anaytics
to true
in your tyk.conf
.
enable_detailed_recording
in your tyk.conf
to true
. This is needed so that the GraphQL information can be parsed from the request body and response.
pump.conf
using this sample configuration:
postgres
, sqlite
and mysql
databases. The table_name
refers to the table that will be created in the case of unsharded setups, and the prefix that will be used for sharded setups
e.g tyk_analytics_graph_20230327
.
The Graph SQL pump currently has the same limitations as the Graph Mongo Pump.
sql-graph-aggregate
can be configured similar to the Graph SQL pump:
pump.conf
file:
Dashboards --> lists
section, (https://app.datadoghq.com/dashboard/lists)[https://app.datadoghq.com/dashboard/lists], and it is called Tyk Analytics Canvas
. To use this dashboard you will need to make sure that your datadog agent deployment has the following tag env:tyk-demo-env
and that your Tyk Pump configuration has dogstatsd.meta.namespace
set to pump
. You can also import it from Datadog official GH repo and change those values in the dashboard itself to visualize your analytics data as it flows into Datadog.
pump.conf
file
address
: address of the datadog agent including host & portnamespace
: prefix for your metrics to datadogasync_uds
: Enable async UDS over UDPasync_uds_write_timeout_seconds
: Integer write timeout in seconds if async_uds: true
buffered
: Enable buffering of messagesbuffered_max_messages
: Max messages in single datagram if buffered: true
. Default 16sample_rate
: default 1 which equates to 100% of requests. To sample at 50%, set to 0.5tags
: List of tags to be added to the metric. The possible options are listed in the below examplepath
method
response_code
api_version
api_name
api_id
org_id
tracked
oauth_id
path
tag.
On startup, you should see the loaded configs when initialising the DogstatsD pump
pump.conf
file:
index_name
: The name of the index that all the analytics data will be placed in. Defaults to tyk_analytics
elasticsearch_url
: If sniffing is disabled, the URL that all data will be sent to. Defaults to http://localhost:9200
enable_sniffing
: If sniffing is enabled, the elasticsearch_url
will be used to make a request to get a list of all the nodes in the cluster, the returned addresses will then be used. Defaults to false
document_type
: The type of the document that is created in Elasticsearch. Defaults to tyk_analytics
rolling_index
: Appends the date to the end of the index name, so each days data is split into a different index name. For example, tyk_analytics-2016.02.28
. Defaults to false
.extended_stats
: If set to true will include the following additional fields: Raw Request
, Raw Response
and User Agent
.version
: Specifies the ES version. Use 3
for ES 3.X, 5
for ES 5.X, 6
for ES 6.X, 7
for ES 7.X . Defaults to 3
.disable_bulk
: Disable batch writing. Defaults to false
.bulk_config
: Batch writing trigger configuration. Each option is an OR with each other:
workers
: Number of workers. Defaults to 1
.flush_interval
: Specifies the time in seconds to flush the data and send it to ES. Default is disabled.bulk_actions
: Specifies the number of requests needed to flush the data and send it to ES. Defaults to 1000 requests. If it is needed, can be disabled with -1
.bulk_size
: Specifies the size (in bytes) needed to flush the data and send it to ES. Defaults to 5MB. Can be disabled with -1
.$ docker restart tyk-pump
pump.env
:
Parameter | Required | Description | Environment Variable |
---|---|---|---|
application_id | required | Moesif Application Id. Multiple Tyk api_id’s will be logged under the same app id. | TYK_PMP_PUMPS_MOESIF_META_APPLICATIONID |
request_header_masks | optional | Mask a specific request header field. Type: String Array [] string | TYK_PMP_PUMPS_MOESIF_META_REQUESTHEADERMASKS |
request_body_masks | optional | Mask a specific - request body field. Type: String Array [] string | TYK_PMP_PUMPS_MOESIF_META_REQUESTBODYMASKS |
response_header_masks | optional | Mask a specific response header field. Type: String Array [] string | TYK_PMP_PUMPS_MOESIF_META_RESPONSEHEADERMASKS |
response_body_masks | optional | Mask a specific response body field. Type: String Array [] string | TYK_PMP_PUMPS_MOESIF_META_RESPONSEBODYMASKS |
disable_capture_request_body | optional | Disable logging of request body. Type: Boolean. Default value is false. | TYK_PMP_PUMPS_MOESIF_META_DISABLECAPTUREREQUESTBODY |
disable_capture_response_body | optional | Disable logging of response body. Type: Boolean. Default value is false. | TYK_PMP_PUMPS_MOESIF_META_DISABLECAPTURERESPONSEBODY |
user_id_header | optional | Field name to identify User from a request or response header. Type: String. Default maps to the token alias | TYK_PMP_PUMPS_MOESIF_META_USERIDHEADER |
company_id_header | optional | Field name to identify Company (Account) from a request or response header. Type: String | TYK_PMP_PUMPS_MOESIF_META_COMPANYIDHEADER |
user_id_header
to a header that contains your API user/consumer id such as X-Consumer-Id
. You can also set the company_id_header
which contains the company to link the user to. See Moesif docs on identifying customers
admin
and the password we set in the Docker run command, mypassword
B) Create a new Data input
HTTP Event Collector -> Add New
pump.conf
and add this bit to the “Pumps” section, like so, adding the token from step #1:
Make sure to add your token from the previous step into the collector_token
field above
localhost
value matches with your setup. Head on over to our community forum to ask for help if you are stuck here.$ docker restart tyk-pump
pump.conf
file:
meta.url
: Use if you do not want to use the default Logz.io URL, for example when using a proxy. The default url is https://listener.logz.io:8071
.meta.queue_dir
: The directory for the queue.meta.drain_duration
: This sets the drain duration (when to flush logs on the disk). The default value is 3s
.meta.disk_threshold
: Set the disk queue threshold. Once the threshold is crossed the sender will not enqueue the received logs. The default value is 98
(percentage of disk).meta.check_disk_space
: Set the sender to check if it crosses the maximum allowed disk usage. The default value is true
.GET
, POST
.
Host
header.
Remarks: Includes host and optional port number of the server to which the request was sent.
Example: tyk.io
, or tyk.io:8080
if port is included.
/foo/bar
for /foo%2Fbar
or /foo/bar
.
/foo/bar
for /foo%2Fbar
or /foo/bar
.
Content-Length
header.
Remarks: The number of bytes in the request body.10
for request body 0123456789
.
User-Agent
header.
Example: curl/7.86.0
.
TimeStamp
field.16
for 2022-11-16T03:01:54Z
.
TimeStamp
field.11
for 2022-11-16T03:01:54Z
.
TimeStamp
field.
Example: 2022
for 2022-11-16T03:01:54Z
.
TimeStamp
field.3
for 2022-11-16T03:01:54Z
.
200
for 200 OK
.
auth_key
, hashed 6129dc1e8b64c6b4
, or 00000000
if no authentication provided.
2022-11-16T03:01:54.648+00:00
.
1
or b
. Is Not Versioned
if not versioned.
Foo API
.
727dad853a8a45f64ab981154d1ffdad
.
5e9d9544a1dcd60001d0ed20
.
my-oauth-client-id
.
Latency.Total
field.
Example: 3
for a 3ms roundtrip.
R0VUIC9nZXQgSFRUUC8xLjEKSG9zdDogdHlrLmlv
.
SFRUUC8xLjEgMjAwIE9LCkNvbnRlbnQtTGVuZ3RoOiAxOQpEYXRlOiBXZWQsIDE2IE5vdiAyMDIyIDA2OjIxOjE2IEdNVApTZXJ2ZXI6IGd1bmljb3JuLzE5LjkuMAoKewogICJmb28iOiAiYmFyIgp9Cg==
.
X-Real-IP
or X-Forwarded-For
request headers, if set. Otherwise, determined by gateway based on request.172.18.0.1
.
{"country":{"isocode":"SG"},"city":{"geonameid":0,"names":{}},"location":{"latitude":0,"longitude":0,"timezone":""}}
.
upstream
is the roundtrip duration between the gateway sending the request to the upstream server and it receiving a response. total
is the upstream
value plus additional gateway-side functionality such as processing analytics data.{"total":3,"upstream":3}
.
leaving Tyk -> upstream -> response received back at Tyk
.["key-00000000","org-5e9d9544a1dcd60001d0ed20","api-accbdd1b89e84ec97f4f16d4e3197d5c"]
.
my-key-alias
.
true
if the requested endpoint is configured to be tracked, otherwise false
.true
or false
.
2022-11-23T07:26:25.762+00:00
.
pump.conf
:
<tyk-pump>
with your host name or IP address.
http://<tyk-pump>:9090
from your browser.
<api name>
with the name of your API for this query.
<api name>
with the name of your API for this query.
<api name>
with the name of your API for this query.
tyk_http_requests_total
and tyk_http_latency
described here for illustration:
/metrics
endpoint for scraping. Just enable service in tyk-pump.pump.service
:
tyk_analytics
collection a capped collection. Capping a collection guarantees that analytics data is rolling within a size limit, acting like a FIFO buffer which means that when it reaches a specific size, instead of continuing to grow, it will replace old records with new ones.
tyk_analytics
collection contains granular log data, which is why it can grow rapidly. The aggregate pump will convert this data into a aggregate format and store it in a separate collection. The aggregate collection is used for processing reporting requests as it is much more efficient.
If you’ve got an existing collection which you want to convert to be capped you can use the convertToCapped
MongoDB command.
If you wish to configure the pump to cap the collections for you upon creating the collection, you may add the following
configurations to your uptime_pump_config
and / or mongo.meta
objects in pump.conf
.
collection_cap_max_size_bytes
sets the maximum size of the capped collection.
collection_cap_enable
enables capped collections.
If capped collections are enabled and a max size is not set, a default cap size of 5Gib
is applied.
Existing collections will never be modified.
timestamp
field is older then specified expiration time.
expireAt
to correspond to the time the document should expire. MongoDB will automatically delete documents from the tyk_analytics
collection 0 seconds after the expireAt
time in the document. The expireAt
will be calculated and created by Tyk in the following step.
data_expires
- Sets the data expires to a time in seconds for it to expire. Tyk will calculate the expiry date for you.
mongo_selective
pump stores data on a per organization basis. You will have to run the following command in your MongoDB shell for an individual organization as follows.
tyk.conf
with the following section:
addrs
is new in v2.9.3, and replaces hosts
which is now deprecated.enable_cluster
to false
, you only need to set one entry in addrs
:
The configuration is the same (and uses the same underlying driver) as the regular configuration, so Redis Cluster is fully supported.