{"id":13565843,"url":"https://github.com/yciabaud/kong-plugin-prometheus","last_synced_at":"2025-09-14T02:31:23.388Z","repository":{"id":143046501,"uuid":"104552965","full_name":"yciabaud/kong-plugin-prometheus","owner":"yciabaud","description":"Prometheus metrics exporter for Kong API management","archived":false,"fork":false,"pushed_at":"2020-01-23T09:46:17.000Z","size":29,"stargazers_count":42,"open_issues_count":5,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-08T17:21:52.525Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yciabaud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-09-23T08:27:04.000Z","updated_at":"2023-12-11T06:17:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"0d0a8315-6c73-4ac5-88a7-1ee4b18c8352","html_url":"https://github.com/yciabaud/kong-plugin-prometheus","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/yciabaud/kong-plugin-prometheus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yciabaud%2Fkong-plugin-prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yciabaud%2Fkong-plugin-prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yciabaud%2Fkong-plugin-prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yciabaud%2Fkong-plugin-prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yciabaud","download_url":"https://codeload.github.com/yciabaud/kong-plugin-prometheus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yciabaud%2Fkong-plugin-prometheus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275052416,"owners_count":25397144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T13:01:56.448Z","updated_at":"2025-09-14T02:31:23.010Z","avatar_url":"https://github.com/yciabaud.png","language":"Lua","funding_links":[],"categories":["Lua"],"sub_categories":[],"readme":"# kong-prometheus-plugin\n\nWidely inspired by [nginx-lua-prometheus](https://github.com/knyar/nginx-lua-prometheus/) NGINX module and the [Kong StatsD plugin](https://github.com/Mashape/kong/tree/master/kong/plugins/statsd).\n\n\nExposes API [metrics](#metrics) for [Prometheus](https://prometheus.io) monitoring system.\n\n----\n\n## Installation\n\nInstall the `luarocks` utility on your system then install it by doing:\n```bash\n$ luarocks install kong-plugin-prometheus\n```\n\n## Configuration\n\nConfiguring the plugin is straightforward, you can add it on top of an\nAPI by executing the following request on your Kong server:\n\n```bash\n$ curl -X POST http://kong:8001/apis/{api}/plugins \\\n    --data \"name=prometheus\"\n```\n\n`api`: The `id` or `name` of the API that this plugin configuration will target\n\nYou can also apply it for every API using the `http://kong:8001/plugins/`\nendpoint.\n\nparameter                       | default | description\n---                             | ---     | ---\n`name`                          |         | The name of the plugin to use, in this case: `prometheus`\n`config.metrics`\u003cbr\u003e*optional*  | All metrics\u003cbr\u003eare logged | List of Metrics to be logged. Available values are described under [Metrics](#metrics).\n`config.dict_name`\u003cbr\u003e*optional*| `kong_cache` | The name of the nginx shared dictionary which will be used to store all metrics.\n`config.prefix`\u003cbr\u003e*optional*   | `kong` | String to be prefixed to each metric's name.\n\n\n----\n\nIf you use a custom shared dictionary to store the metrics, you need to create a kong configuration template including the shared dictionary:\n```\nlua_shared_dict prometheus_metrics 10M;\n```\n\n## Metrics\n\nThe plugin exposes is metrics on kong's admin endpoint (port 8001 by default) on the path `/prometheus/metrics`.\n\nMetrics the plugin can expose in the prometheus format:\n\nMetric                           | description | namespace\n---                              | ---         | ---\n`http_requests_total`            | tracks api request | kong_http_requests_total\n`http_request_size_bytes`        | tracks api request's body size in bytes | kong_http_request_size_bytes\n`http_response_size_bytes`       | tracks api response's body size in bytes | kong_http_response_size_bytes\n`http_request_duration_ms`       | tracks the time interval between the request started and response received from the upstream server | kong_http_latency\n`http_upstream_duration_ms`      | tracks the time it took for the final service to process the request | kong_http_upstream_latency\n`http_kong_duration_ms`          | tracks the internal Kong latency that it took to run all the plugins | kong_http_kong_latency\n\n### Metric Fields\n\nPlugin can be configured with any combination of [Metrics](#metrics), with each entry containing the following fields.\n\nField         | description                                           | allowed values\n---           | ---                                                   | --- \n`name`        | Prometheus metric's name                              | [Metrics](#metrics)          \n`stat_type`   | determines what sort of event the metric represents   | `gauge`, `counter` and `histogram`\n\n## Kong Process Errors\n\nThis logging plugin will only log HTTP request and response data. If you are\nlooking for the Kong process error file (which is the nginx error file), then\nyou can find it at the following path:\nprefix/logs/error.log\n\n## Built-in metrics\n\nThe module increments the `kong_metric_errors_total` metric if it encounters an error (for example, when lua_shared_dict becomes full). You might want to configure an alert on that metric.\n\n## Caveats\n\nPlease keep in mind that all metrics stored by this library are kept in a\nsingle shared dictionary (`lua_shared_dict`). By default, we use the `kong_cache` shared dict so if you are using it remember to allow extra space to it.\nWhile exposing metrics the module has to list all dictionary keys, which has serious performance implications for\ndictionaries with large number of keys (in this case this means large number\nof metrics OR metrics with high label cardinality). Listing the keys has to\nlock the dictionary, which blocks all threads that try to access it (i.e.\npotentially all nginx worker threads).\n\nThere is no elegant solution to this issue (besides keeping metrics in a\nseparate storage system external to nginx), so for latency-critical servers you\nmight want to keep the number of metrics (and distinct metric label values) to\na minimum.\n\n## Credits\n- Adapted and maintained by Yoann Ciabaud [@yciabaud](https://github.com/yciabaud)\n- :heart: kindly improved and tested by [@jayhding](https://github.com/jayhding)\n\n### Kong StatsD plugin\n- Source [Plugin](https://getkong.org/plugins/statsd/) created and maintained by the [Kong](https://getkong.org/) folks at [Mashape](https://www.mashape.com)\n\n### nginx-lua-prometheus\nAll prometheus implementation credits goes to [nginx-lua-prometheus](https://github.com/knyar/nginx-lua-prometheus/)\n- Created and maintained by Anton Tolchanov (@knyar)\n- Metrix prefix support contributed by david birdsong (@davidbirdsong)\n- Gauge support contributed by Cosmo Petrich (@cosmopetrich)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyciabaud%2Fkong-plugin-prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyciabaud%2Fkong-plugin-prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyciabaud%2Fkong-plugin-prometheus/lists"}