Forum Discussion

Claudius's avatar
13 years ago

"Realtime" metric & for a certain period via REST API

We are currently trying to plug in Lithium metrics into another monitoring solution and would like to get daily/hourly/minutely metrics on views/posts per board.

 

Question 1:

I can't find a way to limit e.g. the message count to a certain time period. I tried without success (e.g. no difference to the count without the "date_start" parameter):

http://skypec.lithium.com/skypec/restapi/vc/boards/id/Windows/messages/count?date_start=2012-01-01&date_end=2012-01-20

 

Question 2:

I tried to use the "Metrics" API object to pull the hourly data but couldn't get it working, e.g. with this url

http://skypec.lithium.com/skypec/restapi/vc/boards/id/Windows/metrics/name/views/history/daily  

 

I keep receiving

 

UserRef does not have access to RequiredPermissions[(allow_access_metrics)] 

 

 Although the user has full REST APi read and general metrics access. On stage there's an even weirder error message:

The maximum number of hourly metrics allowed is 8760, but 372591 hours were requested.

Interestingly neither of the numbers mentions keeps changing when refresing the page or trying at other times of the day.

What's wrong there? 

 

Bonus question:

How realtime are the REST API data? Will I see a new message being posted reflect in the message count of a board the next minute?

  • Hi Claudius,

     

    Question 1

     

    Unfortunately the method you're working with doesn't have a way to bound the search results. However, you could use search instead. For example:

    http://skypec.lithium.com/skypec/restapi/vc/boards/id/Windows/search/messages/count

     

    For your query, you can search on the date field. You specify the date field as a range with the endpoint values specified in seconds since epoch, like so:

    date:[1341341612 TO 1341946412]

     It's a good ideal to URL encode your query string parameter values:

    date%3A%5B1341341612%20TO%201341946412%5D

     

    Putting it all together:

    http://skypec.lithium.com/skypec/restapi/vc/boards/id/Windows/search/messages/count?q=date%3A%5B1341341612%20TO%201341946412%5D&collapse_discussion=false
    

     

    You may have noticed the extra collapse_discussion parameter at the end. That disabled collapsing of search results, which essentially combines multiple results from the same topic into a single result, like how it's shown in the UI. This way, you're getting all of the messages.

     

    Question 2

     

    I'd suggest specifying the date_start and/or date_end parameters for your query. They're listed as optional in the JavaDocs, but if you don't specify the parameters then the query is unbounded. So what's likely happening is that with how much history your community already has, you're exceeding the result limit imposed for that method because you're requesting results for the entire history of your community.

     

    Bonus Question

     

    I'd say that most methods are as real-time as the UI. There may be a few methods here and there that are cached for performance, but with getting counts for messages, you shouldn't have any issues.

     

     

    Regards,

     

    Adam

  • AdamN's avatar
    AdamN
    Khoros Oracle

    Hi Claudius,

     

    Question 1

     

    Unfortunately the method you're working with doesn't have a way to bound the search results. However, you could use search instead. For example:

    http://skypec.lithium.com/skypec/restapi/vc/boards/id/Windows/search/messages/count

     

    For your query, you can search on the date field. You specify the date field as a range with the endpoint values specified in seconds since epoch, like so:

    date:[1341341612 TO 1341946412]

     It's a good ideal to URL encode your query string parameter values:

    date%3A%5B1341341612%20TO%201341946412%5D

     

    Putting it all together:

    http://skypec.lithium.com/skypec/restapi/vc/boards/id/Windows/search/messages/count?q=date%3A%5B1341341612%20TO%201341946412%5D&collapse_discussion=false
    

     

    You may have noticed the extra collapse_discussion parameter at the end. That disabled collapsing of search results, which essentially combines multiple results from the same topic into a single result, like how it's shown in the UI. This way, you're getting all of the messages.

     

    Question 2

     

    I'd suggest specifying the date_start and/or date_end parameters for your query. They're listed as optional in the JavaDocs, but if you don't specify the parameters then the query is unbounded. So what's likely happening is that with how much history your community already has, you're exceeding the result limit imposed for that method because you're requesting results for the entire history of your community.

     

    Bonus Question

     

    I'd say that most methods are as real-time as the UI. There may be a few methods here and there that are cached for performance, but with getting counts for messages, you shouldn't have any issues.

     

     

    Regards,

     

    Adam

    • luk's avatar
      luk
      Boss
      AdamN: is it possible to specify multiple parameters in q? e.g. besides date[start To end] also is_root:true?