Collecting metrics using StatsD or NewRelic
Last updated: 2 minutes read.
Metrics collection and analysis are key components of an Observability strategy, providing real-time insight into system behaviour and performance.
Tyk Gateway, Pump and Dashboard have been instrumented for StatsD monitoring.
Additionally, Tyk Gateway has also been instrumented for NewRelic metrics.
StatsD Instrumentation
StatsD is a network daemon that listens for statistics, like counters and timers, sent over UDP or TCP and sends aggregates to one or more pluggable backend services. It’s a simple yet powerful tool for collecting and aggregating application metrics.
Configuring StatsD instrumentation
To enable instrumentation for StatsD, you must set the environment variable: TYK_INSTRUMENTATION=1
and then configure the statsd_connection_string
field for each component.
statsd_connection_string
is a formatted string that specifies how to connect to the StatsD server. It typically includes information such as the host address, port number, and sometimes additional configuration options.
Optionally you can set statsd_prefix
to a custom prefix value that will be applied to each metric generated by Tyk. For example, you can configure separate prefixes for your production and staging environments to make it easier to differentiate between the metrics in your analysis tool.
StatsD Keys
There are plenty of keys (metrics) available when you enable the StatsD instrumentation, but these are the basics:
- API traffic handled by Gateway:
gauges.<prefix>.Load.rps
(requests per second) - Tyk Gateway API:
counters.<prefix>.SystemAPICall.called.count
(calls count) andtimers.<prefix>.SystemAPICall.success
(response time) - Tyk Dashboard API:
counters.<prefix>.SystemAPICall.SystemCallComplete.count
(requests count),counters.<prefix>.DashSystemAPIError.*
(api error reporting) - Tyk Pump records:
counters.<prefix>.record.count
(number of records processed by pump)
NewRelic Instrumentation
Tyk Gateway has been instrumented for NewRelic metrics since v2.5. Simply add the following config section to tyk.conf
to enable the instrumentation and generation of data:
{
"newrelic": {
"app_name": "<app-name>",
"license_key": "<license_key>"
}
}