How to custom metric + property?
robertrv Dec 11, 2013 7:35 AMHello every body!
first of all, I am not sure this is the place where I should send this message, so if is not here the correct place, please correct me!
I am trying to create a custom metric for mod_cluster. In fact what I want is to have a metric that can manage to send all the information about the metric to AWS CloudWatch so we can auto scale based on this, in order to use this service we need public and secret keys. This interceptor just need to bypass everything and store the final load number, so I would like to be able to change the metric used (business, heap or cpu) to adapt at any time our service depending on application behavior.
I have two options
- First one (not preferred) is to rewrite mod_cluster class DynamicLoadBalanceFactorProvider so I can handle any call here and send it back to AWS CloudWatch service, this will help because I can manage to have any metric with the same flexibility mod_cluster provide. The cons here will be that I have to add authentication tokens for the external service which I was thinking about using just JVM params because don't see where to set extra metrics, but this is an small cons; the other cons is that I have to reimplement mod_cluster ...which obviously is not a good solution.
- The other solution is to use the tag custom-load-metric. This metric will contain the credentials and some other properties and some of this properties to be the other metrics. This metrics should be just string values and resolve the at my metric. Just started with a simple metric, is added and called but does not receive the property definition. I mean, I have:
- standalone.xml:
<dynamic-load-provider history="10" decay="2"> <load-metric type="heap" weight="1" capacity="3725"/> <load-metric type="busyness" weight="2" /> <load-metric type="cpu" weight="3" capacity="2" /> <custom-load-metric class="com.netquest.jboss.metric.MyCustomMetric"> <property name="foo" value="accessKeyvalue" /> <property name="accessKey" value="accessKeyvalue" /> <property name="privateKey" value="privateKeyValue" /> </custom-load-metric> </dynamic-load-provider>
- My metric I have two attributes with public setters and getters:
private String accessKey = "empty"; public String getAccessKey() { return accessKey; } public void setAccessKey(String accessKey) { this.accessKey = accessKey; }
- And on getLoad I printout the value which are always empty ...
What do you think? There are other solutions or any documentation about how to implement it? About the property problem, did you have any idea why property are not being wired?
thanks in advance, robert