Q:

Prometheus not able to pull configured metrics

I configured prometheus.yml file 
# my global config
global:
scrape_interval:     15s # Set the scrape interval to every 15 seconds. 
Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is 
every 1 minute.
# scrape_timeout is set to the global default (10s).

# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
- job_name:       'example-random'

# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s

static_configs:
  - targets: ['localhost:8090']
    labels:
      group: 'dummy'

and registered a metric with prometheus 
public class PrometheusMetricsServlet extends MetricsServlet {

private static final Gauge emailCount = Gauge.build().name("email_count")
        .help("Number of emails sent by the user")
        .register();

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    resp.setStatus(200);
    emailCount.set(54);
 }
}

then configured a servlet in web.xml
<servlet>
    <servlet-name>PrometheusServlet</servlet-name>
    <servlet-class>prometheusSpike.PrometheusMetricsServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>PrometheusServlet</servlet-name>
    <url-pattern>/metrics</url-pattern>
</servlet-mapping>

The status of the target shows UP and the last scrape happens some seconds before, but the metric is not getting reflected in prometheus.
What to do so that prometheus pulls configured metrics from the targets?

A:

When you overrode doGet you prevented the code running that exposes the metrics. Use the MetricsServlet as-is, and you'll see your metrics.

