<div class="gmail_extra">The OP has not said if he uses Guvnor or not. We can only guess.<br><br>"Last run date" is a run-time metric. Guvnor only contains design-time metrics. Therefore you'll have to devise your own mechanism using AgendaListener as Wolfgang proposes.<br>
<br>"Author" (and other such metadata) is stored in Guvnor and is (probably) available using the REST API - but it'll be on a per-asset basis and definitely not lend itself to batch querying (e.g. as with a RDBMS) as you imply.<br>
<br>"Rule validity" is another analysis you do not mention. drools-verifier may be able to help there.<br><br><div class="gmail_quote">On 25 April 2012 17:43, Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 25/04/2012, <a href="mailto:thomashatz@yahoo.com">thomashatz@yahoo.com</a> <<a href="mailto:thomashatz@yahoo.com">thomashatz@yahoo.com</a>> wrote:<br>
> Thanks Wolfgang,<br>
><br>
> But don't the rules tables have basic info like 'last run date and time and<br>
> user' type info...<br>
<br>
</div>I'm not aware of any such information being collected and stored<br>
automatically. But if this is a Guvnor function, I may have a very<br>
blind spot there.<br>
<div class="im"><br>
><br>
> Also how to setup an AgendaEventListener<br>
<br>
</div>It's done as with any other listener in JDK etc. Here are some code<br>
snippets to get you started. This code is not necessarily "best<br>
practice" or anything; it's meant to illustrate the essentials. The<br>
constructor installs the listener.<br>
<br>
public class AgendaWatcher implements AgendaEventListener {<br>
<br>
// useful aux. method<br>
private String ruleNameOfEvent( ActivationEvent actEvent ){<br>
Activation activation = actEvent.getActivation();<br>
Rule rule = activation.getRule();<br>
return rule.getPackageName() + '.' + rule.getName();<br>
}<br>
<br>
public AgendaWatcher( KnowledgeRuntime knowledgeRuntime ){<br>
knowledgeRuntime.addEventListener( (AgendaEventListener)this );<br>
}<br>
<br>
@Override<br>
public void activationCancelled(ActivationCancelledEvent actEvent) {<br>
// happens frequently, for various reasons. may not be of interest.<br>
}<br>
<br>
@Override<br>
public void activationCreated(ActivationCreatedEvent actEvent) {<br>
// same thing.<br>
}<br>
<br>
@Override<br>
public void beforeActivationFired(BeforeActivationFiredEvent arg0) {<br>
}<br>
<br>
@Override<br>
public void afterActivationFired(AfterActivationFiredEvent actEvent) {<br>
// count firings<br>
Counts counts = getCountsForName( ruleNameOfEvent( actEvent ) );<br>
counts.firings++;<br>
}<br>
<br>
@Override<br>
public void agendaGroupPopped(AgendaGroupPoppedEvent arg0) {<br>
}<br>
@Override<br>
public void agendaGroupPushed(AgendaGroupPushedEvent arg0) {<br>
<div class="HOEnZb"><div class="h5"> }<br>
}<br>
<br>
<br>
<br>
<br>
><br>
> Really appreciate your knowledge sharing<br>
><br>
> --- On Tue, 4/24/12, Wolfgang Laun <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>> wrote:<br>
><br>
>> From: Wolfgang Laun <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>><br>
>> Subject: Re: [rules-users] How to query rules to create reports to analyze<br>
>> usage<br>
>> To: "Rules Users List" <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
>> Date: Tuesday, April 24, 2012, 4:30 AM<br>
>> For analyzing "rules usage" an<br>
>> AgendaEventListener should be used to<br>
>> register the information you are interested in. (You<br>
>> wouldn't need to<br>
>> query the rules DB for this anyway.)<br>
>><br>
>> -W<br>
>><br>
>> On 24/04/2012, thatz <<a href="mailto:thomashatz@yahoo.com">thomashatz@yahoo.com</a>><br>
>> wrote:<br>
>> > Am new user to Drools, have 300+ rules, but need to<br>
>> query them using SQL<br>
>> > syntax to create reports and analyze rules usage (if<br>
>> rules are being called,<br>
>> > etc.). App developer said cannot query the rules<br>
>> db directly because it is<br>
>> > proprietary. Is there anyway to query rules or<br>
>> what is best way to analyze<br>
>> > rules usage. Thanks<br>
>> ><br>
>> > --<br>
>> > View this message in context:<br>
>> > <a href="http://drools.46999.n3.nabble.com/How-to-query-rules-to-create-reports-to-analyze-usage-tp3934833p3934833.html" target="_blank">http://drools.46999.n3.nabble.com/How-to-query-rules-to-create-reports-to-analyze-usage-tp3934833p3934833.html</a><br>
>> > Sent from the Drools: User forum mailing list archive<br>
>> at Nabble.com.<br>
>> > _______________________________________________<br>
>> > rules-users mailing list<br>
>> > <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>> > <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>> ><br>
>> _______________________________________________<br>
>> rules-users mailing list<br>
>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>><br>
><br>
> _______________________________________________<br>
> rules-users mailing list<br>
> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br></div>