Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: allow generic REST service? #196

Open
bobfang1992 opened this issue Oct 9, 2019 · 2 comments
Open

Proposal: allow generic REST service? #196

bobfang1992 opened this issue Oct 9, 2019 · 2 comments

Comments

@bobfang1992
Copy link

Hi, this might be a bit naive but is it possible to allow the monitor to query against any generic REST service and then just display the response?

For example a config can look at this:

{
  "name": "REST",
  "domain": "mydoamin.com",
  "configuration": {
    "slugs": [
         {
            "url": "/api/v1/is_service_okay",
            "extractor": "status",
            "pattern": {
                "okay": "green",
                "error": "red"
             }
         }
    ]
  }
}

The the monitor will periodically hit mydomain.com/api/v1/is_service_okay and then check the return value. It extract the result using payload["status"] as specified by the extractor (there might be more suitable json extracting syntax out there, just an example" and then match the result with the pattern you specified, if it is okay then show green, if not then show red.

Do you think this is possible? If so I could contribute, where do I start?

@bobfang1992
Copy link
Author

https://www.npmjs.com/package/jsonpath for extracting fields...

@bobfang1992 bobfang1992 changed the title Propossal: allow generic REST service? Proposal: allow generic REST service? Oct 10, 2019
@marcells
Copy link
Owner

Hi @bobfang1992,

yes, you can implement this Service, if you want to. Just create the service in the app/services folder. You can take a look at Tfs2015.js for a simple implementation how a service looks like.

I think, that only a extractor setting is not enough. You need some kind of a field mapping, too. But you will see this, while implementing the service.

The generic build format for the build monitor looks is the following:

{
    id: ...,
    project: ...,
    definition: ...,
    number: ...,
    isRunning: ...,
    startedAt: ...,
    finishedAt: ...,
    requestedFor: ...,
    statusText: ...,
    status: ...,
    reason: ...,
    hasErrors: ...,
    hasWarnings: ...,
    url: ...
}

Kind regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants