I need to update the aggs.metrics... Can I create a plugin for Kibana that does that?
I believe so. Take a look at the existing metrics as a guide for creating your own. Usually there is a registry of some kind that we use to allow plugins to register new things, but I don't see that for metrics currently. Maybe I'm missing it. However,
src/ui/public/agg_types/index.js is where they are all built, and it just exports an IndexedArray, which extends the Array prototype, so you should be able to push a new metric definition onto it. It's pretty hacky, but it should work...
Sounds like you got it working though, did you do something different?
I want to iterate over all existing visualization and update the aggFilter to exclude the custom metric.
Well, you should be able to access all of the visualizations through the vis_types registry, which I believe will allow you to mutate the records. See
src/ui/public/vislib_vis_type/vislib_vis_type.js for how those objects work. This, again, is kind of hacky, but I believe it will work.