Skip to content

Adding Custom metrics #8270

Answered by esatterwhite
esatterwhite asked this question in Help
Jan 7, 2022 · 4 comments · 14 replies
Discussion options

You must be logged in to vote

Sure. The thing to keep in mind about these kong plugins, is that "its just lua", and as long as you play by the rules of the kong PDK - anything goes.

Basically what I did was separate each phase handler into separate lua modules

kong
└── plugins
    └── my-plugin
        ├── access.lua
        ├── handler.lua
        ├── metrics.lua
        └── schema.lua

in handler.lua where the plugin class lives, you initialize your metrics lib, and pass it to your phase functions in addition to the plugin config

-- handler.lua

local access = require('kong.plugins.my-plugin.access')
local metrics = require('kong.plugins.my-plugin.metrics')
local version = require('kong.plugins.my-plugin.version')

l…

Replies: 4 comments 14 replies

Comment options

You must be logged in to vote
2 replies
@sydpz
Comment options

@esatterwhite
Comment options

Comment options

You must be logged in to vote
6 replies
@esatterwhite
Comment options

Answer selected by esatterwhite
@esatterwhite
Comment options

@chenmaolin928
Comment options

@esatterwhite
Comment options

@chenmaolin928
Comment options

Comment options

You must be logged in to vote
2 replies
@esatterwhite
Comment options

@abhi-gaur
Comment options

Comment options

You must be logged in to vote
4 replies
@flowdopip
Comment options

@vanigupta82
Comment options

@pavan-kumar-06
Comment options

@flowdopip
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment