7 Replies Latest reply on Jul 12, 2012 3:49 PM by genman

    REST interface - missing findDataForCompatibleGroup?

    genman

      I would like to get resource group measurements using the REST interface, but there is no such feature. Or is there a way to do this through the existing API in a way I don't know yet.

       

      Was that just an oversight?

        • 1. Re: REST interface - missing findDataForCompatibleGroup?
          pilhuhn

          Elias,

          you are absolutely right, this is currently missing as I have not yet gotten around to implement it (and you are the first one to ask too).

           

          when you say "findDataForCompatibleGroup" - what do you expect? One schedule of the group, which would work by pass a metric definition id.

          Or via a schedule id of one of the group's resources ?

           

          For the start this could be the "buckets" version. For raw data, the situation is more complicated, as here there is no guarantee that all the

          metrics have the same timestamp, so the method would need to return a list of metrics for each group member.

           

            Heiko

          • 2. Re: REST interface - missing findDataForCompatibleGroup?
            pilhuhn

            I've added this to master now:

             

            Get groups:

             

            $ curl -i -u rhqadmin:rhqadmin http://localhost:7080/rest/1/group.json

            [{"id":10491,"category":"MIXED","name":"AS-Servers","explicitCount":1,"resourceTypeId":null,"recursive":true,"links":[{"rel":"edit","href":"http://localhost:7080/rest/1/group/10491"},{"rel":"metricDefinitions","href":"http://localhost:7080/rest/1/group/10491/metricDefinitions"}],"implicitCount":324,"dynaGroupDefinitionId":0},{"id":10471,"category":"COMPATIBLE","name":"CPUs","explicitCount":2,"resourceTypeId":null,"recursive":false,"links":[{"rel":"edit","href":"http://localhost:7080/rest/1/group/10471"},{"rel":"metricDefinitions","href":"http://localhost:7080/rest/1/group/10471/metricDefinitions"}],"implicitCount":2,"dynaGroupDefinitionId":0}]

             

            Get a metric definition -- see link in group e.g.:

             

            $ curl -i -u rhqadmin:rhqadmin http://localhost:7080/rest/1/group/10471/metricDefinitions.json

            [{"type":"DETAIL","displayName":"Idle","unit":"PERCENTAGE","mtime":0,"enabled":false,"links":[{"rel":"metric","href":"http://localhost:7080/rest/1/metric/data/group/10471/10246%3FhideEmpty=true"}],"scheduleId":"10246","collectionInterval":2400000,"scheduleName":"CpuPerc

             

            (technically it is not a 'scheduleId', but a definitionId, that identifies the metric definition, but that should not matter )

             

            Get metric data:

             

            $ curl -u rhqadmin:rhqadmin http://localhost:7080/rest/1/metric/data/group/10471/10248.json?hideEmpty=true

            {"max":0.30582165305367887,"min":0.05427111421818303,"avg":0.18645952391364662,"scheduleId":10248,"group":true,"dataPoints":[{"value":0.06151586271180798,"timeStamp":1341902397076,"low":0.05427111421818303,"high":0.06876061120543293},{"value":0.10896352207179844,"timeStamp":1341903357076,"low":0.10092163594546849,"high":0.11700540819812838},{"value":0.13855196456598706,"timeStamp":1341904797076,"low":0.13411941169117952,"high":0.14298451744079463},{"value":0.12265093962415034,"timeStamp":1341905757076,"low":0.1168782487005198,"high":0.1284236305477809},{"value":0.18660119548815768,"timeStamp":1341907197076,"low":0.18119898958741487,"high":0.19200340138890046},{"value":0.19718834161688464,"timeStamp":1341908157076,"low":0.18904652479435174,"high":0.20533015843941754},{"value":0.24463939989238603,"timeStamp":1341909597076,"low":0.23790110797088762,"high":0.2513776918138845},{"value":0.26374762953628095,"timeStamp":1341910557076,"low":0.25594647960076317,"high":0.27154877947179873},{"value":0.17025525264802915,"timeStamp":1341911997076,"low":0.163495646565624,"high":0.17701485873043435},{"value":0.3011033242580081,"timeStamp":1341912957076,"low":0.2963849954623374,"high":0.30582165305367887},{"value":0.27972898984530103,"timeStamp":1341914397076,"low":0.27365922718187874,"high":0.2857987525087233},{"value":0.16256786470496754,"timeStamp":1341915357076,"low":0.1576944898708407,"high":0.16744123953909437}],

            "numDataPoints":60,"minTimeStamp":1341902397076,"maxTimeStamp":1341915357076}

             

            Get aggregates for the group:

             

            $ curl -u rhqadmin:rhqadmin http://localhost:7080/rest/1/metric/data/group/10471.json

            [{"max":"NaN","min":"NaN","scheduleId":10246,"avg":"NaN","group":true,"dataPoints":[],"numDataPoints":0,"minTimeStamp":0,"maxTimeStamp":0},{"max":0.07908003833173617,"min":0.03268251273344652,"scheduleId":10247,"avg":0.05440870694298016,"group":true,"dataPoints":[],"numDataPoints":0,"minTimeStamp":0,"maxTimeStamp":0},{"max":0.30582165305367887,"min":0.05427111421818303,"scheduleId":10248,"avg":0.18645952391364662,"group":true,"dataPoints":[], .........

             

             

            Let me know if this helps you

             

              Heiko

            • 3. Re: REST interface - missing findDataForCompatibleGroup?
              genman

              Thanks for adding this :-) :-) :-) I was going to do this but it is a bit of delay contributing the code back.

               

              I will need to backport to 4.2 and 4.4 but I imagine this is pretty easy to do.

              • 4. Re: REST interface - missing findDataForCompatibleGroup?
                pilhuhn

                For 4.4 the backport should be straightforward with the 2 commits I made (actually the 2nd is still local on my disk). If you have the rest api already on 4.2, I think the same patches may apply there as well, as I did not change any "inner" SLSBs.

                 

                Wrt contributing - I am sure there are still other areas left :-)

                 

                Thanks

                   Heiko

                • 5. Re: REST interface - missing findDataForCompatibleGroup?
                  genman

                  Heiko,

                   

                  Can we get the 'dataPoints' parameter added as well? I have been enjoying querying using the REST interface with 100+ data points.

                  • 6. Re: REST interface - missing findDataForCompatibleGroup?
                    pilhuhn

                    Elias,

                    I have added that.

                     

                    Can you please report your experience and changes wrt the number of datapoints? Did you just extend rhq_numbers to e.g. 300 entries and then everything works ok?

                     

                      Heiko

                    • 7. Re: REST interface - missing findDataForCompatibleGroup?
                      genman

                      I admin a test system with about 100 machines and haven't had trouble with it. I've only gone up to 240 so far.

                       

                      I do noticed when there's lots of points requested and not a ton of data you end up with NaN values for a lot of them.