Pipeline monitoring api usage of org_wide

Please help me figure out what the syntax is for using the org_wide parameter for the pipeline monitoring api.

I’ve tried, but get an error for all of the below:

https://elastic.snaplogic.com/api/1/rest/public/runtime/” + _org + “?last_hours=” + _last_hours + “?org_wide=1”

https://elastic.snaplogic.com/api/1/rest/public/runtime/” + _org + “?last_hours=” + _last_hours + “?org_wide=0”

https://elastic.snaplogic.com/api/1/rest/public/runtime/” + _org + “?last_hours=” + _last_hours + “?org_wide=-1”

If I remove the org_wide, it works but only returns for root of org, understandably. When I look at the error it says it’s expecting an integer, but I’ve already tried: 0, 1, and -1 and none of them work.

Also, the documentation is no help. There’s no example of usage and ‘N/A’ makes no sense for a default value for the boolean.

@vincenr : Based on your question, I’m assuming that you are looking at this documentation page. That page will be deprecated soon and a note at the top of the page includes links to the new topics that replace it.

The newer topic that seems most applicable to the API you want is this page, which shows that the API no longer requires the org_wide parameter. If you don’t specify a project filter, you’ll get results for all projects in the Org.

I hope that helps.

When I remove everything but the ‘last_hours’ parameter, I do not get everything in our org… all I get is whatever has run at the root of our org directory, not all of the projects subsumed under the org directory. So, please help me out here.

Do I need to open a ticket or will someone clarify (see my latest question on community)…?

@vincenr: Are you an Org admin for the Org? If not, you’ll only see what you have permissions to see.

If you are an Org admin, yes, please file a ticket.

Ok, so I downloaded a pipeline I found on your site and it works, but I’m confused as to why mine won’t work using the following:

https://elastic.snaplogic.com/api/1/rest/public/runtime/” + _org + “?last_hours=” + _last_hours + “?state=” + _state

The one I found (below) is much more complicated and I don’t want to just use it without understanding why mine doesn’t work. So obviously, I have rights to see “everything”.

https://elastic.snaplogic.com/api/1/rest/public/runtime/’ + pipe.plexPath.split(‘/’)[1] + ‘?level=summary’ + (_state == null || _state ==“” ? ‘’ : ‘&state=’+ _state) + (_hours == null || _hours ==“” ? ‘’ : ‘&last_hours=’+ _hours) + (_batchsize == null || _batchsize ==“” ? ‘’ : ‘&limit=’+ _batchsize)

My ‘_org’ is preset to our org, but I’ll probably change it to the more generic one.
I do realize a lot of that has nothing to do with the data I want to see, but load balancing for paging.

There was a high level explanation of the api call directly above on the article I found, but not why all the gymnastics with the state parameter and the hours parameter. Also, the ‘level’ parm is not listed on the page you referred me to.

Breaking this command down into the individual elements for explanation:

First is just the path of the API call:

Next is a dynamic way of specifying the org that the pipeline executing the REST GET - pipe.plexPath is a built-in property that gives the full path of the pipeline being executed, then we break that string down into an array of strings using the String.split() method, and finally grab only the array element at index 1.

+ pipe.plexPath.split(‘/’)[1]

Finally, we are using some pipeline parameters to build out the remaining query elements in the URL. If you are not familiar with ternary operators, please take a look at the “Special Operators” section of the Expression Operators documentation.

+ ‘?level=summary’ + (_state == null || _state ==“” ? ‘’ : ‘&state=’+ _state) 
+ (_hours == null || _hours ==“” ? ‘’ : ‘&last_hours=’+ _hours) 
+ (_batchsize == null || _batchsize ==“” ? ‘’ : ‘&limit=’+ _batchsize)`

I hope this helps!

Can you please post the correct API page here for me? You had previously stated the page I was using had been deprecated.

@vincenr: The newer topic is this page.

Thanks for the new page reference. However, I don’t see the ‘level’ parm mentioned that Craig Stewart used. Is there a different API for that?

The API you are using will return you a list of runtimes, with summary data. If you take the RUUID from that make another request with the RUUID in the request too, you get the more detailed info.

Hi Craig,

Just wondering why you had to do all the ternary comparisons with state and hours to get the call to work? Is that analogous to SQL where if sometimes you don’t deal with nulls correctly you won’t get all the results or get incorrect results?

@vincenr - The ternary statements will optionally include the state, hours, last_hours, and limit query parameters to the API call. The values for these are coming from pipeline parameters so you can configure that at run time rather than have them hardcoded into the call.

1 Like