-
Notifications
You must be signed in to change notification settings - Fork 94
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 an ID field to filters #174
Comments
Should it be a label on the Filter's assigned metric(s), rather than part of the name? Might be good to see the total metrics in for a given filter, then dig down into each individual one? I'm assuming here that ids for Filters are probably going to be a small set -- but we can't guarantee it. WDYT? |
Not entirely sure I follow, do you mean rather than e.g |
Ah ignore me - you were already saying to use a label, I just didn't quite grok that. We're on the same page. 👍 |
Looking at this now, would it make sense if instead there was some kind of wrapper newtype struct around a filter? I'm just trying to think if there are cases where you explicitly wouldn't want a filter to have an ID, and if not it might be easier to keep it in one place, rather than duplicating the field across each filter. I was thinking something like the following: struct TrackedFilter<F> {
id: Option<Uuid>,
filter: F
}
impl<F: Filter> Filter for TrackedFilter<F> {
fn read(&self, ctx: ReadContext) -> Option<ReadResponse> {
self.filter.read(ctx)
}
fn write(&self, ctx: WriteContext) -> Option<WriteResponse> {
self.filter.write(ctx)
}
} |
Yeah it would be nice if we can have it in one place. At least all of the builtin filters would include an ID either to tag metrics/log info and a filter that doesn't need it can ignore the value. though custom filters won't necessarily have one. |
Good points.
Well we could make it a requirement for all filters by adding I think it probably depends on whether you want the encapsulation to be in the filters or in metrics. Like do we want metrics to work with potentially any filter? Or do we want filters supposed to be mostly opaque and have complete control over metrics? |
Its up to the filter to export the metric they choose to - we pass in the metrics registry and they register any implementation specific metrics, in that sense its mostly opaque yeah. Currently its not required that a filter has an id since the current use cases of metrics/logs are implementation specific (e.g a filter that doesn't export any metrics doesn't need one). Not sure if there'll be a use case that requires quilkin to know an ID of a filter and we can add it to the trait if that shows up |
Something that came up when I was implementing this, is "What ID should a |
The |
Well FilterChain::new([
Debug::new(),
LoadBalancer::new(),
Authentication::new(),
FilterChain::new([
Compression::new(),
Debug::new(),
Encryption::new(),
]),
Scriptable::new(),
]) Where as if |
That makes sense, I don't think FilterChain was intended to be public (if it is today it shouldn't be since its not mentioned in the docs for example) but yeah we could expose it. |
Should the id be a |
Is this resolved now? |
Just peeking through this - we have a (source) /// Filter is the configuration for a single filter
#[derive(Debug, Deserialize, Serialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct Filter {
pub name: String,
pub config: Option<serde_yaml::Value>,
} But I don't think this information makes its way to the (source) /// Arguments needed to create a new filter.
pub struct CreateFilterArgs<'a> {
/// Configuration for the filter.
pub config: Option<ConfigType<'a>>,
/// metrics_registry is used to register filter metrics collectors.
pub metrics_registry: Registry,
} So it looks like that work is outstanding at this point. |
....and as soon as I hit "submit" I realise that was wrong. The So it doesn't look like any of this work has been done yet. |
@markmandel yes but I thought from the discussion in #263 we didn’t want instance specific IDs, and |
Oh that's right! If a user did something like dynamically generating a uuid or something for each id, it becomes an possible footgun if they are running lots of proxies. It would be useful though to be able to look at a specific configuration of a filter in a chain and see that that is the one that's causing a performance issue (for example). But maybe this is one of those things where we close this for now and revisit if people want to explore it in the future -- it's entirely possible that in practice people won't actually use multiple instances of a filter that often. @jahrlin any suggestions on how to prevent users from creating their own cardinality bomb accidentally? Do we think documentation is good enough (put some big warnings on it)? |
One way would be to key by the values of the config rather than by the instance, that would provide some kind bound as long as the configuration itself isn’t unbounded. |
Closing this issue, as it seems resolved, and we can always open in a new issue if there's more work. |
We want to be able to assign an
id
(name is already taken) to filters - this would allow us to e.g filter in metrics only coming from a particular filter.id
field of type string - the field is optional and we use a default uuid otherwise.https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels
id
set to the filter's assigned ID.The text was updated successfully, but these errors were encountered: