Solved

Checking FME Server availability using the REST API


Badge +11

Hi,

Just wondering what is the minimal operation required, using the REST API (v3), to test if an FME Server instance is available to process jobs?

For example, how much is a successful response to a “GET info” request telling me? Is it just that the FME Server web services are running (ie. Tomcat) or does it mean that FME Server can accept requests?

Does a “GET repositories” request tell me anything more?

The reason that I’m asking is that I will be using a 3rd party application to monitor FME Server and let me know if it becomes unavailable. I could write a very minimal FME workspace to be called via a submit job request – which would obviously tell me what I need to know – but would prefer not to tie up an engine with spurious job requests. In order to be useful I will need to be polling FME Server on a frequent basis.

Thanks,

Nic

icon

Best answer by nic_ran 4 May 2017, 16:09

View original

9 replies

Userlevel 1
Badge +12

If you want to query whether there are engines running, or with queues you can use a get on transformations/jobs as below:

http://docs.safe.com/fme/html/FME_REST/v2/apidoc/index.html#!/transformations/list_get_11

Userlevel 1
Badge +12

If you want to query whether there are engines running, or with queues you can use a get on transformations/jobs as below:

http://docs.safe.com/fme/html/FME_REST/v2/apidoc/index.html#!/transformations/list_get_11

And you probably want to look at /transformations/engines to confirm the number of engines first

 

 

Badge +16

The best way to know which API end point to use is to acces it via your FME server > help > REST API this way you can see what the result is and if it fits your needs.

Hope this helps.

Userlevel 4

As @todd_davis says, you can use the REST API to query for the number of running engines. Example:

http://myfmeserver/fmerest/v2/transformations/engines?accept=json&detail;=low

It will return a json list object that enumerates the available engines. If you want to see if one of them is free, check for currentJobId = -1, example from a server with two engines:

[
  {
    "hostName": "myfmeserver",
    "resultFailureCount": 0,
    "resultSuccessCount": 0,
    "maxTransactionResultSuccess": 100,
    "instanceName": "myfmeserver_Engine1",
    "transactionPort": 62392,
    "currentJobID": -1,
    "maxTransactionResultFailure": 10,
    "buildNumber": 16716,
    "platform": "WIN32"
  },
  {
    "hostName": "myfmeserver",
    "resultFailureCount": 0,
    "resultSuccessCount": 0,
    "maxTransactionResultSuccess": 100,
    "instanceName": "myfmeserver_Engine2",
    "transactionPort": 54189,
    "currentJobID": -1,
    "maxTransactionResultFailure": 10,
    "buildNumber": 16716,
    "platform": "WIN32"
  }
]

There is also an API call to query the running and queued jobs, if you need more information.

Badge +11

Thanks folks. I figured that checking the available engines was probably the best approach, as per Todd's recommendation, just wanted to see if anyone had alternate solutions/suggestions.

It would be nice if Safe could add a REST call specifically to check for FME Server "availability", however that is best defined. For example, is it possible for the engines to be available but not the Core? They are started and managed by different services. Or for the Engines and Core to be available but not the DB service?

I think checking engine availability is a good start and probably the best solution with the current REST API but I'm just not sure it's a total solution.

It would be nice if Safe could comment on this... :)

Userlevel 4

Thanks folks. I figured that checking the available engines was probably the best approach, as per Todd's recommendation, just wanted to see if anyone had alternate solutions/suggestions.

It would be nice if Safe could add a REST call specifically to check for FME Server "availability", however that is best defined. For example, is it possible for the engines to be available but not the Core? They are started and managed by different services. Or for the Engines and Core to be available but not the DB service?

I think checking engine availability is a good start and probably the best solution with the current REST API but I'm just not sure it's a total solution.

It would be nice if Safe could comment on this... :)

The engines aren't available without the core, so checking for available engines is a very good check, in my opinion.
Badge +11

We had a phone call with the guys at Safe and talked about this point, among other items. I subsequently received an email with the information below. It turns out that there's an undocumented REST API call that can be made to do a quick "health check" to see if the services are running but it still does not test full job processing capability. Anyway, their response is interesting and provides some further context around what the available calls are and what they are checking...

as discussed in our call today, here is the REST endpoint for the FME Sever health check:

<FMEServer_URL>:<PORT>/fmerest/v3/healthcheck

This is the endpoint that we use to check whether our FME Cloud instances are up and running. However I am not 100% anymore if this is what you were looking for. I had a discussion with a developer and it turns out that this call just checks whether the REST API webapp is running. It does not tell you:

1. Is the FME Core process running

2. Is the FME Engine process running

So it is not exactly a indication whether a job can be processed.

The /fmerest/v3/healthcheck endpoint will either return an HTTP 200 response code or not respond at all.

 

The call

<FMEServer_URL>:<PORT>/fmerest/v3/info

will give an indication whether the FME Core process is up, because it calls this process. That said, we would not recommend to hit this endpoint too often as it is single threaded and can put a lot of load on the process. This is the actual reason why we use the healthcheck endpoint.

The /fmerest/v3/info call can return 2 different HTTP status codes depending on the state of the core:

- 200 core is up & running

- 503 Web app can't connect to core

Pinging this endpoint about every 10s should be fine.

 

 

 

Another option is the call

<FMEServer_URL>:<PORT>/fmerest/v3/transformations/engines

This will tell you whether engines are registered and running and therefore this is the best indicator whether a job can be processed or not. However this call will be slower and probably also shouldn't be hit in a too high interval.

As conclusion I'd say the healthcehck gives you an idea wither the tomcat and the machine is up and it can be hit in short intervals. If the FME Server core is running on a different machine this check won't detect if the core is down. The info and engines endpoints will give you more information about the overall status but should also not be hit too often.

Thanks folks. I figured that checking the available engines was probably the best approach, as per Todd's recommendation, just wanted to see if anyone had alternate solutions/suggestions.

It would be nice if Safe could add a REST call specifically to check for FME Server "availability", however that is best defined. For example, is it possible for the engines to be available but not the Core? They are started and managed by different services. Or for the Engines and Core to be available but not the DB service?

I think checking engine availability is a good start and probably the best solution with the current REST API but I'm just not sure it's a total solution.

It would be nice if Safe could comment on this... :)

Bear in mind that the available engine count being zero may mean the server is busy. It may be still available.

 

 

Userlevel 4
Bear in mind that the available engine count being zero may mean the server is busy. It may be still available.

 

 

That should not be the case. The REST API will return the number of licensed and running engines, including a job id if the engine is busy.

 

 

Reply