-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use custom metrics? #25
Comments
Any update on this issue? It seems you can add custom metrics but the question is how to trigger them? Thanks in advance! |
@nizarayari Yes, you should use gin metrics with you custom mectrics build with standart prometheus library methods. Gin prometheus library collect base metrics and bind it into common metrics report |
ok.. so im a bit stumped here. i have the custom metrics implemented (so i can see them show up when i have my server running): However, even with looking with the answer provided to nizarayari, i dont see how to apply the .Inc() method to the custom metric. I have tried as well looking at the other example, however the prometheus.Register(numErrors) example never ends up showing up in the gin metrics list (as the test ones outlined above are). any pointers would be wonderful! |
I change customMetrics := []*ginprometheus.Metric{
&ginprometheus.Metric{
ID: "1234", // optional string
Name: "test_metric", // required string
Description: "Counter test metric", // required string
Type: "counter", // required string
},
&ginprometheus.Metric{
ID: "1235", // Identifier
Name: "test_metric_2", // Metric Name
Description: "Summary test metric", // Help Description
Type: "summary", // type associated with prometheus collector
},
// Type Options:
// counter, counter_vec, gauge, gauge_vec,
// histogram, histogram_vec, summary, summary_vec
}
p := ginprometheus.NewPrometheus("gin", customMetrics)
// add data to custom metrics
m := p.MetricsList["1234"].MetricCollector.(prometheus.Counter)
m.Inc() |
Thanks @snowlyg |
Hi, i read sourse code and could not understand how to use custom metrics? Does exist way do it, or i should rewrite this library?
The text was updated successfully, but these errors were encountered: