private static void verifyPrometheusEndpointsAreRunning()

in micrometerMetrics/src/main/java/org/apache/geode_examples/micrometerMetrics/Example.java [52:71]


  private static void verifyPrometheusEndpointsAreRunning() {
    String[] endpoints = {"http://localhost:9914", "http://localhost:9915"};

    for (String endpoint : endpoints) {
      try {
        URL url = new URL(endpoint);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.connect();

        if (HttpURLConnection.HTTP_OK != connection.getResponseCode()) {
          throw new IllegalStateException(
              "Prometheus endpoint returned status code " + connection.getResponseCode());
        }
      } catch (IOException e) {
        throw new IllegalStateException("Failed to connect to Prometheus endpoint", e);
      }

      System.out.println("A Prometheus endpoint is running at " + endpoint + ".");
    }
  }