Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to filter out metrics #4599

Open
dlmarion opened this issue May 23, 2024 · 4 comments · May be fixed by #4736
Open

Add ability to filter out metrics #4599

dlmarion opened this issue May 23, 2024 · 4 comments · May be fixed by #4736
Labels
enhancement This issue describes a new feature, improvement, or optimization.
Milestone

Comments

@dlmarion
Copy link
Contributor

Is your feature request related to a problem? Please describe.
It's possible that a user may not need one or more metrics that we publish via Micrometer.

Describe the solution you'd like
I think we can add a method on MeterRegistryFactory, maybe even a default method, that accepts a comma separated list of regular expressions via a property value, that returns a MeterFilter via MeterFilter.deny(Predicate). This MeterFilter that is returned will need to be added to the MeterRegistry using MeterRegistry.meterFilter.

@dlmarion dlmarion added the enhancement This issue describes a new feature, improvement, or optimization. label May 23, 2024
@keith-turner
Copy link
Contributor

One way to do this w/ the existing code is by subclassing an existing MeterRegistryFactory

package mypackage;

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.config.MeterFilter;
import org.apache.accumulo.core.spi.metrics.LoggingMeterRegistryFactory;

public class FilteringLoggingMRFactory extends LoggingMeterRegistryFactory {
    @Override
    public MeterRegistry create(final InitParameters params) {
       var meterRegistry = super.create(params);
        MeterFilter myFilter = MeterFilter.denyNameStartsWith("accumulo.gc");
        meterRegistry.config().meterFilter(myFilter);
        return meterRegistry;
    }
}

@dlmarion
Copy link
Contributor Author

So, that's a fair point. We don't necessarily have to implement something to provide some base functionality. A user can extend one of our existing implementations or create their own to provide this functionality.

@keith-turner
Copy link
Contributor

We don't necessarily have to implement something to provide some base functionality. A user can extend one of our existing implementations or create their own to provide this functionality.

Wondering if it would be useful to provide some kind of help in the SPI for building micrometer filters related to Accumulo metrics. One possible way to do this would be to have constants related to metrics in the SPI. This could enable writing a MeterRegistryFactory that manipulates Accumulo metrics using those constants. Could have something like the following.

package org.apache.accumulo.core.spi.metrics;

class MetricsConstants {

   static class Tags {
           String INSTANCE_TAG = "instance.name";
  }

  static class Meters {
           String COMPACTIONS_QUEUED = "...";
  }
}

With the above then could have a scenario like the following.

  • Custom MeterRegistryFactory is written against 3.1 that drops the instance name tag. Its impl uses the INSTANCE_TAG constant from the SPI.
  • Accumulo 4.0 makes a major changes to the instance name tag that user need to consider. This change deletes INSTANCE_TAG constant from the SPI.
  • The custom MeterRegistryFactory written against 3.1 no longer compiles against 4.0 forcing an investigation of the change.

Completely unrelated to metrics, but if this approach of putting metrics related constants in the SPI works then it could also potentially work for Accumulo's properties. Could have constants related to those in the SPI maybe.

@ArbaazKhan1
Copy link
Contributor

I can take a look at this

@ArbaazKhan1 ArbaazKhan1 linked a pull request Jul 10, 2024 that will close this issue
@ctubbsii ctubbsii modified the milestones: 3.1.0, 2.1.3 Jul 12, 2024
@ctubbsii ctubbsii modified the milestones: 2.1.3, 2.1.4 Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue describes a new feature, improvement, or optimization.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants