Skip to content

Adding Custom metrics #8270

Answered by esatterwhite
esatterwhite asked this question in Help
Jan 7, 2022 · 5 comments · 16 replies

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: 5 comments 16 replies

You must be logged in to vote
2 replies
@sydpz

@esatterwhite

You must be logged in to vote
6 replies
@esatterwhite

Answer selected by esatterwhite
@esatterwhite

@chenmaolin928

@esatterwhite

@chenmaolin928

You must be logged in to vote
2 replies
@esatterwhite

@abhi-gaur

You must be logged in to vote
4 replies
@flowdopip

@vanigupta82

@pavan-kumar-06

@flowdopip

You must be logged in to vote
2 replies
@Blaimi

@SimonKpf

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