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

poc: custom scripts #596

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jcsaaddupuy
Copy link

Hi,

Using a custom script in a endpoint would allow anyone to support any custom target.

This MR is a poc to execute a custom script, and be able to check in conditions the exit code, the script stdout/stderr.

Example configuration :

  - name: custom script
    script:
      command: "echo -n HELLO"
    interval: 10s
    conditions:
      - "[EXIT_CODE] == 0"
      - "[STDOUT] == HELLO"

I did not implement tests yet, and the MR may not be clean.
Let me know what you think !

@TwiN
Copy link
Owner

TwiN commented Oct 18, 2023

Gatus' Docker image doesn't have bash installed though, nor does it have curl, wget, echo, etc.

@jcsaaddupuy
Copy link
Author

Indeed.
It's a good thing to keep the default image as light as possible.

But isn't it only a runtime issue?

As a gatus user, it's totally possible to either extend the base image, or build a docker image with a more complex setup and install gatus in it.
This feature can stay totally optional.

Supporting custom script would be a simple way to let end-users implement usecases that are not covered out of the box by gatus.

For example, in my case, I need to check the correct execution of some pipelines persisting data in a bigquery database.
With this feature, I'm able to implement a SQL check based on a python script, delegating all the setup/authentication mechanism outside of gatus.

That could be extended to others cases (for ex: having checks based on complex api calls, proprietary systems/...) while keeping the impact on gatus codebase low - we just check for the exit code after all :)

@jcsaaddupuy
Copy link
Author

To add more material on this proposal, one could build a custom image but still using gatus from the last official image :

FROM busybox # or any other base image, for ex python

COPY --from=twinproduction/gatus /gatus /gatus

COPY ./config /config # inject custom local config defining scripts endpoints
# also should copy custom scripts in PATH

ENV PORT=8080
EXPOSE ${PORT}
ENTRYPOINT ["/gatus"]

I see at least one or two issues (in addition to my own usecase) this would allow to easily support :

Let me know if you find interest in this feature, I can make a proper PR with unittests / clean a little the code.

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

Successfully merging this pull request may close these issues.

2 participants