How to use statsd purely at route level

I enabled plugin statsd for each route but when I checked grafana I saw it is using the metric name from service so it means even If I enabled this at route level there is no way to check metrics for each route. Can someone help me on this?

statsd is like below
{
“created_at”: 1532935412000,
“config”: {
“host”: “127.0.0.1”,
“port”: 8125,
“prefix”: “portal.kong.version”,
“metrics”: [
{
“sample_rate”: 1,
“name”: “request_count”,
“stat_type”: “counter”
},
{
“stat_type”: “timer”,
“name”: “latency”
},
{
“stat_type”: “timer”,
“name”: “request_size”
},
{
“sample_rate”: 1,
“name”: “status_count”,
“stat_type”: “counter”
},
{
“stat_type”: “timer”,
“name”: “response_size”
},
{
“consumer_identifier”: “custom_id”,
“name”: “unique_users”,
“stat_type”: “set”
},
{
“sample_rate”: 1,
“name”: “request_per_user”,
“consumer_identifier”: “custom_id”,
“stat_type”: “counter”
},
{
“stat_type”: “timer”,
“name”: “upstream_latency”
},
{
“stat_type”: “timer”,
“name”: “kong_latency”
},
{
“sample_rate”: 1,
“name”: “status_count_per_user”,
“consumer_identifier”: “custom_id”,
“stat_type”: “counter”
}
]
},
“id”: “1ad7f802-c3b9-4df9-a6c4-f43b92d83d2a”,
“name”: “statsd”,
“enabled”: true,
“route_id”: “d410ea54-3692-4e7b-8b33-1eb1e4028157”
}

route is like below

{
“created_at”: 1532935412,
“strip_path”: false,
“hosts”: null,
“preserve_host”: true,
“regex_priority”: 0,
“updated_at”: 1532935412,
“paths”: [
“/v1/products/\d+/pickup-locations/\d+/stock-lots/\d+”
],
“service”: {
“id”: “0fbd9654-6a85-4cd4-aa0e-2149536ac585”
},
“methods”: [
“PATCH”
],
“protocols”: [
“http”
],
“id”: “d410ea54-3692-4e7b-8b33-1eb1e4028157”
}

service is like below

{
“host”: “localhost”,
“created_at”: 1532935412,
“connect_timeout”: 60000,
“id”: “0fbd9654-6a85-4cd4-aa0e-2149536ac585”,
“protocol”: “http”,
“name”: “api-service-v1-products”,
“read_timeout”: 60000,
“port”: 8098,
“path”: null,
“updated_at”: 1532935412,
“retries”: 2,
“write_timeout”: 60000
}

metrics is captured under name “api-service-v1-products”.

@jeremyjpj0916 any suggestion ?

Hello you rang :slight_smile: ? As far as StatsD works with services/routes we use it globally and its tagged on Service Name, you cannot monitor say 3 routes individually tied to a service as far as I know since it all relates to the service name. This is my global StatsD configuration. If you are like me this is not a real problem because I create a 1 to 1 service to route relationship.

{
  "created_at": 1530404048286,
  "config": {
    "host": "localhost",
    "metrics": [
      {
        "sample_rate": 1,
        "name": "request_count",
        "stat_type": "counter"
      },
      {
        "name": "latency",
        "stat_type": "timer"
      },
      {
        "name": "request_size",
        "stat_type": "timer"
      },
      {
        "sample_rate": 1,
        "name": "status_count",
        "stat_type": "counter"
      },
      {
        "name": "response_size",
        "stat_type": "timer"
      },
      {
        "name": "upstream_latency",
        "stat_type": "timer"
      },
      {
        "name": "kong_latency",
        "stat_type": "timer"
      }
    ],
    "prefix": "kong",
    "port": 8125
  },
  "id": "fb12c3be-5a69-4f2a-9866-e6932f7a7f3f",
  "name": "statsd",
  "enabled": true
}

Thanks for reply. Ya I wanted to monitor say 3 routes individually tied to a service but I was not able to configure since all are clubbed by service name. I was wondering if Kong clubbed all metrics at route level to service name then why it allow to enable statsd at route level why not just at service layer to avoid confusion and that’s why I thought may be I am missing something. As you mentioned I was also thinking to map 1 route to 1 service if I want to have statsd defined for each route.

1 Like