Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

AEM + Prometheus client_java = servlet endpoint


Level 2

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 = {

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() {

        protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
            throws IOException, ServletException {






Error Message:

org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: No use provider could resolve identifier

Any help will be appreciated.


3 Replies


Community Advisor



    Is this happening because of the missing @Override ?



Veena ✌


Level 2

I pasted the wrong code, but the one I am running on my machine has @Override


Community Advisor

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 ?