How do I reduce the metric collection time interval?

Hi
I want to know if it is possible to reduce the time between metric collections.
I found in the metric collector worker creation that the 5 minute period can be overwritten defining config.Period but I don’t know how to set that.
I tried to put the period config variable in the config.yml of the charm but it didn’t work. How can I do that?

https://github.com/juju/juju/blob/2.7/worker/metrics/collect/manifold.go

Thanks

1 Like

Hi @endikap100,

Although we do allow the collect period to be configured, unfortunately it’s not wired up at the moment. You can see where it could/should be wired up, it’s just a matter of doing it.

I think the best way forward is to raise a bug so it can be prioritised.

Done, thanks for the reply
https://bugs.launchpad.net/juju/+bug/1854144

I could have sworn you could manually trigger the collect-metrics hook tool with juju run so that you can trigger it to speed up during development. Perhaps @cmars can suggest the best practice for aiding development if that’s the goal.

Yes I remember seeing that in the docs. As a bit of an escape hatch, could always run collect-metrics via juju exec.

I tried to force the execution of collect-metrics but the hook returns “ERROR cannot record metric: metrics not allowed in this context”, any suggestion?

used command:
juju run -a testtimetwo-b-essence-ims-vdu-ab hooks/collect-metrics

I’m using this collect metrics in open source mano:
https://github.com/AdamIsrael/layer-metrics-proxy

full output:
ERROR cannot record metric: metrics not allowed in this context
hooks/collect-metrics:65: YAMLLoadWarning: calling yaml.load() without Loader=… is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
doc = yaml.load(f)
Traceback (most recent call last):
File “hooks/collect-metrics”, line 68, in
check_call(command)
File “/usr/lib/python3.5/subprocess.py”, line 581, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘add-metric’, ‘preregistered_users=0’, ‘users_in_dialog=0’, ‘users=5027’]’ returned non-zero exit status 1

Ah, I forgot about that. hooks/collect-metrics has special rules for when it is allowed to be executed.

Which charm are you deploying in the testtimetwo-b-essence-ims-vdu-ab? You might be able to run the commands defined in metrics.yaml directly…

It’s a custom charm.
I want OSM to collect the metrics, so if I execute the command defined in metrics.yaml the metric is not going to be stored.
thanks anyways

1 Like