Skip to content

Commit

Permalink
filtering fix #75
Browse files Browse the repository at this point in the history
  • Loading branch information
eichelbe committed Aug 17, 2022
1 parent 833d82b commit cae90ad
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import de.iip_ecosphere.platform.support.Schema;
import io.micrometer.core.instrument.Measurement;
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.config.MeterFilter;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.exporter.common.TextFormat;
Expand All @@ -58,6 +59,8 @@ public class IipEcospherePrometheusExporter extends MonitoringReceiver {

public static final String DEFAULT_METRICS_SERVLET_NAME = "metrics";
public static final String DEFAULT_METRICS_ENDPOINT = "/" + DEFAULT_METRICS_SERVLET_NAME;
private static final MeterFilter[] METER_FILTERS = MetricsProvider.append(
MetricsProvider.DEFAULT_METER_FILTERS, MeterFilter.denyNameStartsWith("alertmonitor."));

private Tomcat server;
private Context context;
Expand Down Expand Up @@ -155,7 +158,8 @@ protected void doGet(final HttpServletRequest req, final HttpServletResponse res
try {
Set<String> included = parse(req);
TextFormat.write004(writer, AmMetrics.registry.filteredMetricFamilySamples(
id -> included.contains(id) || MetricsProvider.include(id, MetricsProvider.DEFAULT_METER_FILTERS)));
id -> included.contains(id) // below: names in scrape format, filter potentially with "."
|| MetricsProvider.include(id.replaceAll("_", "."), METER_FILTERS)));
writer.flush();
} finally {
writer.close();
Expand Down

0 comments on commit cae90ad

Please sign in to comment.