Search code examples
prometheuskong-plugin

Monitor KongApi using Prometheus


I am using Prometheus with Grafana to monitor KongAPI Gateway by enabling Prometheus plugin on Kong.

Our Kong architecture uses a dedicated one server for Control Plane and another two servers for Data Plane.

Do I need to enable Prometheus plugin on the three servers ?

Are Metrics of the servers different so that I need to configure Prometheus to collect the metrics from all servers ?

Your support is highly appreciated.


Solution

  • Do I need to enable Prometheus plugin on the three servers ?
    Since you are deploying Kong using Hybrid mode deployment, applying the Prometheus plugin on Control plane (via Admin API or Kong Manager). After applying the plugin onto Control plane the Data plane will be configured to expose Prometheus endpoint.

    The metrics can then be scraped using status API, assuming you disable admin API on both data planes.

    # setting status listen in kong.conf to expose port 8100 
    (it can be configured as https endpoint the same way as proxy_listen)
    status_listen = 0.0.0.0:8100
    

    Setting this expose port 8100, which Prometheus will expose metrics at :8100/metrics

    Example prometheus config:

    - job_name: kong
      static_configs:
        - targets:
          - <CP-ip>:8100
          - <DP1-ip>:8100
          - <DP2-ip>:8100
    

    Are Metrics of the servers different so that I need to configure Prometheus to collect the metrics from all servers ?
    The metrics will be 'somewhat' different (e.g.proxy metrics only on DPs), but those metrics will have instance IP included in it:
    e.g.: kong_memory_lua_shared_dict_bytes{instance="IP:8100", job="kong", kong_subsystem="http", shared_dict="kong"}

    Additionally, Kong's Grafana dashboard has already taken into account multiple instances, so if you use the config above to scrape the metrics, Grafana will plot 3 lines in the graph, each representing an instance( 1CP + 2 DPs)