cancel
Showing results for 
Search instead for 
Did you mean: 

Pipeline monitoring api usage of org_wide

vincenr
New Contributor III

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.

image

12 REPLIES 12

vincenr
New Contributor III

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

vincenr
New Contributor III

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:
‘https://elastic.snaplogic.com/api/1/rest/public/runtime/’

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!