Does anyone tried to use Prometheus client_java (GitHub - prometheus/client_java) in AEM sling servlet?
I am trying to create a servlet where prometheus data will be displayed from a custom URL.
This is my simple servlet, but I am experiencing some issues with it.
import io.prometheus.client.Counter;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.osgi.service.component.annotations.Component;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import java.io.IOException;
@Component(service = Servlet.class, immediate = true, property = {
"sling.servlet.methods=GET",
"sling.servlet.paths=/services/metrics"
})
public class PrometheusServlet extends SlingSafeMethodsServlet {
static final Counter counter =
Counter.build().name("Total_number_of_sample_counter").help("Total number of counter").register();
void processCounter() {
counter.inc();
}
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws IOException, ServletException {
processCounter();
response.getWriter().println(counter);
}
}
org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: No use provider could resolve identifier
Any help will be appreciated.
Thanks!
Views
Replies
Total Likes
Is your servlet in active state ? The error makes me think that your servlet is not yet active. Also how are you accessing the servlet ?
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies