new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java
private void editPrometheusCM(String oldRegex, String newRegex) throws ApiException {
    List<V1ConfigMap> cmList = Kubernetes.listConfigMaps(monitoringNS).getItems();
    V1ConfigMap promCm = cmList.stream()
            .filter(cm -> "prometheus-server".equals(cm.getMetadata().getName()))
            .findAny()
            .orElse(null);

    assertNotNull(promCm,"Can't find cm for prometheus-server");
    Map<String, String> cmData = promCm.getData();
    String values = cmData.get("prometheus.yml").replace(oldRegex,newRegex);
    assertNotNull(values, "can't find values for key prometheus.yml");
    cmData.replace("prometheus.yml", values);

    promCm.setData(cmData);
    Kubernetes.replaceConfigMap(promCm);

    cmList = Kubernetes.listConfigMaps(monitoringNS).getItems();

    promCm = cmList.stream()
            .filter(cm -> "prometheus-server".equals(cm.getMetadata().getName()))
            .findAny()
            .orElse(null);

    assertNotNull(promCm,"Can't find cm for prometheus-server");
    assertNotNull(promCm.getData(), "Can't retreive the cm data for prometheus-server after modification");

  }
/**
   * Edit Prometheus Config Map.
   * @param oldRegex search for existed value to replace
   * @param newRegex new value
   * @throws ApiException when update fails
   */
Edit Prometheus Config Map.
@param oldRegex search for existed value to replace
@param newRegex new value
@throws ApiException when update fails
Edit Prometheus Config Map . @param oldRegex search for existed value to replace @param newRegex new value @throws ApiException when update fails
private void editPrometheusCM(String oldRegex, String newRegex) throws ApiException {
    List<V1ConfigMap> cmList = Kubernetes.listConfigMaps(monitoringNS).getItems();
    V1ConfigMap promCm = cmList.stream()
            .filter(cm -> "prometheus-server".equals(cm.getMetadata().getName()))
            .findAny()
            .orElse(null);
    assertNotNull(promCm,"Can't find cm for prometheus-server");
    Map<String, String> cmData = promCm.getData();
    String values = cmData.get("prometheus.yml").replace(oldRegex,newRegex);
    assertNotNull(values, "can't find values for key prometheus.yml");
    cmData.replace("prometheus.yml", values);
    promCm.setData(cmData);
    Kubernetes.replaceConfigMap(promCm);
    cmList = Kubernetes.listConfigMaps(monitoringNS).getItems();
    promCm = cmList.stream()
            .filter(cm -> "prometheus-server".equals(cm.getMetadata().getName()))
            .findAny()
            .orElse(null);
    assertNotNull(promCm,"Can't find cm for prometheus-server");
    assertNotNull(promCm.getData(), "Can't retreive the cm data for prometheus-server after modification");
  }
private void editPrometheusCM ( String oldRegex , String newRegex ) throws ApiException { List < V1ConfigMap > cmList = Kubernetes . listConfigMaps ( monitoringNS ) . getItems ( ) ; V1ConfigMap promCm = cmList . stream ( ) . filter ( cm -> "prometheus-server" . equals ( cm . getMetadata ( ) . getName ( ) ) ) . findAny ( ) . orElse ( null ) ; assertNotNull ( promCm , "Can't find cm for prometheus-server" ) ; Map < String , String > cmData = promCm . getData ( ) ; String values = cmData . get ( "prometheus.yml" ) . replace ( oldRegex , newRegex ) ; assertNotNull ( values , "can't find values for key prometheus.yml" ) ; cmData . replace ( "prometheus.yml" , values ) ; promCm . setData ( cmData ) ; Kubernetes . replaceConfigMap ( promCm ) ; cmList = Kubernetes . listConfigMaps ( monitoringNS ) . getItems ( ) ; promCm = cmList . stream ( ) . filter ( cm -> "prometheus-server" . equals ( cm . getMetadata ( ) . getName ( ) ) ) . findAny ( ) . orElse ( null ) ; assertNotNull ( promCm , "Can't find cm for prometheus-server" ) ; assertNotNull ( promCm . getData ( ) , "Can't retreive the cm data for prometheus-server after modification" ) ; }
Edit Prometheus Config Map.
Edit Prometheus Config Map .