gatus icon indicating copy to clipboard operation
gatus copied to clipboard

split config files

Open jiiro974 opened this issue 2 years ago • 1 comments

Describe the feature request

Currently all config is in a single file

Splitting config into mutliple files can improve readability

for example : config/generic.yaml with all global config

metrics: true                                                                                                                                                                                                                                                                                                                                                                                                       storage:                                                                                                                                                                                                    
  type: sqlite                                                                                                                                                                                              
  path: data.db                                                                                                                                                                                           remote:                                                                                                                                                                                                     
  instances:                                                                                                                                                                                                
  - endpoint-prefix: "Remonte Node~"                                                                                                                                                                             
    url: "http://8.8.8.8:8080/api/v1/endpoints/statuses"        

config/host1.yaml with host1

  - name: host1-ping
    url: "icmp://host1"
    conditions:
      - "[CONNECTED] == true"

  - name: host1-tcp6739
    url: "tcp://host1:6739"
    conditions:
      - "[CONNECTED] == true"

Adding a notion of "service" can be great (so we can link a node with multiples services)

config/host1.yaml with host1

  - name: host1
    service : ping
      url: "icmp://host1"
      conditions:
        - "[CONNECTED] == true"
    service: redis
      url: "tcp://host1:6739"
      conditions:
        - "[CONNECTED] == true"

Thanks !

Why do you personally want this feature to be implemented?

improve readability and maintainability

How long have you been using this project?

No response

Additional information

No response

jiiro974 avatar Sep 06 '22 10:09 jiiro974

Honestly, I'm not sure how I feel about that.

If you need more than one configuration file because you have too many lines, perhaps it's because there's too many endpoints for one Gatus instance.

While I do understand that configuration files can get rather large, with some comments, it shouldn't harm readability/maintainability, not to mention that you can leverage anchors to make your configs smaller.

For instance, in your example, you mentioned these:

endpoints:
  - name: host1-ping
    url: "icmp://host1"
    conditions:
      - "[CONNECTED] == true"

  - name: host1-tcp6739
    url: "tcp://host1:6739"
    conditions:
      - "[CONNECTED] == true"

  - name: host1
    url: "icmp://host1"
    conditions:
      - "[CONNECTED] == true"

  - name: redis
    url: "tcp://host1:6739"
    conditions:
      - "[CONNECTED] == true"

Well, you can shorten them like so:

default-endpoint: &default
  conditions:
    - "[CONNECTED] == true"

endpoints:
  - name: host1-ping
    url: "icmp://host1"
    <<: *defaults

  - name: host1-tcp6739
    url: "tcp://host1:6739"
    <<: *defaults

  - name: host1
    url: "icmp://host1"
    <<: *defaults

  - name: redis
    url: "tcp://host1:6739"
    <<: *defaults

The benefits are not that pronounced in the example above because the defaults are rather small, but it does add up.

Another of my concerns would also be that we'd now have to watch more files so that we can reload the application if they get updated.

I do understand where you're coming from, though, but I'm just not sure if this is something worth implementing right now.

TwiN avatar Sep 14 '22 23:09 TwiN

👍

This would help in setting up the application on kubernetes. At the moment we're trying to add a postgres connection, however we want to store the sensitive part (username/password) in a secret instead of the configmap. Having the ability to split the config files would make this possible.

kobellem avatar Oct 13 '22 12:10 kobellem

I'd also like to second the usefulness of managing this solution with split files. Our Gatus configuration file is over 1600 lines, and we anticipate needing to monitor more endpoints in the future. We can use the default condition syntax above, but it will still be quite lengthy.

diamonddelt avatar Nov 03 '22 15:11 diamonddelt

I also think this would be useful and it's not just about the configuration file length, in k8s you might want to have the config for a specific service as a ConfigMap on that service's helm chart so each service manages its own monitoring config, the same way it would have its own PrometheusRules or Grafana dashboards...

luisdavim avatar Jan 03 '23 11:01 luisdavim

Implemented by #396

TwiN avatar Jan 08 '23 23:01 TwiN