Also, after using @Times annotation at the method level, I am getting 
metrics consist of  of 
*http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/students",}
 
2.0* 

While I was hoping this will return tags from Http request and response as 
per the default implementation inside class DefaultWebMvcTagsProvider 

@Override
public Iterable<Tag> getTags(HttpServletRequest request, HttpServletResponse 
response, Object handler,
Throwable exception) {
Tags tags = Tags.of(WebMvcTags.method(request), WebMvcTags.uri(request, 
response, this.ignoreTrailingSlash),
WebMvcTags.exception(exception), WebMvcTags.status(response), WebMvcTags.
outcome(response));
for (WebMvcTagsContributor contributor : this.contributors) {
tags = tags.and(contributor.getTags(request, response, handler, exception));
}
return tags;
} Any idea what am I missing here? Also, I have added custom class to 
override the behavior but did not work. @Bean WebMvcTagsProvider 
webMvcTagsProvider() { return new WebMvcTagsProvider() { 
@SuppressWarnings("unchecked") @Override public Iterable<Tag> 
getTags(HttpServletRequest request, HttpServletResponse response, Object 
handler, Throwable exception) { return ((Map<String, String>) 
request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE)) 
.entrySet() .stream() .map(entry -> new ImmutableTag(entry.getKey(), 
entry.getValue())) .collect(Collectors.toList()); } @Override public 
Iterable<Tag> getLongRequestTags(HttpServletRequest request, Object 
handler) { return new ArrayList<>(); } }; } 

Any advise on what I am doing wrong? 

Appreciate your help!

Thanks,
Ketan
On Thursday, 7 May 2020 12:22:39 UTC+5:30, Ketan Talreja wrote:
>
> Hi Guys, 
>
> Hope everyone is doing well! 
>
> I have started using Prometheus to collect metrics for my application 
> which is implemented in Java spring boot 2.x framework. I have used 
> "micrometer-registry-prometheus" library but this required some annotation 
> to be done in the code and moreover customize the bean configuration. 
>
> *Monitoring use-case for my application -* 
> *1*. I have to count the number of time REST API/Endpoint has been invoked
> *2.* I have to also capture REST request Input/response Output generated 
> and scrape it to metrics server i.e. Prometheus and using this metrics I 
> have to calculate i.e. number of time the "value" is returned in the 
> response output and same for request input i.e. number of time the specific 
> "value" is passed as in the input payload. 
>
> Could you please help how can I achieve above two points using Prometheus 
> and its client-libraries? And is there a way to achieve without 
> instrumenting the app code? This will help to decouple the application 
> codebase from instrumentation.
>
> Thanks!!
> Ketan
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/97dcff39-d1a2-405d-b281-1fa4b7f78fcf%40googlegroups.com.

Reply via email to