Log metrics for a Service, route to a StatsD server. It can also be used to log metrics on Collectd daemon by enabling its StatsD plugin.
The StatsD Advanced plugin provides features not available in the open-source StatsD plugin, such as:
- Ability to choose status codes to log to metrics.
- More granular status codes per workspace.
- Ability to use TCP instead of UDP.
By default, the plugin sends a packet for each metric it observes. The udp_packet_size
option
configures the greatest datagram size the plugin can combine. It should be less than
65507 according to UDP protocol. Please consider the MTU of the network when setting this parameter.
Metrics
Metric | Description | Namespace |
---|---|---|
request_count |
the request count | kong.service.\<service_identifier>.request.count |
request_size |
the request’s body size in bytes | kong.service.\<service_identifier>.request.size |
response_size |
the response’s body size in bytes | kong.service.\<service_identifier>.response.size |
latency |
the time interval in milliseconds between the request and response | kong.service.\<service_identifier>.latency |
status_count |
tracks each status code returned in a response | kong.service.\<service_identifier>.request.status.\<status>.count and kong.\<service_name>.request.status.\<status>.total |
unique_users |
tracks unique users who made a requests to the underlying Service/Route | kong.service.\<service_identifier>.user.uniques |
request_per_user |
tracks the request count per Consumer | kong.service.\<service_identifier>.user.\<consumer_id>.request.count |
upstream_latency |
tracks the time in milliseconds it took for the final Service to process the request | kong.service.\<service_identifier>.upstream_latency |
kong_latency |
tracks the internal Kong latency in milliseconds that it took to run all the Plugins | kong.service.\<service_identifier>.kong_latency |
status_count_per_user |
tracks the status code for per Consumer per Service | kong.\<service_name>.user.\<customer_id>.request.status.\<status> and kong.\<service_name>.user.\<customer_id>.request.status.total |
status_count_per_workspace |
the status code per Workspace | kong.service.\<service_identifier>.workspace.\<workspace_identifier>.status.\<status> |
status_count_per_user_per_route |
the status code per Consumer per Route | kong.route.\<route_id>.user.\<customer_id>.status.\<status> |
shdict_usage |
the usage of shared dict, sent once every minute | kong.node.\<node_hostname>.shdict.\<shdict_name>.free_space and kong.node.\<node_hostname>.shdict.\<shdict_name>.capacity |
If a request URI doesn’t match any Routes, the following metrics will be sent instead:
Metric | Description | Namespace |
---|---|---|
request_count |
the request count | kong.global.unmatched.request.count |
request_size |
the request’s body size in bytes | kong.global.unmatched.request.size |
response_size |
the response’s body size in bytes | kong.global.unmatched.response.size |
latency |
the time interval between the request started and response received from the upstream server | kong.global.unmatched.latency |
status_count |
the status count | kong.global.unmatched.status.\<status>.count |
kong_latency |
the internal Kong latency in milliseconds that it took to run all the plugins | kong.global.unmatched.kong_latency |
Metric Fields
The plugin can be configured with any combination of Metrics, with each entry containing the following fields:
Field | Description | Datatype | Allowed values |
---|---|---|---|
name |
StatsD metrics name. Required. | String | Metrics |
stat_type |
Determines what sort of event a metric represents. Required. | String | gauge , timer , counter , histogram , meter and set |
sample_rate conditional |
Sampling rate. Required. | Number | number |
consumer_identifier conditional |
Authenticated user detail. Required. | String | One of the following options: consumer_id , custom_id , username |
service_identifier conditional |
Service detail. Required. | String | One of the following options:service_id , service_name , service_host , service_name_or_host |
workspace_identifier conditional |
Workspace detail. Required. | String | One of the following options:workspace_id , workspace_name |
Metric Behaviors
- By default, all metrics get logged.
- Metric with
stat_type
set tocounter
orgauge
must havesample_rate
defined as well. unique_users
metric only works withstat_type
asset
.status_count
,status_count_per_user
,status_count_per_user_per_route
andrequest_per_user
work only withstat_type
ascounter
.shdict_usage
work only withstat_type
asgauge
.status_count_per_user
,request_per_user
,unique_users
andstatus_count_per_user_per_route
must havecustomer_identifier
defined.- All metrics can optionally configure
service_identifier
; by default it’s set toservice_name_or_host
. status_count_per_workspace
must haveworkspace_identifier
defined.
Kong Process Errors
This logging plugin logs HTTP request and response data, and also supports streams data (TCP, TLS, and UDP).
If you are looking for the Kong process error file (which is the nginx error file), you can find it at the following path:
{prefix}/logs/error.log